num-roots-in-range

▸ function numRootsInRange (p: number[], a: number, b: number): number

Defined in roots/descartes/double/num-roots-in-range.ts:33

Returns the exact number of distinct real roots in the open interval (a,b) of the given polynomial - subject to floating point underflow / overflow of intermediate calculations.

example

const p = [1, 1, -64, 236, -240];
numRootsInRange(p,-20,-11); //=> 0
numRootsInRange(p,-11,-9); //=> 1
numRootsInRange(p,-11,3.5); //=> 3
numRootsInRange(p,-11,5); //=> 4

Parameters:

NameTypeDescription
pnumber[]a polynomial with coefficients given densely as an array of double floating point numbers from highest to lowest power, e.g. [5,-3,0] represents the polynomial 5x^2 - 3x
anumbera lower bound
bnumberan upper bound

Returns: number