Catherine Chen
Catherine Chen

Reputation: 13

How to let MATLAB return numeric value when solving high-order equations?

When I'm trying to solve the equation(since I don't have enough reputation so I can only post the latex code for the equation here)

\begin{equation}
\Comb{5}{1} P_s(1-P_s)^4+\Comb{5}{5} P_s^5\geq0.9
\end{equation}

(the equation looks more or less like:5*P*(1-P)^4+P^5=0.9)

by MATLAB,
I used the code:

clc;close all; clear all;
syms x
eqn=5*x*((1-x)^4)+x^5==0.9;
% solx=solve(eqn,x)
solve(eqn,x)

then MATLAB returned this:

ans =

 RootOf(z^5 - (10*z^4)/3 + 5*z^3 - (10*z^2)/3 + (5*z)/6 - 3/20, z)[1]
 RootOf(z^5 - (10*z^4)/3 + 5*z^3 - (10*z^2)/3 + (5*z)/6 - 3/20, z)[2]
 RootOf(z^5 - (10*z^4)/3 + 5*z^3 - (10*z^2)/3 + (5*z)/6 - 3/20, z)[3]
 RootOf(z^5 - (10*z^4)/3 + 5*z^3 - (10*z^2)/3 + (5*z)/6 - 3/20, z)[4]
 RootOf(z^5 - (10*z^4)/3 + 5*z^3 - (10*z^2)/3 + (5*z)/6 - 3/20, z)[5]

then I continue to try to get numeric value by this code:

clc;close all; clear all;
syms z
eqn=z^5 - (10*z^4)/3 + 5*z^3 - (10*z^2)/3 + (5*z)/6 - 3/20==0;
solve(eqn,z)

but MATLAB still returned this:

ans =

 RootOf(z1^5 - (10*z1^4)/3 + 5*z1^3 - (10*z1^2)/3 + (5*z1)/6 - 3/20, z1)[1]
 RootOf(z1^5 - (10*z1^4)/3 + 5*z1^3 - (10*z1^2)/3 + (5*z1)/6 - 3/20, z1)[2]
 RootOf(z1^5 - (10*z1^4)/3 + 5*z1^3 - (10*z1^2)/3 + (5*z1)/6 - 3/20, z1)[3]
 RootOf(z1^5 - (10*z1^4)/3 + 5*z1^3 - (10*z1^2)/3 + (5*z1)/6 - 3/20, z1)[4]
 RootOf(z1^5 - (10*z1^4)/3 + 5*z1^3 - (10*z1^2)/3 + (5*z1)/6 - 3/20, z1)[5]

Can someone please provide me some idea how to solve this problem or some link I should refer to? I referred to the link(http://www.mathworks.com/help/symbolic/solve.html#zmw57dd0e111578) on Mathwork but didn't help getting numerical values.

Please support Many thanks in advance.

Upvotes: 1

Views: 836

Answers (1)

scmg
scmg

Reputation: 1894

You have to use vpa for those RootOf to get the numerical approximation:

clc;close all; clear all;
syms x
eqn=5*x*((1-x)^4)+x^5==0.9;
% solx=solve(eqn,x)
sol = solve(eqn,x);
my_sol = vpa(sol)

Result:

>> mysol = vpa(sol)

mysol =

                                        0.9791481609736960010570740114736
 0.13006272993340436563484822895086 + 0.23845812045897270134074538059624i
   1.047029856246414300503281431979 + 0.99001796114505954590535961748791i
   1.047029856246414300503281431979 - 0.99001796114505954590535961748791i
 0.13006272993340436563484822895086 - 0.23845812045897270134074538059624i

Upvotes: 5

Related Questions