scijs/modified-newton-raphson

Name: modified-newton-raphson

Owner: scijs

Description: Find zeros a function using the Modified Newton-Raphson method

Created: 2016-06-01 19:03:56.0

Updated: 2016-12-25 10:59:10.0

Pushed: 2016-06-03 03:49:40.0

Homepage: null

Size: 36

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

modified-newton-raphson

Find zeros of a function using the Modified Newton-Raphson method

Build Status npm version Dependency Status js-semistandard-style

Introduction

The Newton-Raphson method uses the tangent of a curve to iteratively approximate a zero of a function, f(x). The Modified Newton-Raphson [1][2] method uses the fact that f(x) and u(x) := f(x)/f'(x) have the same zeros and instead approximates a zero of u(x). That is, by defining

u(x) = \frac{f(x)}{f'(x)},

the Newton-Raphson update for u(x),

x_{i + 1} = x_i -\frac{u(x_i)}{u'(x_i)},

becomes

x_{i+1} = x_i - \frac{f(x_i)f'(x_i)}{(f'(x_i))^2 - f(x_i)f''(x_i)}.

In other words, by effectively estimating the order of convergence, it overrelaxes or underrelaxes the update, in particular converging much more quickly for roots with multiplicity greater than 1.

Example

Consider the zero of (x + 2) * (x - 1)^4 at x = 1. Due to its multiplicity, Newton-Raphson is likely to reach the maximum number of iterations before converging. Modified Newton-Raphson computes the multiplicity and overrelaxes, converging quickly using either provided derivatives or numerical differentiation.

mnr = require('modified-newton-raphson');

tion f   (x) { return Math.pow(x - 1, 4) * (x + 2); }
tion fp  (x) { return 4 * Math.pow(x - 1, 3) * (x + 2) + Math.pow(x - 1, 4); }
tion fpp (x) { return 12 * Math.pow(x - 1, 2) * (x + 2) + 8 * Math.pow(x - 1, 3); }

sing first and second derivatives:
f, fp, fpp, 2)
> 1.0000000000000000 (4 iterations)

sing numerical second derivative:
f, fp, 2)
> 1.000000000003979 (4 iterations)

sing numerical first and second derivatives:
f, 2)
> 0.9999999902458561 (4 iterations)
Installation
m install modified-newton-raphson
API
require('modified-newton-raphson')(f[, fp[, fpp]], x0[, options])

Given a real-valued function of one variable, iteratively improves and returns a guess of a zero.

Parameters:

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

See Also
References

[1] Wu, X., Roots of Equations, Course notes.
[2] Mathews, J., The Accelerated and Modified Newton Methods, Course notes.

License

© 2016 Scijs Authors. MIT License.

Authors

Ricky Reusser


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.