Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple zeros for linear equation #1122

Open
wangzuodong1997 opened this issue Apr 20, 2024 · 1 comment
Open

Multiple zeros for linear equation #1122

wangzuodong1997 opened this issue Apr 20, 2024 · 1 comment

Comments

@wangzuodong1997
Copy link

Hello, I curruntly observed a strange behavior of the symbolic computation. I was trying to find the minimize of a quadratic function, by looking for the unique zero of its derivative (since its derivative is an affine function). But I finally find at least 3 zeros for this affine function. Could you please help me to figure out the problem?

In the following code, the variable is b, and the other variables are considered as parameters. The quadratic function is given by r, its derivative with respect to b is given by dr. At the end of the code, I printed three values which make the affine function equal to zero.

#############################

using Symbolics

let

@variables b, p, c, d, e, f, g, h


a(b) = -c/d - b*e/d

r(b) = c + 2*a(b)*d  + 2*b*e + a(b)*a(b)*f+ 2*a(b)*b*g+ b*b*h
sss(b) = c + 2*a(b)*d  + 2*b*g + a(b)*a(b)*f+ 2*a(b)*b*g+ b*b*h

dr(b) =  Symbolics.derivative(r(b), b)
dssss(b) = Symbolics.derivative(sss(b), b)

c_r = Symbolics.solve_for(dr(b) ~ 0,b)
c_s = Symbolics.solve_for(dssss(b) ~ 0,b)

@show simplify(r(b))

@show simplify(dr(b))

@show simplify(c_r)

@show simplify(c_s)

@show simplify(dr(c_s))
@show simplify(dr(1))
@show simplify(dr(c_r))


end

#####################

@wangzuodong1997
Copy link
Author

And my output is:

simplify(r(b)) = ((c^2)*f - c*(d^2) - 2.0b*c*d*g + 2.0b*c*e*f + (b^2)*(d^2)*h - 2.0(b^2)*d*e*g + (b^2)*(e^2)*f) / (d^2)
simplify(-a1 / (2a2)) = (2.0c*d*g - 2.0c*e*f) / (2((d^2)*h - 2.0d*e*g + (e^2)*f))
simplify(dr(b)) = (-2.0c*d*g + 2.0c*e*f + 2.0b*(d^2)*h - 4.0b*d*e*g + 2.0b*(e^2)*f) / (d^2)
simplify(c_r) = (-c*d*g + c*e*f) / (-(d^2)*h + 2.0d*e*g - (e^2)*f)
simplify(c_s) = (-c*d*g + c*e*f - (d^2)*e + (d^2)*g) / (-(d^2)*h + 2.0d*e*g - (e^2)*f)
simplify(dr(c_s)) = 0
simplify(dr(1)) = 0
simplify(dr(c_r)) = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant