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
파일 보기 프로젝트 열기: markrogoyski/math-php

공개 메소드들

메소드 설명
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