PHP 클래스 MathPHP\NumericalAnalysis\RootFinding\BisectionMethod

In numerical analysis, the Bisection method is a method for finding successively better approximations to the roots (or zeroes) of a continuous, real-valued function f(x). It starts with two points $a and $b, such that f($a) and f($b) have different signs (one is positive, one is negative). This lets us use the intermediate value theorem to prove that there is a root $p such that p is between $a and $b. We initially set $p to be the average of $a and $b and analyze the result of f($p). Based on the sign, we construct a new $p that is either the average of $a and the original $p, or the average of the original $p and $b. We continue doing this until our function evaluation f($p) is within the tolerance set on our input. https://en.wikipedia.org/wiki/Bisection_method
파일 보기 프로젝트 열기: markrogoyski/math-php

공개 메소드들

메소드 설명
solve ( callable $function, number $a, number $b, number $tol ) : number Use the Bisection Method to find the x which produces $function(x) = 0.

비공개 메소드들

메소드 설명
validate ( callable $function, number $a, number $b, number $tol ) Verify the input arguments are valid for correct use of the bisection method. If the tolerance is less than zero, an Exception will be thrown.

메소드 상세

solve() 공개 정적인 메소드

Use the Bisection Method to find the x which produces $function(x) = 0.
public static solve ( callable $function, number $a, number $b, number $tol ) : number
$function callable f(x) callback function
$a number The start of the interval which contains a root
$b number The end of the interval which contains a root
$tol number Tolerance; How close to the actual solution we would like.
리턴 number