solve(eqn,x) giving wrong answer

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)
ans = logical
0
syms x y
eqn = -1.5960e-06*x^2 + 0.0367*x - 2.0468 == y
eqn = 
solx = solve(eqn,x)
solx = 
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!

Respuestas (2)

Cris LaPierre
Cris LaPierre el 24 de Ag. de 2021
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_R1Coeff1 = 1.1497e+04
your_R1coeff2 = 1/d
your_R1coeff2 = 3.1328e+05
Steven Lord
Steven Lord el 24 de Ag. de 2021
You can check the answer.
sympref('FloatingPointOutput',true)
ans = logical
1
syms x y
eqn = -1.5960e-06*x^2 + 0.0367*x - 2.0468 == y
eqn = 
solx = solve(eqn,x)
solx = 
simplify(subs(eqn, x, solx))
ans = 
leftside = lhs(eqn)
leftside = 
simplify(subs(leftside, x, solx))
ans = 
Looks right to me.

Categorías

Productos

Versión

R2021a

Preguntada:

el 24 de Ag. de 2021

Respondida:

el 24 de Ag. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by