DADiSP Worksheet Functions > Function Categories > Polynomials > POLYROOT
Finds the roots of a polynomial using the companion matrix.
POLYROOT(coef, form)
coef |
- |
A series, the polynomial coefficients. |
||||
form |
- |
Optional. An integer, the polynomial coefficient form:
|
A real or complex series, the roots of the polynomial.
polyroot({0, -2, 1})
returns {0, 2}, the roots of -2x + x2
r = polyroot({1, -1, -1}, 1)
r == {1.618034, -0.618034}
r[1] == phi
returns 1, demonstrating that for polynomial:
i.e. positive root of
a := rand
x = -10..0.01..10
W1: polyroot({a, 1, -1, -1}, 1)
W2: xy(W1, zeros(length(W1),1));points;setsym(14)
W3: a*x^3 + x^2 - x - 1;overp(W2, lred)
W3 displays a cubic of the form:
The roots of the cubic are overplotted in red and displayed as solid circles.
Executing the statement a := rand creates a new polynomial that is automatically updated in W3. A zoomed portion of the graph below shows the cubic nature of the location of the roots.
POLYROOT calculates the roots of a polynomial by finding the eigenvalues of the companion matrix for the corresponding characteristic polynomial. See ROOTS to calculate the polynomial roots using other algorithms.
polyroot(a) or polyroot(a, 0) finds the roots of:
this is the same form as POLYFIT and POLYGRAPH, where the polynomial coefficients are ordered from lowest power to highest power.
polyroot(a, 1) finds the roots of:
where the coefficients are ordered from highest power to lowest power. This is the polynomial coefficient form expected by ROOTS.