continued-fraction

0.0.0 • Public • Published

continued-fraction

Continued fractions are pretty great.

You can use them to compute transcendental real numbers!

example

e

var cf = require('continued-fraction');
var n = cf(
    function (n) { return (- 2) % 3 ? 1 : 2 * ((- 2) / 3) },
    function (n) { return 1 }
);
console.log(n);
2.7182818284590455

pi

var cf = require('continued-fraction');
var n = cf(
    function (n) { return 2 * (- 1) + 1 },
    function (n) { return n * n }
);
console.log(4/n);
3.141592653589793

methods

var cf = require('continued-fraction');

var n = cf(f, g)

Evaluate a continued fraction given two functions f and g which will be evaluated with a parameter i, a set index starting at 1 for sets a and b of the generalized form.

Returns a float n.

install

With npm do:

npm install continued-fraction

license

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i continued-fraction

Weekly Downloads

2

Version

0.0.0

License

MIT

Last publish

Collaborators

  • nopersonsmodules