Newton Raphson

Overview


Root finding is the process of finding the inputs at which an algebraic function is zero.

newton raphson api

Demonstration


The Newton Raphson algorithm starts at a given point, then it computes the tangent at that point. The tangent will intersect the x-axis somewhere. The x values of that intersection with the x axis becomes the next point.

The follwoing graph demonstrates newton raphson on the function(x) = x*x. Starting at the point x=1, the tange is drawn and the point of intersection with the x axis is computed, and is used as the starting point of the second iteration of the algorithm.

Newton Raphson


The newton raphson method can be found in the newton raphson module found at the following URL.


'/lib/numeric/roots/v1.0.0/newton-raphson.mjs'
					


The newton raphson module contains a funtion called root.


function root(f, initial, error, maxiterations, derivative)
					


The following code demonstrates calculating a root using the Newton Raphson method.


let nr = await import('/lib/numeric/roots/v1.0.0/newton-raphson.mjs');

let f = function(x){
  return (x-5)*(x-5);
}

let test = nr.root(f);
let test2 = nr.root(f,0,0.000001,1000);
					
newton-raphson, see chapra - pg. 151

Try it!

Contents