NM - 03b Non Linear Eq - New1
NM - 03b Non Linear Eq - New1
NM - 03b Non Linear Eq - New1
Newton-Raphson Method
This method is more efficient than the Bisection and Iteration methods. If x is the real root and x0 is an initial approximation of the real root of an equation f(x) = 0, f (x0) 0, f(x) has the same sign between x0 and x, Then, the tangent at f(x0) can lead to the real root x.
2
tangent at f(x0)
Newton-Raphson Method
Methodology Let x0 be an approximate root of f(x) = 0 and Let, x1 is the correct root such that x1 = x0 + h and f(x1) = 0. Expanding f(x0+h) by Taylors series, we obtain,
h2 f ( x0 ) + hf ( x0 ) + f ( x0 ) + ... = 0 2!
Neglecting the second and higher order derivatives, we have Which gives
f ( x0 ) + hf ( x0 ) = 0
f ( x0 ) h= f ( x0 )
f ( x0 ) x1 = x0 + h = x0 f ( x0 )
Successive approximation are given by x2, x3, .., xn, xn+1 where
f ( xn ) xn +1 = xn f ( xn )
This formula is known as the Newton-Raphson formula.
Newton-Raphson Method
f(x)
f(xi)
[x f (x )]
i, i
f(xi ) xi +1 = xi f (xi )
f(xi-1) xi+2 xi+1 xi X
Derivation
8
f(x)
f(xi)
tan( ) =
AB AC
f ( xi ) f ' ( xi ) = xi xi +1
C xi+1 A xi X
f ( xi ) xi +1 = xi f ( xi )
http://numericalmethods.eng.usf.edu
Step 1
Evaluate
f (x)
symbolically.
10
http://numericalmethods.eng.usf.edu
Step 2
Use an initial guess of the root, xi , to estimate the new value of the root, xi +1, as
f ( xi ) xi +1 = xi f (xi )
11
http://numericalmethods.eng.usf.edu
Step 3
Find the absolute relative approximate error a as
xi +1- xi a = 100 xi +1
12
http://numericalmethods.eng.usf.edu
Step 4
Compare the absolute relative approximate error with the pre-specified relative error tolerance s .
Yes Is a >s? No Go to Step 2 using new estimate of the root. Stop the algorithm
Also, check if the number of iterations has exceeded the maximum number of iterations allowed. If so, one needs to terminate the algorithm and notify the user.
13 http://numericalmethods.eng.usf.edu
Example
You are working for DOWN THE TOILET COMPANY that makes floats for ABC commodes. The ball has a specific gravity of 0.6 and has a radius of 5.5 cm. You are asked to find the distance to which the ball will get submerged when floating in water.
15
Solution
The equation that gives the depth x to which the ball is submerged under water is given by
16
f ( x ) = x -0.165 x +3.993x10
3 2
-4
http://numericalmethods.eng.usf.edu
Iteration #1
18
x0 = 0.02
Iteration #2
19
x1 = 0.08320 x2 = x1
f ( x1 ) f ' ( x1 )
Contoh Program
Penyelesaian dgn fzero
function newraph_o x0=0.02; x=fzero(@fungsi, x0,optimset('display','off')) function y=fungsi(x) y=x^3-0.165*x^2+0.00039
');
Advantages
21
Mulai
Nyatakan: x = x0 x0 = x + 1
Selesai
Function
function fx=f_cth_NR_01(x) fx=x^3-1; Catatan: Program yang ditulis dalam MATLAB disimpan dalam mfile. Ada 2 jenic m-file: -script m-file -function m-file
fzero
Matlab function for solving a single nonlinear algebraic equation Finds the root of a continuous function of one variable Syntax: x = fzero(fun,xo)
fun is the name of the user provided Matlab m-file function (fun.m) that evaluates and returns the LHS of f(x) = 0 xo is an initial guess for the solution of f(x) = 0
Algorithm uses a combination of bisection, secant, and inverse quadratic interpolation methods Function for solving a system of nonlinear algebraic equations Only available in Matlab Optimization Toolbox Discussed next lecture
fsolve
MATLABs fzero provides the best qualities of both bracketing methods and open methods.
function is a function handle to the function being evaluated x0 is the initial guess x is the location of the root fx is the function evaluated at that root
Using an initial bracket: x = fzero(function, [x0 x1]) [x, fx] = fzero(function, [x0 x1])
As above, except x0 and x1 are guesses that must bracket a sign change
fzero Options
Options may be passed to fzero as a third input argument - the options are a data structure created by the optimset command
options = optimset(par1, val1, par2, val2,)
the name of the parameter to be set valn is the value to which to set that parameter The parameters commonly used with fzero are:
parn is
display: when set to iter displays a detailed record of all the iterations tolx: A positive scalar that sets a termination tolerance on x.
fzero Example
Nama fungsi
Harga awal
Contoh
Iterasi ke1 2 3 4
2-(23-1)/(3x22) = 1.4167 (not OK) 1.011 -(1.0113-1)/(3x 1.0112) = 1.0001 (not OK)
1.4167 1.4167 -(1.41673-1)/(3x1.41672) = 1.011 (not OK) 1.0001 1.0001 -(1.0001 3-1)/(3x 1.0001 2) = 1.0000001 (OK)
Main Program
v0=500; v=fsolve(@rey,v0,optimset(@fsolve)); fprintf('nilai v ketemu= %6.4f cm/s',v)