Class: Math_PolynomialOp
Source Location: /Math_Polynomial-0.0.2/PolynomialOp.php
Class for operations on Math_Polynomial objects
Author(s):
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
add [line 115]
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 93]
object create(
string
$str)
|
|
Create a Polynomial object from a string/integer/float
Parameters:
createFromRoots [line 367]
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 846]
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:
createTangentFunction [line 987]
string createTangentFunction(
object
$p, float
$x)
|
|
Create a lambda-style function representing the tangent line at a point
Parameters:
div [line 240]
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 737]
bool equals(
object
$p1, object
$p2)
|
|
Tell whether or not two Polynomials/string representations are equal
Parameters:
evaluate [line 339]
float evaluate(
$p, float
$x, object
$m1)
|
|
Evaluate the polynomial for a given x value
Parameters:
getCriticalPoints [line 823]
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 1082]
object A &getDerivative(
object
$p, [
$n = 1], integer
$der_num)
|
|
Get the nth derivative of the 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:
getLocalMaximums [line 884]
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 925]
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 418]
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 553]
array getRootsCubic(
$p, object
$m)
|
|
Find and return the real roots of a cubic Polynomial using the cubic formula
Parameters:
getRootsHighDegree [line 770]
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 472]
array getRootsLinear(
$p, object
$m)
|
|
Get the roots of a linear Polynomial
Parameters:
getRootsQuadratic [line 508]
array getRootsQuadratic(
$p, object
$m)
|
|
Get the roots of a quadratic Polynomial (using the Quadratic Formula)
Parameters:
getRootsQuartic [line 632]
array getRootsQuartic(
object
$p)
|
|
Find and return the roots of a Quartic Polynomial (degree 4) with the Quartic formula
Parameters:
getSlopeAt [line 1027]
float getSlopeAt(
object
$p, float
$x)
|
|
Get the slope of the Polynomial at a given x value
Parameters:
getTangentAt [line 962]
object getTangentAt(
object
$p, float
$x)
|
|
Get a Polynomial object representing a tangent to the given Polynomial at the given point
Parameters:
getTangentSlopeAt [line 1039]
isConstant [line 1142]
bool isConstant(
object
$p)
|
|
Tell whether or not a Polynomial is constant (degree 0)
Parameters:
isMath_Polynomial [line 723]
bool isMath_Polynomial(
object
$p)
|
|
Tell whether or not an object is a Polynomial or not
Parameters:
isZero [line 1116]
Tells whether or not the Polynomial is equivalent to zero
Parameters:
mod [line 322]
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 184]
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 151]
object &sub(
mixed
$p1, mixed
$p2)
|
|
Subtract one Polynomial from another Polynomial
Parameters:
_round [line 447]
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:35:51 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|