bisection
▸ function bisection
(f
: function, a
: number, b
: number): number
Defined in roots/naive/bisection.ts:35
Returns a refined root given a root bracketed in the interval (a,b) of the given function using the Bisection Method algorithm.
any function can be supplied (it does not even have to be continuous) as long as the root is bracketed.
this function has no advantages above Brent's method except for its simpler implementation and can be slower. Use brentPoly or brent instead.
the algorithm stops once the interval width becomes equal or less than
2 * Number.EPSILON * max(1,abs(a),abs(b))
wherea
andb
are the current lower and upper interval limits
example
const p = fromRoots([-10,2,3,4]); //=> [1, 1, -64, 236, -240]
const f = t => Horner(p,t);
bisection(f,2.2,3.8); //=> 3
bisection(f,2.2,3.1); //=> 3.0000000000000044
Parameters:
Name | Type | Description |
---|---|---|
f | (n: number) => number | the function for which the root is sought |
a | number | the lower limit of the search interval |
b | number | the upper limit of the search interval |
Returns: number