# Proposal for "Math_Polynomial"

» Description
A math package to represent and manipulate polynomials ( equations of the form ax^n + bx^(n - 1) + ... yx + z, or, for example: 5x^3 + 6x^2 + 4x + 2 )

The package includes a Polynomial class with these methods:
subtract()
multiply()
divide()
mod() - Modulus function ( division remainder ) for polynomials
degree() - Tell the degree ( highest exponent ) of the polynomial
getDerivative() - Get the nth derivative of a polynomial
evaluate() - Evaluate the polynomial for a given x value

Example of usage:
``` include "Polynomial.php"; print("\n-- Algebra --\n"); \$p = new Polynomial("3x^2 + 2x"); \$q = new Polynomial("4x + 1"); print("P is: " . \$p -> toString() . "\n"); print("Q is: " . \$q -> toString() . "\n"); \$p -> multiply(\$q); // Multiply p by q print("P multiplied by Q is: " . \$p -> toString() . "\n"); // Print string representation print("The degree of that result is: " . \$p -> degree() . "\n"); print("That result evaluated at x = 10 is: " . number_format(\$p -> evaluate(10)) . "\n"); \$r = new Polynomial(\$q); print("R is: " . \$r -> toString() . "\n"); \$p -> subtract(\$r); print("P minus R is: " . \$p -> toString() . "\n"); print("\n-- Derivatives --\n"); print("f(x) is: " . \$p -> toString() . "\n"); \$der1 = \$p -> getDerivative(); print("f'(x) is: " . \$der1 -> toString() . " (first derivative)\n"); \$der2 = \$p -> getDerivative(2); print("f''(x) is: " . \$der2 -> toString() . " (second derivative)\n"); ```

In the future, I may add support for multi-variable polynomials, where you have, for example, an x, y, and z variable in the equation. I'm also looking into algorithms to find the GCD of the polynomial, and polynomial factoring.

You can view code, examples, and the start of a unit test here: http://www.uglyslug.com/Math_Polynomial/