Finding real roots of a cubic equation

조회 수: 23 (최근 30일)
robin johansson
robin johansson 2016년 12월 19일
댓글: Massimo Zanetti 2016년 12월 20일
I have the equation:
eqn = ((d^3*pi*((4251*d + 5951400)/(25*d))^(1/2))/(2*(d + 1400)))*(pi*(d^2)/4)-180 == 0
and want to find the real root/roots.
when i attempt to solve it with
x = vpasolve(eqn,d)
Matlab only return the imaginary part of the solution:
- 3.593452147062167996782934136112 - 1.3074862631155484137468498544529i
How do i find the real solution?

답변 (3개)

Roger Stafford
Roger Stafford 2016년 12월 20일
This is an equation that can be manipulated so that d is one of the roots of a ninth degree polynomial equation of which only one of its nine roots is real.
The original equation is:
((d^3*pi*((4251*d+5951400)/(25*d))^(1/2))/(2*(d+1400)))*(pi*(d^2)/4)==180
Since 4251*d+5951400 = 4251*(d+1400), the d+1400 partially cancels with the same quantity in the denominator and we get the equation
pi^2/40*d^5*(4251/(d*(d+1400)))^(1/2)==180
or
pi^2/40*d^5*4251^(1/2) == 180*(d*(d+1400))^(1/2)
Squaring both sides and transposing gives
4251/1600*pi^4*d^10-32400*d^2-45360000*d == 0
One factor d can be factored out since d = 0 is clearly not a solution of the original equation and that finally leaves the polynomial equation
4251/1600*pi^4*d^9-32400*d-45360000 == 0
The ‘roots’ function can be used for this and it shows that there is only one real root, namely
d = 3.82617917662798

Massimo Zanetti
Massimo Zanetti 2016년 12월 19일
편집: Massimo Zanetti 2016년 12월 19일
To force the vpasolve finding only real solutions you cannot use assume. If you know the real solution is only one a workaround is to set search range to [-Inf,Inf]:
x = vpasolve(eqn,d,[-Inf,Inf])
x =
3.8261791766279723703687735908663
By the way, I suggest you to read documentation to get more insights: vpasolve
  댓글 수: 2
robin johansson
robin johansson 2016년 12월 19일
편집: robin johansson 2016년 12월 19일
Thank you for the answer! Just what i was looking for.
With this problem i did know that i only had 1 real solution. I've read the documentation and i still don't understand how i would go about if i didn't know how many real solutions i could find.
My idea of how to get around this would be
X = vpasolve(eqn,x,[-inf, inf],'random',true)
Y = vpasolve(eqn,x,[X, inf],'random',true)
Z = vpasolve(eqn,x,[-inf, X],'random',true)
etc.
Not sure if this works, could you suggest a smarter solution to finding all real values of a nonpolynomial equation?
Massimo Zanetti
Massimo Zanetti 2016년 12월 20일
For non polynomial equations there is no general rule to find all solutions. Consider using solve function. The documentation is rich of useful examples that cover many potential applications.

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


Walter Roberson
Walter Roberson 2016년 12월 19일
One approach for polynomials is to use solve instead of vpasolve, to get all of the solutions, and then to use logical indexing to select the results whose imag()==0
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 12월 20일
sols = solve(eqn, x);
sols(imag(sols)~=0) = []; %remove the ones that have a non-zero imaginary component.
However, in R2016b (and perhaps some other releases), this code can fail due to a bug in the Symbolic Toolbox (I notified them of the bug a few weeks ago.) The work-around for the moment is
sols(imag(vpa(sols))~=0) = [];

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by