Cannot find ALL solutions to simultaneous equation

Hi everyone, I would like to find ALL the solutions to this series of equations. Here is my code.
My problem is that it prompts me to use vpasolve, which doesn't give ALL the solutions. I tried "ReturnCondition", but to no avail.
My code is here:
clear all
syms x y z
eq1 = exp(x^2 + y^2 + z^2) == 9;
eq2 = x + x*y - z == 1;
eq3 = x + y + z == 1;
[solx,soly,solz] = solve([eq1,eq2,eq3],[x y z])

 採用された回答

David Goodmanson
David Goodmanson 2020 年 1 月 8 日

0 投票

Hi CZ
If
exp(x^2+y^2+z^2) = 9
then
x^2+y^2+z^2 = log(9)
which is a lot less challenging for symbolic evaluation.
clear all
syms x y z C
eq1 = x^2 + y^2 + z^2 == C;
eq2 = x + x*y - z == 1;
eq3 = x + y + z == 1;
[solx,soly,solz] = solve([eq1,eq2,eq3],[x y z])
solz =
root(z1^4 - 5*z1^3 - z1^2*(C - 7) + z1*((5*C)/2 - 1/2) - C/2 + C^2/4 + 1/4, z1, 1)
root(z1^4 - 5*z1^3 - z1^2*(C - 7) + z1*((5*C)/2 - 1/2) - C/2 + C^2/4 + 1/4, z1, 2)
root(z1^4 - 5*z1^3 - z1^2*(C - 7) + z1*((5*C)/2 - 1/2) - C/2 + C^2/4 + 1/4, z1, 3)
root(z1^4 - 5*z1^3 - z1^2*(C - 7) + z1*((5*C)/2 - 1/2) - C/2 + C^2/4 + 1/4, z1, 4)
There are expressions that are twice as long for x and y. You can get numerical results by plugging in log(9) for C and using the roots function to get four solutions. I wish I knew how to get the coefficients in solx, soly and solz into the roots function in a convenient way, but I don't.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 1 月 8 日

0 投票

Ookkay... The 55 kilobyte solution is attached.
Now what are you going to do with it?

5 件のコメント

Xinzhe Chai
Xinzhe Chai 2020 年 1 月 8 日
Hi there! Thank you for answering me the question! However, can you teach me how did you get all the answers? What script did you change? Thanks a lot!
Walter Roberson
Walter Roberson 2020 年 1 月 8 日
I used Maple,
[allvalues](solve([exp(x^2 + y^2 + z^2) = 9, x*y + x - z = 1, x + y + z = 1]))
and then a fair bit of hand-editing to get the values into a form that could be loaded into MATLAB.
Xinzhe Chai
Xinzhe Chai 2020 年 1 月 8 日
Thanks a lot! However, it would be so kind if you could advise me how to change my code in MATLAB? Its kind of an assignment for my MATLAB class. I don't understand why cant MATLAB solve this simultaneous equation?
I will accept this answer as soon as you give me some suggestion on the MATLAB code change! Thanks a lot!
Walter Roberson
Walter Roberson 2020 年 1 月 8 日
solve eq2 for x (in terms of y and z) . Substitute that x into eq3 and solve for z. substitute for x and then z into eq1, and solve for y asking solve for MaxDegree 4. The result will be four exact roots for y. simplify(). Now do back substitution.
Xinzhe Chai
Xinzhe Chai 2020 年 1 月 8 日
Thanks!

サインインしてコメントする。

カテゴリ

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by