root() function gives compelx solution for cubic equation. how to get the nearby real root?
Ältere Kommentare anzeigen
Dear All:
i have a cubic equation and the coefficients are set already. But it always gives me the complex roots (all of them).
As i know, root() function of the matlab (in practice and theory) gives the very approximate roots for any polynomial that has more than quadratic.
So, is there anyway i can force the root to give me the most possible real roots?.
Thanks.
5 Kommentare
John D'Errico
am 25 Jun. 2020
As you THINK you know, but maybe you are wrong in what you think.
You cannot force roots to give you a real root where one does not exist. There is no magical flag you can set to change that behavior for roots.
For example, consider the equation:
p(x) = x^3 - x^2 - x - 1/5
This has one real root. Wanting it to have more than that is a good dream, but just a dream.
roots([1 -1 -1 -1/5])
ans =
1.670356741159 + 0i
-0.335178370579499 + 0.0859672116099084i
-0.335178370579499 - 0.0859672116099084i
Yes, Suppose we purturb this cubic by a small amount, changing the constant term from -1/5 to -5/27.
roots([1 -1 -1 -5/27])
ans =
1.66666666666667 + 0i
-0.333333333333333 + 6.59783539196707e-09i
-0.333333333333333 - 6.59783539196707e-09i
Which suggests the roots you might think are the ones you want to see, are: [5/3, -1/3, -1/3]. But for that to be true, I had to make a perhaps significant modification to the polynomial.
Perhaps a better question is what is the minimum norm perturbation to the coefficients of that polynomial that yields all real roots, and for that perturbation, what would be the roots? Of course, for that we would need to define what we mean by a minimal perturbation.
mirewuti muhetaer
am 25 Jun. 2020
Walter Roberson
am 25 Jun. 2020
As i know, root() function of the matlab (in practice and theory) gives the very approximate roots for any polynomial that has more than quadratic.
Could you give us an example of a polynomial you consider root() or roots() to be insufficiently accurate for? Situations where more accurate numeric roots are possible, rather than situations where you have reached the limits of double precision ?
In the test I just did, the largest error I found during the test was 50 ϵ on polynomials up to degree 49, when comparing the numeric roots against those found by symbolic means.
I did find one where back-substituting one of the roots gave a value on the order of 4e+32, but that was primarily due to double precision limitations; the best possible double precision root at that location was one bit different, on the order of 9e+31
mirewuti muhetaer
am 25 Jun. 2020
Walter Roberson
am 25 Jun. 2020
The roots function considers p to be a vector with n+1 elements representing the nth degree characteristic polynomial of an n-by-n matrix, A. The roots of the polynomial are calculated by computing the eigenvalues of the companion matrix, A.
Not Newton's method.
Antworten (0)
Kategorien
Mehr zu Polynomials finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!