How to solve function

조회 수: 6 (최근 30일)
Ruta Dranginyte
Ruta Dranginyte 2020년 3월 18일
댓글: Walter Roberson 2020년 3월 21일
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?

답변 (3개)

Ameer Hamza
Ameer Hamza 2020년 3월 18일
편집: Ameer Hamza 2020년 3월 18일
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
John D'Errico
John D'Errico 2020년 3월 18일
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. :)
Walter Roberson
Walter Roberson 2020년 3월 21일
MATLAB is able to express the solution analytically: it is just abbreviating it.

댓글을 달려면 로그인하십시오.


Ruta Dranginyte
Ruta Dranginyte 2020년 3월 21일
Thank You guys for the help :)

Walter Roberson
Walter Roberson 2020년 3월 21일
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.

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by