Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 6x 6x 6x 6x 6x 15x | import { Polynomial } from '../polynomial'
export enum RootFinderMethod {
Bisection = 'bisection',
Newton = 'newton',
}
export type RootFinderOptions = {
epsilon: number
estimate: number | 'auto'
fallbackMethod: RootFinderMethod | null
maxIterations: number
method: RootFinderMethod
}
export type Root = {
converged: boolean
iterations: number
value: number
}
export interface IRootFinder {
findRoot(polynomial: Polynomial): Root
}
export const DEFAULT_ROOT_FINDER_OPTIONS: RootFinderOptions = {
estimate: 'auto',
epsilon: 1e-8,
fallbackMethod: RootFinderMethod.Bisection,
maxIterations: 100,
method: RootFinderMethod.Newton,
}
export function getRootFinderOptionsWithDefaults(
options: Partial<RootFinderOptions>,
): RootFinderOptions {
return Object.assign({}, DEFAULT_ROOT_FINDER_OPTIONS, options)
}
|