PHP Класс 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
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

solve() публичный статический Метод

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.
Результат number