You are on page 1of 3

# 11/7/2016

GitHubscijs/newtonraphsonmethod:FindzerosofafunctionusingtheNewtonRaphsonmethod

Personal

Open source

Explore

Pricing

Blog

Support

This repository

scijs / newtonraphsonmethod
Code

Issues 0

Watch

Pull requests 0

Projects 0

Pulse

Search

Star

Fork

Graphs

3 commits

Branch: master

1 branch

0 releases

1 contributor

Find file

## Latest commit 7155c50 on Jun 3

examples

Initial commit

5 months ago

images

Initial commit

5 months ago

test

Initial commit

5 months ago

.gitignore

Initial commit

5 months ago

.npmignore

Initial commit

5 months ago

.travis.yml

Initial commit

5 months ago

5 months ago

5 months ago

index.js

5 months ago

package.json

5 months ago

newtonraphsonmethod
Find zeros of a function using Newton's Method
build passing

npmpackage 1.0.0

dependencies none

codestyle semistandard

Introduction
The NewtonRaphson method uses the tangent of a curve to iteratively approximate a zero of a function, f(x). This yields
the update:

Example
Consider the zero of (x+2)*(x1) at x=1:
varnr=require('newtonraphsonmethod');
functionf(x){return(x1)*(x+2);}

https://github.com/scijs/newtonraphsonmethod

1/3

11/7/2016

GitHubscijs/newtonraphsonmethod:FindzerosofafunctionusingtheNewtonRaphsonmethod
functionfp(x){return(x1)+(x+2);}
//Usingthederivative:
nr(f,fp,2)
//=>1.0000000000000000(6iterations)
//Usinganumericalderivative:
nr(f,2)
//=>1.0000000000000000(6iterations)

Installation
\$npminstallnewtonraphsonmethod

API
require('newtonraphsonmethod')(f[,fp],x0[,options])
Given a realvalued function of one variable, iteratively improves and returns a guess of a zero.
Parameters:
f: The numerical function of one variable of which to compute the zero.
fp optional: The first derivative of f. If not provided, is computed numerically using a fourth order central difference

## with step size h.

x0: A number representing the intial guess of the zero.
options optional: An object permitting the following options:
tolerance default: 1e7: The tolerance by which convergence is measured. Convergence is met if |x[n+1]x[n]|
<=tolerance*|x[n+1]|.
epsilon default: 2.220446049250313e16 doubleprecision epsilon: A threshold against which the first derivative

## is tested. Algorithm fails if |y'|<epsilon*|y|.

maxIter default: 20: Maximum permitted iterations.
h default: 1e4: Step size for numerical differentiation.

Returns: If convergence is achieved, returns an approximation of the zero. If the algorithm fails, returns false.

modifiednewtonraphson: A simple modification of NewtonRaphson that may exhibit improved convergence.
newtonraphson: A similar and lovely implementation that differs only? in requiring a first derivative.

Authors
Ricky Reusser

https://github.com/scijs/newtonraphsonmethod

2/3

11/7/2016
2016 GitHub, Inc.

GitHubscijs/newtonraphsonmethod:FindzerosofafunctionusingtheNewtonRaphsonmethod
Terms

Privacy

Security

Status

https://github.com/scijs/newtonraphsonmethod

Help

Contact GitHub

API

Training

Shop

Blog