What is z1 appearing when solving this nonlinear system for x y and z?

36 views (last 30 days)
I'm trying to solve the following nonlinear system
g = 1;
b = 1;
a = b+1;
syms x y z
eqn1 = 0 == -x^2/g-2*a*x-y^2/g+2*b*y+1;
eqn2 = 0 == a*x-a*y-b*y+b*z-x*y/g-y*z/g;
eqn3 = 0 == -y^2/g+2*a*y-z^2/g-2*b*z+1;
[x,y,z] = solve([eqn1, eqn2, eqn3], [x, y, z])
When running the code I was expecting to get numeric solutions, but instead each one of them contain z1, which I think is linked to the variable z (maybe it has to do with real or complex parts?). If I write z1 in the command window and press Enter, the error "Unrecognized function or variable 'z1'." appears.
These are the solutions:
x =
(230*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1)^2)/361 + (100*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1)^3)/361 + (21*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1))/361 - 101/361
(230*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2)^2)/361 + (100*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2)^3)/361 + (21*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2))/361 - 101/361
(230*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3)^2)/361 + (100*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3)^3)/361 + (21*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3))/361 - 101/361
(230*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4)^2)/361 + (100*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4)^3)/361 + (21*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4))/361 - 101/361
y =
(42*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1)^2)/19 + (10*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1)^3)/19 + (4*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1))/19 - 31/19
(42*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2)^2)/19 + (10*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2)^3)/19 + (4*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2))/19 - 31/19
(42*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3)^2)/19 + (10*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3)^3)/19 + (4*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3))/19 - 31/19
(42*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4)^2)/19 + (10*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4)^3)/19 + (4*root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4))/19 - 31/19
z =
root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 1)
root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 2)
root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 3)
root(z1^4 + (32*z1^3)/5 + (241*z1^2)/25 - (103*z1)/25 - 739/100, z1, 4)
The code above corresponds to the following system:

Accepted Answer

Steven Lord
Steven Lord on 24 Mar 2020
Theoretically you could write out the roots of a quartic equation. There's a picture on the Wikipedia page for quartic function that shows the roots. The expressions in the picture are quite long, so Symbolic Math Toolbox doesn't put them in the solution. Instead it uses the root function to represent those roots. In order to write out the polynomials whose roots root represent, it needs to introduce a "temporary" variable. In this case that temporary variable is z1.
If you want to see the numeric solutions call double or vpa on the variables returned by solve.
  2 Comments
giannit
giannit on 24 Mar 2020
Thank you for the detailed explanation, both vpasolve (as suggested by Stijn Haenen) and solve+double or vpa work the same, the first case just requires a bit less code.
giannit
giannit on 24 Mar 2020
Consider the same nonlinear system as before but with unknown parameters a, b and g, moreover add conditions on the parameters (g>0, b>0, a>b)
syms x y z a b g
eq1 = 0 == -x^2/g-2*a*x-y^2/g+2*b*y+1;
eq2 = 0 == a*x-a*y-b*y+b*z-x*y/g-y*z/g;
eq3 = 0 == -y^2/g+2*a*y-z^2/g-2*b*z+1;
[x,y,z] = solve([eq1, eq2, eq3, g>0, b>0, a>b], [x, y, z])
Do you know why in this case the code provides empty solutions?
Warning: Unable to find explicit solution. For options, see
help.
> In solve (line 317)
In test (line 15)
x =
Empty sym: 0-by-1
y =
Empty sym: 0-by-1
z =
Empty sym: 0-by-1

Sign in to comment.

More Answers (1)

Stijn Haenen
Stijn Haenen on 24 Mar 2020
You can try to use the function vpasolve instead of solve

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!