solve(eqn,x) giving wrong answer
Show older comments
Hello,
I am working with some polynomials and am solving for x and unfortunately I am not getting the correct answer which is really baffling. You can run it to get the answer, but if you take both solutions and work backwards for some value of x and y they are not correct. I was wondering if maybe my use of FloatingPointOutput is the issue?
sympref('FloatingPointOutput',true)
syms x y
eqn = -1.5960e-06*x^2 + 0.0367*x - 2.0468 == y
solx = solve(eqn,x)
I plugged this same formula into symbolab.com and got the correct answer (0.00133... is truncated but I confirmed the first one is the correct answer)

Not sure what's going on here...
Thanks!
Answers (2)
It looks the same to me. Just do the algebra.
b = -0.0367;
d = 0.000003192;
% Note that these values match what MATLAB is giving you
your_R1Coeff1 = -b/d
your_R1coeff2 = 1/d
You can check the answer.
sympref('FloatingPointOutput',true)
syms x y
eqn = -1.5960e-06*x^2 + 0.0367*x - 2.0468 == y
solx = solve(eqn,x)
simplify(subs(eqn, x, solx))
leftside = lhs(eqn)
simplify(subs(leftside, x, solx))
Looks right to me.
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!