How to solve function

Hi,
I am trying to solve the fuction according to x1:
syms x1 x2
Eq2 = (1*(-0.0296505547))+(x1*(-1.4168313955))+(x2*(-0.4039704255))+(x1^2*(-0.0746402042))+((x2^2)*(-1.6203228042))+(x1^3*0.0000356471)+(x2^3*0.0400047846)+(x1*x2*0.7706539390)+((x1^2)*x2*0.0015188307)+(x1*(x2^2)*(-0.0173642989))==-log(1/0.4 - 1);
t_sol1 = solve(Eq2, x1)
The answer i get is this:
t_sol1 =
root(z^3 + (73786976294838206464*z^2*((3502185151774141*x2)/2305843009213693952 - 1344598383287911/18014398509481984))/2630291722679727 - (73786976294838206464*z*(- (3470716792512005*x2)/4503599627370496 + (2502459201778877*x2^2)/144115188075855872 + 1595210336205155/1125899906842624))/2630291722679727 + (2951832092960308736*x2^3)/2630291722679727 - (119558720343491166208*x2^2)/2630291722679727 - (9935918736728068096*x2)/876763907559909 + 9243406514527810816/876763907559909, z, 1)
root(z^3 + (73786976294838206464*z^2*((3502185151774141*x2)/2305843009213693952 - 1344598383287911/18014398509481984))/2630291722679727 - (73786976294838206464*z*(- (3470716792512005*x2)/4503599627370496 + (2502459201778877*x2^2)/144115188075855872 + 1595210336205155/1125899906842624))/2630291722679727 + (2951832092960308736*x2^3)/2630291722679727 - (119558720343491166208*x2^2)/2630291722679727 - (9935918736728068096*x2)/876763907559909 + 9243406514527810816/876763907559909, z, 2)
root(z^3 + (73786976294838206464*z^2*((3502185151774141*x2)/2305843009213693952 - 1344598383287911/18014398509481984))/2630291722679727 - (73786976294838206464*z*(- (3470716792512005*x2)/4503599627370496 + (2502459201778877*x2^2)/144115188075855872 + 1595210336205155/1125899906842624))/2630291722679727 + (2951832092960308736*x2^3)/2630291722679727 - (119558720343491166208*x2^2)/2630291722679727 - (9935918736728068096*x2)/876763907559909 + 9243406514527810816/876763907559909, z, 3)
Could You explain why the z occurs in solved function?

Answers (3)

Ameer Hamza
Ameer Hamza on 18 Mar 2020
Edited: Ameer Hamza on 18 Mar 2020
The solution given by MATLAB shows that for a given value of x2, x1 has 3 solutions. However, MATLAB is not able to express those solutions analytically; therefore, it gave the output in terms of another function root(). If you look carefully, you can see that the polynomials in three solutions are the same, only the last number is different, indicating which root will be output by root() function. See: https://www.mathworks.com/help/symbolic/sym.root.html. To get a numeric answer for a specific value of x2, try
syms x1 x2
Eq2 = (1*(-0.0296505547))+(x1*(-1.4168313955))+(x2*(-0.4039704255))+(x1^2*(-0.0746402042))+((x2^2)*(-1.6203228042))+(x1^3*0.0000356471)+(x2^3*0.0400047846)+(x1*x2*0.7706539390)+((x1^2)*x2*0.0015188307)+(x1*(x2^2)*(-0.0173642989))==-log(1/0.4 - 1);
x2_val = 1;
double(subs(t_sol1, x2, x2_val))

2 Comments

If you want the results in a symbolic floating point form, then use vpa instead of double. Of course, since the coefficients in the original equation were only provided with 10 significant digits, then computing an answer that is accurate to 40 digits is arguably a bit silly. :)
MATLAB is able to express the solution analytically: it is just abbreviating it.

Sign in to comment.

Ruta Dranginyte
Ruta Dranginyte on 21 Mar 2020

0 votes

Thank You guys for the help :)
Change
t_sol1 = solve(Eq2, x1)
To
t_sol1 = solve(Eq2, x1, 'MaxDegree', 3)
To get the solutions.
They will be long and difficult to read, but they will be the solutions.
MATLAB knows that the exact solutions to degree 3 and 4 are very long, and automatically abbreviates them into the root() form.

Asked:

on 18 Mar 2020

Commented:

on 21 Mar 2020

Community Treasure Hunt

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

Start Hunting!