How do I solve this system of equations for real number?
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Allison Duong
le 27 Sep 2019
Modifié(e) : John D'Errico
le 27 Sep 2019
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.
0 commentaires
Réponse acceptée
Star Strider
le 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.
0 commentaires
Plus de réponses (1)
John D'Errico
le 27 Sep 2019
Modifié(e) : John D'Errico
le 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Numbers and Precision dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!