# /home/jaubrey/webwork//pg_TRUNK/macros/PGpolynomialmacros.pl

### From WeBWorK

- PGpolynomialmacros.pl DESCRIPTION
`ValidPoly(@PolynomialCoeffs)`

`PolyAdd(@Polyn1,@Polyn2)`

`PolySub(@Polyn1,@Polyn2)`

`PolyMult(~~@coefficientArray1,~~@coefficientArray2)`

- (@quotient,$remainder) =
`SynDiv(~~@dividend,~~@divisor)`

- (@quotient,@remainder) =
`LongDiv($dividendref,$divisorref)`

`UpBound(~~@polynomial)`

`LowBound(~~@polynomial)`

`PolyString(~~@coefficientArray,x)`

- ($maxpos,$maxneg) =
`Descartes(~~@poly)`

# PGpolynomialmacros.pl DESCRIPTION

########################################################## # It contains rountines used to create and manipulate ## # polynomials for WeBWorK ## # ## # Copyright 2002 Mark Schmitt ## # Version 1.1.2 ## ##########################################################

# In the current version, there is no attempt to verify that correct arrays are being passed to the routines. # This ought to be changed in the next incarnation. # It is assumed that arrays passed to the routines have no leading zeros, and represent the coefficients of # a polynomial written in standard form using place-holding zeros. # This means $array[0] is the leading coefficient of the polynomial and $array[$#array] is the constant term. # # The routines were written based on the needs of my Honors Algebra 2 course. The following algorithms have been # coded: # Polynomial Multiplication # Polynomial Long Division # Polynomial Synthetic Division (mainly as a support routine for checking bounds on roots) # Finding the least positive integral upper bounds for roots # Finding the greatest negative integral lower bounds for roots # Descartes' Rule of Signs for the maximum number of positive and negative roots # Stringification : converting an array of coefficients into a properly formatted polynomial string # Polynomial Addition # Polynomial Subtraction

`ValidPoly(@PolynomialCoeffs)`

`PolyAdd(@Polyn1,@Polyn2)`

# # Takes two arrays of polynomial coefficients representing # two polynomials and returns their sum. #

`PolySub(@Polyn1,@Polyn2)`

# # Takes two arrays of polynomial coefficients representing # two polynomials and returns their difference. #

`PolyMult(~~@coefficientArray1,~~@coefficientArray2)`

# # Accepts two arrays containing coefficients in descending order # returns an array with the coefficients of the product #

### (@quotient,$remainder) = `SynDiv(~~@dividend,~~@divisor)`

# # Performs synthetic division on two polynomials returning # the quotient and remainder in an array. #

### (@quotient,@remainder) = `LongDiv($dividendref,$divisorref)`

# # Performs long division on two polynomials # returning the quotient and remainder #

`UpBound(~~@polynomial)`

# # Accepts a reference to an array containing the coefficients, in descending # order, of a polynomial. # # Returns the lowest positive integral upper bound to the roots of the # polynomial. #

`LowBound(~~@polynomial)`

# # Accepts a reference to an array containing the coefficients, in descending # order, of a polynomial. # # Returns the greatest negative integral lower bound to the roots of the # polynomial #

`PolyString(~~@coefficientArray,x)`

# # Accepts an array containing the coefficients of a polynomial # in descending order # Returns a sting containing the polynomial with variable x # Default variable is x #

### ($maxpos,$maxneg) = `Descartes(~~@poly)`

# # Accepts an array containing the coefficients, in descending order, of a # polynomial # Returns the maximum number of positive and negative roots according to # Descartes Rule of Signs # # IMPORTANT NOTE: this function currently does not accept coefficients of # zero. #