Analytically finding the roots of polynomials with symbolic variables

16 views (last 30 days)
I am trying to solve a cubic equation with symbolic variables, but Matlab is not able to find an analytical solution.
syms a len
solve((35*len*a)/2 - 6125 == ((2*a - 35)^2*(60*a + 4200))/840, a)
ans =
root(z^3 + 35*z^2 - (7*z*((35*len)/2 + 1225/2))/2 + 42875, z, 1)
root(z^3 + 35*z^2 - (7*z*((35*len)/2 + 1225/2))/2 + 42875, z, 2)
root(z^3 + 35*z^2 - (7*z*((35*len)/2 + 1225/2))/2 + 42875, z, 3)
Can equations such as this be solved analytically in Matlab?

Accepted Answer

James Tursa
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 len
p = (35*len*a)/2 - 6125 - ((2*a - 35)^2*(60*a + 4200))/840
solve(p,a,'MaxDegree',3)
which gives
ans =
((245*len)/12 + 30625/36)/((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3) + ((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3) - 35/3
- ((245*len)/12 + 30625/36)/(2*((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3)) - (3^(1/2)*(((245*len)/12 + 30625/36)/((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3) - ((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3))*1i)/2 - ((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3)/2 - 35/3
- ((245*len)/12 + 30625/36)/(2*((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3)) + (3^(1/2)*(((245*len)/12 + 30625/36)/((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3) - ((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3))*1i)/2 - ((((8575*len)/24 + 7674625/216)^2 - ((245*len)/12 + 30625/36)^3)^(1/2) - (8575*len)/24 - 7674625/216)^(1/3)/2 - 35/3

More Answers (0)

Community Treasure Hunt

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

Start Hunting!