dichotomy

1.1.3 • Public • Published

dichotomy(f, [a], [b]) ⇒ number | Promise.<number>

dichotomy.js Dichotomy algorithm: given a function f : x -> f(x) and two numbers a, b find y such that a < y < b and f(y) = 0

Kind: global function
Returns: number | Promise.<number> - y, such that f(y) == 0

Param Type Default Description
f function a function that takes a number and returns a number or a Promise
[a] Number -Number.MAX_VALUE Start of the search interval
[b] Number Number.MAX_VALUE End of the search interval

Example

dichotomy(x => x*x-2, 0, 10) == Math.sqrt(2)
dichotomy(x => Promise.resolve(x*x-2), 0, 10) == Promise.resolve(Math.sqrt(2))

Readme

Keywords

Package Sidebar

Install

npm i dichotomy

Weekly Downloads

45

Version

1.1.3

License

ISC

Last publish

Collaborators

  • lovasoa