Finding roots of a polynomial
2 views (last 30 days)
Show older comments
I've carried out manual calculations of newton raphson and have proven it in MATLAB with the following code in the command window:
>> f= 0.5*x.^3 + x.^2 - 10*x+14.037;
>> roots ([0.5 1 -10 14.037])
ans =
-6.0627 + 0.0000i
2.0313 + 0.7101i
2.0313 - 0.7101i
I know the -6.0627 is correct as this is the same as my manual calculation, but I don't understand the following 2 answers MATLAB has provided. Could someone explain this in reasonably simple terms what they mean?
Thanks.
0 Comments
Accepted Answer
James Tursa
on 10 Nov 2016
Edited: James Tursa
on 10 Nov 2016
An n'th order polynomial will have n roots, some of which may be repeated or complex. You have a 3rd order polynomial which will have 3 roots. Turns out one of the roots is real and the other two are complex (meaning a plot of the polynomial will only cross the x-axis once). If you plug the roots into the polynomial you can see that all three results are very close to zero as expected:
>> f = @(x) 0.5*x.^3 + x.^2 - 10*x + 14.037
f =
@(x)0.5*x.^3+x.^2-10*x+14.037
>> r = roots ([0.5 1 -10 14.037])
r =
-6.062670505918885
2.031335252959442 + 0.710147689980882i
2.031335252959442 - 0.710147689980882i
>> f(r)
ans =
1.0e-013 *
0.230926389122033
0.035527136788005 - 0.062172489379009i
0.035527136788005 + 0.062172489379009i
Look at it this way, if you take your real root and form (x+6.062670505918885) and factor that out of your polynomial, you will be left with a 2nd order polynomial that has no real roots.
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!