Incorrect Calculation when using symunit in Symbolic Math Toolbox
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Breyonna
el 29 de Nov. de 2023
Movida: Dyuman Joshi
el 11 de Dic. de 2023
clc,clear
syms x a
u = symunit;
a = 1.01325*u.bar
b = -0.049576382*u.bar*u.m^3/u.mol
c = .000003657553277*u.bar*u.m^6/(u.mol)^2
d = -.00000000015676624*u.bar*u.m^9/u.mol^3
eqn = a*x^3+b*x^2+c*x+b == 0
solve(eqn,x,"MaxDegree",3)
vpa(solve(eqn,x,'MaxDegr
Output: 0.016
clc,clear
syms x
u = symunit;
a = 1.01325
b = -0.049576382
c = 3.657553277*10^-6
d = -1.5676624*10^-10
eqn = a*x^3+b*x^2+c*x+b == 0
solve(eqn,x,"MaxDegree",3)
vpa(solve(eqn,x,'MaxDegree',3),10)
Output: 0.382
a = 1.01325
b = -0.049576382
c = 3.657553277*10^-6
d = -1.5676624*10^-10
x = [a b c d];
vpa(roots(x),10)
Output: 0.048
u = symunit;
a = 1.01325*u.bar
b = -0.049576382*u.bar*u.m^3/u.mol
c = .000003657553277*u.bar*u.m^6/(u.mol)^2
d = -.00000000015676624*u.bar*u.m^9/u.mol^3
x = [a b c d];
vpa(roots(x),10)
Output: root(z^3 - ((sym("223272175501577375")*z^2)/sym("4563272322433155072"))*(symunit("m")^3/symunit("mol")) + ((sym("539759593894213625")*z)/sym("149529307461489625399296"))*(symunit("m")^6/symunit("mol")^2) - sym("252691673573204875/1633258782299364015028043776")*(symunit("m")^9/symunit("mol")^3), z, 1)
Wolfram Alpha Answer: 0.048
2 comentarios
Dyuman Joshi
el 29 de Nov. de 2023
Where exactly do you get the output 0.016 from the first snippet of code?
Do you mean the sigma2 value? If yes, then you are misunderstanding the solution. The solutions are the elements of the 3x1 vector, where the terms have been grouped. And the information below the solutions show, which terms have been grouped into the respective variables.
Also, there's a mistake in the 2nd piece of code, you have written a*x^3 + b*x^2 + c*x + b == 0, it should be d instead of b. Correcting the mistake leads to the correct output, see below -
clc,clear
syms x a
u = symunit;
a = 1.01325*u.bar;
b = -0.049576382*u.bar*u.m^3/u.mol;
c = .000003657553277*u.bar*u.m^6/(u.mol)^2;
d = -.00000000015676624*u.bar*u.m^9/u.mol^3;
eqn = a*x^3+b*x^2+c*x+b == 0
vpa(solve(eqn,x,"MaxDegree",3), 10)
clc,clear
syms x
u = symunit;
a = 1.01325;
b = -0.049576382;
c = 3.657553277*10^-6;
d = -1.5676624*10^-10;
% v
eqn = a*x^3+b*x^2+c*x+d == 0;
solve(eqn,x,"MaxDegree",3);
vpa(solve(eqn,x,'MaxDegree',3),10)
clear
a = 1.01325;
b = -0.049576382;
c = 3.657553277*10^-6;
d = -1.5676624*10^-10;
x = [a b c d];
vpa(roots(x),10)
u = symunit;
a = 1.01325*u.bar;
b = -0.049576382*u.bar*u.m^3/u.mol;
c = .000003657553277*u.bar*u.m^6/(u.mol)^2;
d = -.00000000015676624*u.bar*u.m^9/u.mol^3;
x = [a b c d];
vpa(roots(x),10)
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!