Macro Library polys

Polynomial functions. Version 1.1, Nov 11, 2007

formpoly

formpoly(coefficients,powers or degree)
Creates a polynomial object
Use writepoly to create a display form of the polynomial
coefficients: list/array of coefficients
powers or degree: list/array of powers, or highest degree
highest degree assumes coefficients correspond to consecutively
decreasing powers

formpolyfromroots

formpolyfromroots(stretch,roots,[multiplicities])
create a polynomial object from roots
use writepoly to create a display form of the polynomial
stretch: a stretch factor; the A in A*(x-root)(x-root)...
roots: an array of the roots (zeros, x-intercepts) of the polynomial. For a complex root pair a+-bi give a single array [a,b] as the root.
multiplicites (optional): an array of multiplicites of the roots. Assumed to
be all 1 if not provided

writepoly

writepoly(poly,[var,showzeros])
Creates a display form for polynomial object
poly: polynomial object, created with formpoly
var: input variable. Defaults to x
showzeros: optional, defaults to false. If true, shows zero coefficients

addpolys

addpolys(poly1,poly2)
Adds polynomials, arranging terms from highest to lowest powers

subtpolys

subtpolys(poly1,poly2)
Subtracts polynomials: poly1-poly2, arranging terms from highest to lowest powers

multpolys

multpolys(poly1,poly2)
Multiplies polynomials

scalepoly

scalepoly(poly,c)
Multiplies each term of poly by constant c

derivepoly

derivepoly(poly)
Computes the derivative of poly

polypower

polypower(poly,power)
Calculates poly^power

quadroot

quadroot(a,b,c)
Quadratic equation, solving ax^2+bx+c = 0
Return an array of the two solutions, ordered smaller then larger
if no solution exists, an array of "DNE" strings is returned

getcoef

getcoef(poly,degree)
Gets the coefficient corresponding to the degree specified
if no such term is defined, 0 is returned (since that is the coefficient!)
poly: polynomial object, created with formpoly
degree: degree of term to get coefficient of