0% found this document useful (0 votes)
11 views22 pages

FENG345_lec4

The document discusses various open methods for finding roots of equations, including simple fixed-point iteration, Newton-Raphson, and secant methods. It highlights the advantages of these methods over the bisection method, particularly in terms of convergence speed. Several examples illustrate the application of these methods, along with MATLAB programming for practical implementation.

Uploaded by

Sadettin Şahin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views22 pages

FENG345_lec4

The document discusses various open methods for finding roots of equations, including simple fixed-point iteration, Newton-Raphson, and secant methods. It highlights the advantages of these methods over the bisection method, particularly in terms of convergence speed. Several examples illustrate the application of these methods, along with MATLAB programming for practical implementation.

Uploaded by

Sadettin Şahin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

FENG 345 Numerical Methods for

Engineers I

Lecture 4

Roots (Open Methods)


Dr. Osman Nuri Şahin
1
Introduction
• For the bisection method in previous lecture, the root is located within
an interval prescribed by a lower and an upper bound.
• These methods always results in closer estimates of the true value of
the root.

2
Introduction
• The open methods require only a single starting value or two starting
values that do not necessarily bracket the root.
• When the open methods converge
they usually do so much more
quickly than the bisection method.

3
Simple Fixed-point Iteration
• Open methods employ a formula to predict the root.
• Such a formula can be developed for simple fixed-point iteration by
rearranging the function 𝑓(𝑥) = 0 so that 𝑥 is on the left-hand side of
the equation:

• Given an initial guess at the root 𝑥𝑖 , this equation can be used to


compute a new estimate 𝑥𝑖+1 as expressed by the iterative formula

• the approximate error for this equation can be determined using the
error estimator:

4
Example 1
• Use simple fixed-point iteration to locate the root of 𝑓 𝑥 = 𝑒 −𝑥 − 𝑥.
Solution: The function can be separated directly

Starting with an initial guess of 𝑥0 = 0, this iterative equation can be


applied to compute:

5
each iteration brings the estimate closer to the true value of the root: 0.56714329.
Example
• The concepts of convergence and divergence can be depicted graphically.
• pair of equations 𝑦1 = 𝑥 and 𝑦2 = 𝑔 𝑥 .
• These two equations can then be plotted separately.
For the function 𝑓 𝑥 = 𝑒 −𝑥 − 𝑥 ,

Then the two equations

and

6
Example
• If |𝑔′ | < 1, the errors decrease with
each iteration. For |𝑔′ | > 1 the errors
grow.
• convergence occurs when |𝑔′ | < 1.

(a) and (b) convergence and (c) and (d) divergence of simple
fixed-point iteration. 7
NEWTON-RAPHSON
• Perhaps the most widely used of all root-locating formulas is the
Newton-Raphson method.
• If the initial guess at the root is 𝑥𝑖 , a tangent
can be extended from the point 𝑥𝑖 , 𝑓 𝑥𝑖 .
• The point where this tangent crosses the x
axis usually represents an improved estimate
of the root.

8
NEWTON-RAPHSON
• the first derivative at x is equivalent to the
slope:

• which can be rearranged to yield

• which is called the Newton-Raphson formula.

9
Example 2
• Use the Newton-Raphson method to estimate the root of 𝑓 𝑥 = 𝑒 −𝑥 − 𝑥
employing an initial guess of 𝑥0 = 0.
Solution:

Then,

Starting with an initial guess of 𝑥0 = 0, this iterative equation can be applied


to compute
**The approach rapidly converges on the true root. Notice that the true percent relative error at each iteration
decreases much faster than it does in simple fixed-point iteration. 10
Example
• Determine the positive root of 𝑓 𝑥 = 𝑥 10 − 1 using the Newton-
Raphson method and an initial guess of 𝑥 = 0.5.
Solution: The Newton-Raphson formula for this case is

which can be used to compute


• After the first poor prediction, the
technique is converging on the true
root of 1, but at a very slow rate.

11
Example
• The first iteration flings the solution far away from the initial guess to a new
value (x = 51.65) where f (x) has an extremely high value.

12
Example
• There is no general convergence criterion for Newton-Raphson. Its
convergence depends on the nature of the function and on the accuracy of
the initial guess.

13
SECANT METHODS
• A potential problem in implementing the Newton-Raphson method is the
evaluation of the derivative.
• Although this is not inconvenient for polynomials and many other
functions, there are certain functions whose derivatives may be difficult
or inconvenient to evaluate.
• For these cases, the derivative can be approximated by a backward finite
divided difference:

14
SECANT METHODS
• Then

This is the formula for the secant method. Notice that the approach
requires two initial estimates of x.

15
Non-linear algebraic equations. Newton-Raphson method.

f (x)  0 f (a ) f
Taylor series : f ( x )  f (a )  ( x  a )  ... 0  f  f   x n 1  x n  
f
İ
1
Example 4.1 2 sin  u   u a) Find u. b) Write a MatLAB program to find u.

f (u )  u  2 sin  u   0 f ( x )  x  2 sin  x   0
df 1
Solution: a)  1 cos( x )
dx x

0.6829
f (1)  1  2 sin  1  0.6829
1 1   1.4856
Initial guess x1=1 f (1)  1  cos( 1)  0.4597
1 0.4597
x2=1+1.4856=2.4856 f (2.4856)  2.4856  2 sin  2.4856   0.4856
 0.4856
