Need some help with an odd output with solve

Hello, first time asking a question here. I am having a bizarre output when I try to use solve, and would like some help.
Here is the code:
syms x
eqn = (1315.2/(8.22-x))+(895.4/(2.42-x))+(240/(1-x))+(9.45/(0.378-x))+(0.75/(0.15-x))==800;
solx=solve(eqn,x)
And here is the output:
solx =
0
root(z^4 - (2273*z^3)/250 + (63332491*z^2)/4000000 - (1367320551*z)/200000000 + 721613169/1000000000, z, 1)
root(z^4 - (2273*z^3)/250 + (63332491*z^2)/4000000 - (1367320551*z)/200000000 + 721613169/1000000000, z, 2)
root(z^4 - (2273*z^3)/250 + (63332491*z^2)/4000000 - (1367320551*z)/200000000 + 721613169/1000000000, z, 3)
root(z^4 - (2273*z^3)/250 + (63332491*z^2)/4000000 - (1367320551*z)/200000000 + 721613169/1000000000, z, 4)
I don't know if it's a problem with the code, or with my computer, but I'm unsure of what the z's in the solution correlate to. I'm also wondering if I can output the solution as just numbers, rather than these roots.
Thank you for answering, in advance.

 Accepted Answer

Use the vpasolve function to get numerical output:
syms x
eqn = (1315.2/(8.22-x))+(895.4/(2.42-x))+(240/(1-x))+(9.45/(0.378-x))+(0.75/(0.15-x))==800;
solx=vpasolve(eqn,x)
solx =
0
0.1585817446596710456915191570641
0.41963427877318302442907239553912
1.5592338740562100917600813995941
6.9545501025109358381193270478027

2 Comments

Why are you ignoring the imaginary part of the solution in the question?
The z in the answer is telling that the solutions have imaginary components.
You already have the answer, just to translate from symbolic to numerical:
vpa(solx)
ans =
0
0.1585817446596710456915191570641 + 5.4049015967984410970242199180548e-40i
0.41963427877318302442907239553912 - 6.0171382378517158407579368645247e-40i
1.5592338740562100917600813995941 + 3.0611832052663737186685847323496e-41i
6.9545501025109358381193270478027 + 3.0611832052663737186685847323496e-41i
If you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John
Interesting that vpasolve returned different results than vpa(solx). The imaginary parts are vanishingly small, and likely the result of computational inaccuracies.

Sign in to comment.

More Answers (2)

double(solx)
Or,
solx = solve(eqn, x, 'MaxDegree', 4)
but be warned this is going to give you quite long solx.
(((80000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^2)/160801 - (800000000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^4)/2605105001601 + 8000)*((40000000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^4)/2605105001601 - (4000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^2)/160801 + 40401/100))/(((40000000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^4)/2605105001601 - (4000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^2)/160801 + 40401/100)^2 - (40401*((1000000000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^4)/2605105001601 - (100000*root(z^6 - (16200801*z^4)/10000 + 16924119873732035442801/40000000000000000, z, 1)^2)/160801 + 10)^2)/25)^(1/2)

Tags

Community Treasure Hunt

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

Start Hunting!