How do I solve this system of equations for real number?

23 views (last 30 days)
syms x y z
eqn1= x+y+z== 16;
eqn2= x*y+y*z+z*x ==41.75;
eqn3= x*y*z== -178;
S = solve(eqn1,x,'Real',true);
H = solve(eqn2,y,'Real',true);
F = solve(eqn3,z,'Real',true);
I want to solve for x, y, z as real numbers but idk how this is just giving me it with the other variables.

Accepted Answer

Star Strider
Star Strider on 27 Sep 2019
You have not assigned numeric values to ‘x’, ‘y’, and ‘z’, so what you currently have is the best you can do.

More Answers (1)

John D'Errico
John D'Errico on 27 Sep 2019
Edited: John D'Errico on 27 Sep 2019
Whats the problem? There appear to be six real solutions. Solve finds them with no problem.
xyz = solve(eqn1,eqn2,eqn3)
xyz =
struct with fields:
x: [6×1 sym]
y: [6×1 sym]
z: [6×1 sym]
>> xyz.x
ans =
(3*17^(1/2))/2 + 4
4 - (3*17^(1/2))/2
(3*17^(1/2))/2 + 4
8
4 - (3*17^(1/2))/2
8
>> xyz.y
ans =
4 - (3*17^(1/2))/2
(3*17^(1/2))/2 + 4
8
(3*17^(1/2))/2 + 4
8
4 - (3*17^(1/2))/2
>> xyz.z
ans =
8
8
4 - (3*17^(1/2))/2
4 - (3*17^(1/2))/2
(3*17^(1/2))/2 + 4
(3*17^(1/2))/2 + 4
You can convert them to numeric form using either vpa or double.
What you cannot do is use solve as you tried to do, for some reason, thinking you could solve each equation independenty.

Tags

Community Treasure Hunt

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

Start Hunting!