Class: Math_PolynomialOp
Source Location: /Math_Polynomial-0.1.0/PolynomialOp.php
Class for operations on Math_Polynomial objects
Author(s):
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
add [line 135]
object &add(
mixed
$p1, mixed
$p2)
|
|
Add two Polynomials together and return the result $p = new Polynomial("x + 2");
$res = PolynomialOp::add("x + 3", $p);
print($res->toString()); // Prints 2x + 5 ( sum of the two )
Parameters:
create [line 113]
object create(
string
$str)
|
|
Create a Polynomial object from a string/integer/float
Parameters:
createFromRoots [line 387]
object &createFromRoots(
array
$arr)
|
|
Create a Polynomial object which has roots (zeros) provided as parameters The roots can be passed in as either a variable length parameter list or a single array of float values.
Parameters:
createFunction [line 866]
string createFunction(
object
$p)
|
|
Create a lambda-style anonymous function from the Polynomial Creates an anonymous function representing the Polynomial which takes one parameter, an x value to evaluate at, and returns a unique name for the function.
Parameters:
createSecantFunction [line 1055]
string createSecantFunction(
object
$p, float
$x1, float
$x2)
|
|
Create a lambda-style function representing the secant line through two points
Parameters:
createTangentFunction [line 1008]
string createTangentFunction(
object
$p, float
$x)
|
|
Create a lambda-style function representing the tangent line at a point
Parameters:
div [line 260]
object &div(
object
$p1, object
$p2, [object
$rem = null])
|
|
Divide one Polynomial by another, returning the result Divide the first polynomial by another polynomial object or a string represention of another polynomial. Optionally, you can pass another Polynomial object by reference to store the remainder of the division operator. $a = new Polynomial("4x^2 + 2x");
$b = new Polynomial("2x");
$remainder = new Polynomial();
$result = PolynomialOp::div($a, $b, $remainder);
print("A divided by B is: " . $result->toString() . " with a remainder of " . $remainder->toString() . "\n");
Parameters:
equals [line 757]
bool equals(
object
$p1, object
$p2)
|
|
Tell whether or not two Polynomials/string representations are equal
Parameters:
evaluate [line 359]
float evaluate(
$p, float
$x, object
$m1)
|
|
Evaluate the polynomial for a given x value
Parameters:
getAntiDerivative [line 1295]
void &getAntiDerivative(
object
$p, [integer
$n = 1], [integer
$c = 0])
|
|
Get the nth anti-derivative of a Math_Polynomial Returns the nth anti-derivative of the Polynomial. An optional constant can be passed in to have that appended as the x^0 term.
Parameters:
getCriticalPoints [line 843]
array getCriticalPoints(
object
$p)
|
|
Calculate and return an array of critical points for the Polynomial Critical points of a Polynomial are where something 'important' happens in the Polynomial (inflection point, maximum, minumum, etc.)
Parameters:
getDerivative [line 1349]
object A &getDerivative(
object
$p, [
$n = 1], integer
$der_num)
|
|
Get the nth derivative of a Math_Polynomial Returns the nth derivative of the Polynomial. Derivatives are commonly used in calculus as they represent slopes or acceleration. To get the first derivative, the second parameter should be a 1. For the second derivative parameter should be a two, etc. etc.
Parameters:
getEndBehavior [line 1251]
array getEndBehavior(
object
$p)
|
|
Get the end behavior of a Polynomial The end behaviors are determined by the degree of the Polynomial and whether or not the coefficient is positive or negative. The values returned correspond to the MATH_POLYNOMIAL_QUADRANT_* constants for the cartesian coordinate system: Quad 2 | Quad 1
---------------
Quad 3 | Quad 4 Returns an array containing two elements:
// prints:
Array
(
[0] => MATH_POLYNOMAIL_QUADRANT_2 // This is the left-end behavior
)
Parameters:
getLocalMaximums [line 904]
array getLocalMaximums(
object
$p, [float
$x_min = null], [float
$x_max = null])
|
|
Find and return an array of the local maximums of the Polynomial By default the function returns all local maximums for the Polynomial. If you want just maximums on an interval, pass in the $x_min and $x_max parameters.
Parameters:
getLocalMinimums [line 945]
array getLocalMinimums(
object
$p, [float
$x_min = null], [float
$x_max = null])
|
|
Find and return an array of the minimums of the Polynomial By default the method returns all minimums, if you want the minimums within an interval, pass in the $x_min and $x_max parameters.
Parameters:
getRoots [line 438]
array getRoots(
object
$p, [array
$guesses = array()])
|
|
Get the roots of this Polynomial For Polynomials of degree less than or equal to 4, the exact value of any real roots (zeros) of the Polynomial are returned. For Polynomials of higher degrees, the roots are estimated using the Newton-Raphson method from the Math_Numerical_RootFinding package. Remember that these roots are *estimates* and for high-degree polynomials all of the roots may not be calculated and returned! If you're calculating roots for a higher-degree Polynomial and want to provide the initial guesses for the roots, you can pass them in as an array parameter. If possible, this function will return integers instead of floats.
Parameters:
getRootsCubic [line 573]
array getRootsCubic(
$p, object
$m)
|
|
Find and return the real roots of a cubic Polynomial using the cubic formula
Parameters:
getRootsHighDegree [line 790]
array getRootsHighDegree(
$p, [array
$guesses = array()], object
$m)
|
|
Estimate and return the roots of a high-degree Polynomial ( degree 5 or greater ) This function uses Newton's method using the Math_Numerical_RootFinding PEAR package to estimate the real roots of high-degree Polynomials. If you already have estimates of where the roots might be, you can pass in an array of guesses. Otherwise, the method will try to calculate some good initial guesses for you. You must have the Math_Numerical_RootFinding package installed for this method to work!
Parameters:
getRootsLinear [line 492]
array getRootsLinear(
$p, object
$m)
|
|
Get the roots of a linear Polynomial
Parameters:
getRootsQuadratic [line 528]
array getRootsQuadratic(
$p, object
$m)
|
|
Get the roots of a quadratic Polynomial (using the Quadratic Formula)
Parameters:
getRootsQuartic [line 652]
array getRootsQuartic(
object
$p)
|
|
Find and return the roots of a Quartic Polynomial (degree 4) with the Quartic formula
Parameters:
getSecantAt [line 1029]
object getSecantAt(
object
$p, float
$x1, float
$x2)
|
|
Get a Math_Polynomial object representing the secant line through two points on the given Polynomial
Parameters:
getSecantSlopeAt [line 1118]
float getSecantSlopeAt(
object
$p, float
$x1, float
$x2)
|
|
Get the slope of a secant to the Polynomial passing through points x1 and x2
Parameters:
getSlopeAt [line 1087]
float getSlopeAt(
object
$p, float
$x)
|
|
Get the slope of the Polynomial at a given x value
Parameters:
getTangentAt [line 982]
object getTangentAt(
object
$p, float
$x)
|
|
Get a Polynomial object representing a tangent to the given Polynomial at the given point
Parameters:
getTangentSlopeAt [line 1101]
isConstant [line 1409]
bool isConstant(
object
$p)
|
|
Tell whether or not a Polynomial is constant (degree 0)
Parameters:
isEven [line 1139]
bool isEven(
mixed
$p, [integer
$num_test_points = 10])
|
|
Test if a Math_Polynomial object is an even function (i.e.: f(-x) == f(x) for all x)
Parameters:
isMath_Polynomial [line 743]
bool isMath_Polynomial(
object
$p)
|
|
Tell whether or not an object is a Polynomial or not
Parameters:
isOdd [line 1166]
bool isOdd(
mixed
$p, [integer
$num_test_points = 10])
|
|
Test if a Math_Polynomial object is an odd function (i.e.: f(-x) == -f(x) for all x)
Parameters:
isZero [line 1383]
Tells whether or not the Polynomial is equivalent to zero
Parameters:
mod [line 342]
object &mod(
object
$p1, object
$p2)
|
|
Calculate the mod (%) $p1 of $p2 and return the result as a Polynomial print('p1 % p2 is: ');
print($mod->toString());
Parameters:
mul [line 204]
object &mul(
$p1,
$p2, object
$m1, object
$m2)
|
|
Multiply two Polynomials together The parameters may be either a Polynomial object or a string representation of a polynomial.
Parameters:
sub [line 171]
object &sub(
mixed
$p1, mixed
$p2)
|
|
Subtract one Polynomial from another Polynomial
Parameters:
_round [line 467]
mixed _round(
mixed
$mixed)
|
|
Round an array of integers or single integer if its within the round boundary
Parameters:
Documentation generated on Mon, 11 Mar 2019 14:38:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|