Newton Raphson Applications
Newton Raphson Applications
Newton Raphson Applications
-----------------------------------------------
By Gilberto E. Urroz, Ph.D., P.E.
January 2010
f x 0
requires the knowledge of the derivative f'(x). This can be easily
accomplished in SMath Studio using the "Derivative" option in the
"Functions" palette:
d
fp x f x
dx
Given an initial guess of the solution, x x , the solution can
0
be approximated by the iterative calculation:
f x
k
x x
k 1 k f' x
k
for k 0 ,1, ...
2
Example: Solve the equation: x 2 x 5 0
--------
2
Define the function: f x x 2 x 5
16
0 x
-8
-4 -2 0 2 4 6
f x
-1-
The graph shows solutions near x = -2 and x = 3. We can
implement the solution using the Newton-Raphson method
as follows:
d
fp x f x fp x 2 1 x
dx
6
Parameters of the solution are: ε 1.0 10 nmax 100
First solution:
Starting with a guess of xG 2.5
we find a solution by using the following iterative procedure:
k 0
while k nmax f xG ε
f xG
xGp1 xG
fp xG
k k 1
xG xGp1
Second solution:
Starting with a guess of xG 4.2
we find a solution by using the following iterative procedure:
k 0
while k nmax f xG ε
f xG
xGp1 xG
fp xG
k k 1
xG xGp1
1.4495
solve f x 0, x
3.4495
2 1.4495
solve x 2 x 5 0, x
3.4495
-2-
3 - The Newton-Raphson method for a system of equations:
-------------------------------------------------------
f1 x ,x .. x 0
1 2 n
f2 x ,x
.. x 0
12 n
...
fn x , x .. x 0
1 2 n
or simply, f x 0 , with
f1 x ,x .. x
1 2 n f1 x
f2 x ,x .. x f2 x
f x 1 2 n
. .
fn x ,x .. x fn x
1 2 n
x
1
x
x 2
.
x
n
1
x x J x f x
k 1 k k k
J x
for k 0 ,1,... In this formula, k , is the Jacobian
matrix of the function defined as [to be 100% correct the
derivatives in this matrix should be partial derivatives]:
dy dy dy
1 1 1
.
dx dx dx
1 2 n
dy dy dy
2 2 2
.
J x dx dx dx
k 1 2 n
. . . .
dy dy dy
n n n
.
dx dx dx
1 2 n
Example:
--------
How to calculate the Jacobian matrix of a system of three
equations. Given the system of three equations:
-3-
x x x 6 This is obvious, but could
1 2 3
useful for larger functions:
x x x 6
f x 1 2 3 n length f x
2 2 3
x x x 14 n 3
1 2 3
for i 1 .. n
for j 1 .. n
d
jac f x
ij dx i
j
5
An initial guess is: xG 1
4
The iterative process for the solution is expressed as:
k 0
3 14
1.0161 10
xG 2
f xG 14
1 3.9933 10
14
2.1316 10
-4-
----------------------------------------------------------------
Note: The function representing the system of equations solved
above, namely,
x x x 6
1 2 3
x x x 6
f x 1 2 3
2 2 3
x x x 14
1 2 3
x y z 6 0 x y z 6
x y z 6 0 or x y z 6
2 2 2 2 2 2
x y z 14 0 x y z 14
-5-