PHP Class MathPHP\NumericalAnalysis\RootFinding\SecantMethod

In numerical analysis, the Secant Method is a method for finding successively better approximations to the roots (or zeroes) of a real-valued function. It is a variation of Newton's Method that we can utilize when the derivative of our function f'(x) is not explicity given or cannot be calculated. https://en.wikipedia.org/wiki/Secant_method
Datei anzeigen Open project: markrogoyski/math-php

Public Methods

Method Description
solve ( callable $function, number $p₀, number $p₁, number $tol ) : number Use the Secant Method to find the x which produces $f(x) = 0 by calculating the average change between our initial approximations and moving our approximations closer to the root.

Private Methods

Method Description
validate ( number $p₀, number $p₁, number $tol ) Verify the input arguments are valid for correct use of the secant method If the tolerance is less than zero, an Exception will be thrown. If $p₀ = $p₁, then we cannot run our loop because the slope with be undefined, so we throw an Exception.

Method Details

solve() public static method

Use the Secant Method to find the x which produces $f(x) = 0 by calculating the average change between our initial approximations and moving our approximations closer to the root.
public static solve ( callable $function, number $p₀, number $p₁, number $tol ) : number
$function callable f(x) callback function
$p₀ number First initial approximation
$p₁ number Second initial approximation
$tol number Tolerance; How close to the actual solution we would like.
return number