math-php
|
Base class for numerical integration techniques. More...
Static Public Member Functions | |
static | approximate ($source,... $args) |
static | getPoints ($source, array $args=[]) |
Determine where the input $source argument is a callback function, a set of arrays, or neither. More... | |
static | validate (array $points, $degree=2) |
Validate that there are enough input arrays (points), that each point array has precisely two numbers, and that no two points share the same first number (x-component) More... | |
Public Attributes | |
const | X = 0 |
const | Y = 1 |
Static Protected Member Functions | |
static | functionToPoints (callable $function, $start, $end, $n) |
Evaluate our callback function at n evenly spaced points on the interval between start and end. More... | |
static | sort (array $points) |
Sorts our coordinates (arrays) by their x-component (first number) such that consecutive coordinates have an increasing x-component. More... | |
Base class for numerical integration techniques.
Numerical integration techniques are used to approximate the value of an indefinite intergal.
This calss gives each technique a set of common tools, and requires each technique to define an approximate() method to approximate an indefinite integral.
|
staticprotected |
Evaluate our callback function at n evenly spaced points on the interval between start and end.
callable | $function | f(x) callback function |
number | $start | the start of the interval |
number | $end | the end of the interval |
number | $n | the number of function evaluations |
|
static |
Determine where the input $source argument is a callback function, a set of arrays, or neither.
If $source is a callback function, run it through the functionToPoints() method with the input $args, and set $points to output array. If $source is a set of arrays, simply set $points to $source. If $source is neither, throw an Exception.
Add method to verify function is continuous on our interval
Add method to verify input arguments are valid. Verify $start and $end are numbers, $end > $start, and $points is an integer > 1
callable | array | $source | The source of our approximation. Should be either a callback function or a set of arrays. |
array | $args | The arguments of our callback function: start, end, and n. Example: [0, 8, 5]. If $source is a set of arrays, $args will default to []. |
Exception |
|
staticprotected |
Sorts our coordinates (arrays) by their x-component (first number) such that consecutive coordinates have an increasing x-component.
array | $points |
|
static |
Validate that there are enough input arrays (points), that each point array has precisely two numbers, and that no two points share the same first number (x-component)
array | $points | Array of arrays (points) |
number | $degree | The miminum number of input arrays |
Exception | if there are less than two points |
Exception | if any point does not contain two numbers |
Exception | if two points share the same first number (x-component) |