f (2.4856)  1 
1
cos( 2.4856 )  1.0091 2   0.4812
2.4856 1.0091

x3=2.4856-0.4812=2.0044 f (2.0044)  2.0044  2 sin  2.0044   0.0284


1  0.0284
f (2.0044)  1  cos(2.0044)  0.7814 3   0.0363
2.0044 0.7814

x4=2.0044-0.0363=1.9681 … continued  4  0.0049 x5=1.9681+0.0049=1.9730


5  0.0007 x5=1.9730-0.0037=1.9723
f
f ( x )  x  2 sin  x   0
df 1
b)  x n 1  x n    1 cos( x )
f dx x

% nr1.m
clc,clear,close all
x=1;xe=[0.001];niter=20;kerr=1; ans = 0 4.0000 -0.0001 1.9724
for n=1:1:niter;
f=x-2*sin(sqrt(x)); fd=1-(1/sqrt(x))*cos(sqrt(x));
eps=-f/fd; x=x+eps; if abs(eps)<xe;kerr=0;break;end
end
[kerr,n,eps,x]
Example 4.2

Write a MatLAB program


Solution:
h 2
x 2 df 2x x 2
(9  h )  30 (9  x )  30  0  (9  x)  (1)
3 3 dx 3 3
% nr1.m
clc,clear,close all ans = 0 3.0000 -0.0001 2.0269
x=3;xe=[0.001];niter=20;kerr=1;
for n=1:1:niter;
f=pi*x^2*(9-x)/3-30; fd=2*pi*x*(9-x)/3-pi*x^2/3; h=2.0269 m
eps=-f/fd; x=x+eps; if abs(eps)<xe;kerr=0;break;end
end
[kerr,n,eps,x]
Nonlinear set of algebraic equations. Newton-Raphson method.
f (x)  0 f   f x n 1  x n  
(This subject will be in the last weeks of the semester)
Error equations :
f1 ( x1 , x 2 )  0
 f1 f1  x1 n 1  x1 n  1
f 2 ( x1 , x 2 )  0  x x 2   1    f1 
 1  
 f 2 f 2   2   f 2  x 2 n 1  x 2 n   2
 x1 x 2 

Example 4.3 2u  4.1sin(3v)  3 2 v  3u 2  10.5 Write a MatLAB program to find u and v.
% nr.m
f1  2 x1  4.1sin(3x 2 )  3  0 clc, clear,close all
x=[-1;3];xe=[0.001;0.001];niter=20;kerr=1;
f 2  3x12  2 x 2  10.5  0
%------------------
Error equations : for n=1:1:niter;
%------------------
 2  4.1(3) cos(3x 2 )  1    f1  b=[2*x(1)-4.1*sin(3*x(2))+3;3*x(1)^2+2*x(2)-10.5];b=-b;
6 x    
 1 2  
 2   2  f a=[2,-4.1*3*cos(3*x(2));6*x(1),2];
%------------------
eps=inv(a)*b;x=x+eps;if abs(eps)<xe;kerr=0;break;end
end
x1  1.1993, x 2  3.0925
[kerr,n],[eps,x]
Home Excercise 4.1

Write a MatLAB program.

Home Excercise 4.2


Home Excercise 4.1

Write a MatLAB program.


Solution: x=0:1:200;u=6.26./sqrt(x);f=6.26*sqrt(x).*tanh(u)-36;plot (x,f)
gm  gc  e x  ex
v( t )  tanh t  tanh( x )  x x
c  m  e e % nr1.m
clc,clear,close all
g=9.81, c=0.25, t=4, v=36 x=100;xe=[0.001];niter=20;kerr=1;
for n=1:1:niter;
 6.26  u=6.26/sqrt(x);f=6.26*sqrt(x)*tanh(u)-36;
36  6.26 m tanh  f ( x )  6.26 x tanh u ( x )   36 fd=3.13/sqrt(x)*tanh(u)+6.26*sqrt(x)*(-3.13)*x^(-1.5)...
 m
*(((exp(u)+exp(-u))^2-((exp(u)-exp(-u))^2)))/((exp(u)+exp(-u))^2);
eps=-f/fd; x=x+eps; if abs(eps)<xe;kerr=0;break;end
6.26 e u  e u
u(x)  tanh(u )  u u end
x e e [kerr,n,eps,x],vpa(x)

u 2 u 2
1.5 (e  e )  (e  e )
u u
df 1
 3.13 tanh u ( x )   6.26 x (3.13) x ans = 144.93259626492792335739068221301
dx x (e u  e  u ) 2
Home Excercise 4.2 9.81
Solution: 1  90(tan 0 )  (8100)  1.8
(2)(900) cos 2 0

44.145
f  90(tan x )   0.8  0
cos 2 x

90 2 sin x cos x
f   44.145
cos 2 x cos 4 x

th0=0:1:80;x=th0*pi/180;f=90*tan(x)-44.145./(cos(x)).^2+0.8;plot (x,f)

nr1.m
clc,clear,close all
x=30*pi/180;xe=[0.001];niter=20;kerr=1;
for n=1:1:niter;
f=90*tan(x)-44.145/(cos(x))^2+0.8;
fd=90/(cos(x))^2-2*44.145*sin(x)*cos(x)/(cos(x))^4;
eps=-f/fd; x=x+eps; if abs(eps)<xe;kerr=0;break;end
end
[kerr,n,eps,x*180/pi]

0  37.95o for initial guess 30o

0  51.53o for initial guess 60o

You might also like