Scientific Calculator

(public) falcon/NRroot

By falcon Falcon

Root of a function using Newton-Raphson method

Tagged: algorithms newton root

var NRroot = function (f, x) {
dx = 1e-15;
eps = 1e-15;
err = 1;
while (err > eps) ->  (
x0 = x;
x = x0  - f(x0)*dx / (f(x0+dx)-f(x0) );
err = abs(x-x0);
);
x
}

spam? | offensive?

0 Comments

Sign in to leave a comment