Matlab unable to find solution to cubic polynomial
1 view (last 30 days)
Show older comments
The following cubic equation has three roots.
syms a
solve((1225*a)/2 - 6125 == ((2*a - 35)^2*(60*a + 4200))/840, a)
Matlab's output is:
root(z^3 + 35*z^2 - (8575*z)/2 + 42875, z, 1)
root(z^3 + 35*z^2 - (8575*z)/2 + 42875, z, 2)
root(z^3 + 35*z^2 - (8575*z)/2 + 42875, z, 3)
Can cubic equations like this be solved analytically in Matlab?
0 Comments
Accepted Answer
James Tursa
on 1 Feb 2021
Edited: James Tursa
on 1 Feb 2021
Tell the solve( ) function that the max degree of the polynomial is 3 to force explicit solutions for the result:
syms a
p = (1225*a)/2 - 6125 - ((2*a - 35)^2*(60*a + 4200))/840
solve(p,a,'MaxDegree',3)
which gives
ans =
28175/(18*(- 5187875/108 + (432^(1/2)*659937359375^(1/2)*1i)/432)^(1/3)) + ((432^(1/2)*659937359375^(1/2)*1i)/432 - 5187875/108)^(1/3) - 35/3
- 28175/(36*(- 5187875/108 + (432^(1/2)*659937359375^(1/2)*1i)/432)^(1/3)) - ((432^(1/2)*659937359375^(1/2)*1i)/432 - 5187875/108)^(1/3)/2 - (3^(1/2)*(28175/(18*(- 5187875/108 + (432^(1/2)*659937359375^(1/2)*1i)/432)^(1/3)) - ((432^(1/2)*659937359375^(1/2)*1i)/432 - 5187875/108)^(1/3))*1i)/2 - 35/3
- 28175/(36*(- 5187875/108 + (432^(1/2)*659937359375^(1/2)*1i)/432)^(1/3)) - ((432^(1/2)*659937359375^(1/2)*1i)/432 - 5187875/108)^(1/3)/2 + (3^(1/2)*(28175/(18*(- 5187875/108 + (432^(1/2)*659937359375^(1/2)*1i)/432)^(1/3)) - ((432^(1/2)*659937359375^(1/2)*1i)/432 - 5187875/108)^(1/3))*1i)/2 - 35/3
Then you can also note
>> simplify(ans)
ans =
(35*2^(1/3)*(- 121 - 1077^(1/2)*3i)^(1/3))/6 + (35*2^(1/3)*(- 121 + 1077^(1/2)*3i)^(1/3))/6 - 35/3
- (35*2^(1/3)*(- 121 + 1077^(1/2)*3i)^(1/3))/12 - (35*2^(1/3)*(1 + 3^(1/2)*1i)*(- 121 - 1077^(1/2)*3i)^(1/3))/12 + (2^(1/3)*3^(1/2)*(- 121 + 1077^(1/2)*3i)^(1/3)*35i)/12 - 35/3
- (35*2^(1/3)*(- 121 + 1077^(1/2)*3i)^(1/3))/12 + (35*2^(1/3)*(- 1 + 3^(1/2)*1i)*(- 121 - 1077^(1/2)*3i)^(1/3))/12 - (2^(1/3)*3^(1/2)*(- 121 + 1077^(1/2)*3i)^(1/3)*35i)/12 - 35/3
>> imag(ans)
ans =
0
0
0
So you can pick off the real part for the answer.
0 Comments
More Answers (0)
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!