DADiSP Worksheet Functions > Function Categories > Polynomials > POLYROOT

 

POLYROOT

Purpose:

Finds the roots of a polynomial using the companion matrix.

Syntax:

POLYROOT(coef, form)

coef

-

A series, the polynomial coefficients.

form

-

Optional. An integer, the polynomial coefficient form:

0:

ascending powers, lowest degree to highest (default)

1:

descending powers, highest degree to lowest

Returns:

A real or complex series, the roots of the polynomial.

Example:

 

polyroot({0, -2, 1})

 

returns {0, 2}, the roots of -2x + x2

Example:

image\roots01.gif

 

r = polyroot({1, -1, -1}, 1)

 

r == {1.618034, -0.618034}

 

r[1] == phi

 

returns 1, demonstrating that for polynomial:

 

image\roots05.gif

i.e. positive root of x2 - x - 1 is PHI, the Golden Mean.

Example:

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)

 

image\polyrootpic.gif

 

W3 displays a cubic of the form:

 

image\roots03.gif

 

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.

 

image\polyrootpic2.gif

Remarks:

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:

 

image\polyr02.gif

 

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:

 

image\roots04.gif

 

where the coefficients are ordered from highest power to lowest power. This is the polynomial coefficient form expected by ROOTS.

See Also:

EIG

PFIT

POLY

POLYFIT

POLYGRAPH

POLYSTAB

POLYVAL

REPROOT

ROOTS