Professional Documents
Culture Documents
LEC06 - PT2 - CH06 - Open Methods
LEC06 - PT2 - CH06 - Open Methods
MAE3100
LECURE 6 - 1
LECTURE 6
ROOTS OF EQUATIONS 2: OPEN METHODS
Motivation: Bracketing methods provide a robust approach for numerically computing the roots of a nonlinear equation. However, convergence is slow. Open methods are iterative numerical techniques for finding roots that typically converge faster than bracketing approaches.
Assigned Reading:
MAE3100
LECURE 6 - 2
LECTURE 6 OBJECTIVES
The primary objective of this lecture is to gain a working knowledge of open methods used to compute the roots of a single nonlinear equation. More specifically, this lecture will: Recognize the difference between bracketing and open methods. Solve for roots using the fixed point iteration, Newton Raphson, and secant methods. Provide insight into how polynomials occur in engineering analysis. Show how to compute the roots of polynomials and other nonlinear functions with MATLAB.
MAE3100
LECURE 6 - 3
Rearrange to give:
Define iterative update For example: Let f(x) = e-x - x = 0 Then x = g(x) = e-x xi 1 e xi And
x = g(x)
xi+1 = g(xi) f2
Convergence is: asymptotic if 0 < g(x) < 1 oscillatory if -1 < g(x) < 0 error may grow when |g(x)| > 1
linear convergence
MAE3100
consider
f ( x) 1.5 x (1 x 2 ) 2
LECURE 6 - 4
1 x
0.65x 1 x2
solution
1 0.9
1 x
f1 = x
0.5 0.4 0.3 0.2 0.1 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
f2 = g (x)
MAE3100
LECURE 6 - 5
Newton-Raphson Iteration
Most widely used method for solving nonlinear equations Exhibits quadratic convergence (i.e., Ei+1 = Ei2) The solution procedure begins with a single initial guess x1 Requires the evaluation of both f (xi) and f (xi) at each iteration May be derived from a 1st order Taylor Expansion about xi Consider:
f ( x) f ( xi ) f ( xi )( x xi )
f (x) solution
f ( xi )
xi )
f (xi) f (xi)
( xi
xi ) xi
1
f ( xi ) f ( xi ) f ( xi ) xi f ( xi )
xi+1
f ( xi )
xi
f ( xi )
MAE3100
LECURE 6 - 6
consider
f ( x) 1 x 0.65x 1 x2
f (x)
0.2 0
-0.2
-0.4
iter ----1 2 3 4 5
-0.6
solution
-0.8
-1
-1.2
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
MAE3100
LECURE 6 - 7
MAE3100
LECURE 6 - 8
MAE3100
LECURE 6 - 9
FUNCTION nr1(x1, es, maxiter) xi = x1 DO iter = 1, maxiter f = f(xi) fp = f(xi) If | f | < es EXIT xi = xi f/fp use feval to call user-defined END DO M-File for f and f END nr1 Note: this is NOT a user-friendly NR program. It needs to be modified so that it will accommodate user defined functions and solution parameters (e.g., xi, imax, and es).
MAE3100
LECURE 6 - 10
MATLAB - feval
[y1,y2,...] = feval(func,x1,...,xn) Evaluates the function, func (usually defined by an M-file or built-in function), using arguments x1 through xn. the following are the same: >>sin(pi/4) >>feval(sin,pi/4) >>feval(@sin,pi/4)
MAE3100
LECURE 6 - 11
Function M-files
function nr1(xi,imax,es) for i = 1:imax [f fp] = nrex1(xi); disp([i xi f]); if abs(f)<es,break,end xi = xi - f/fp; end
Function M-file
function nr1(func,xi,imax,es) for i = 1:imax [f fp]=feval(func,xi); disp([i xi f]); if abs(f)<es,break,end xi = xi - f/fp; end
Execution in MATLAB
>>nr1(1,25,1E-8)
Execution in MATLAB
>>nr1(1,25,1E-8)
Execution in MATLAB
>>nr1(nrex1,1,25,1E-8)
or
>>nr1(@nrex1,1,25,1E-8)
MAE3100
LECURE 6 - 12
Then
xi
1
xi xi
2,3,4,...
xi+2 xi+1 xi
f ( xi ) ~ f
MAE3100
LECURE 6 - 13
1.5 x (1 x 2 ) 2
xi ----------0.0 0.5 0.49022 0.48540 0.48305
0.65 tan
f (xi) -----------1.02102 0.02035 0.01015 0.00497 0.00241
1 x
0.65x 1 x2
f (x)
0.2 0
-0.2
-0.4
-0.6
solution
-0.8
-1
0.48087
0.00000721
-1.2
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
x
converged for | f(x) | < 10-5
MAE3100
LECURE 6 - 14
Introduction to Polynomials
One goal of Chapter 6 is to determine the root(s) of an n-th order polynomial with (real) constant coefficients ai written as
f n ( x) a0 a1 x a2 x 2 an x n
The roots obey these rules: There are n real or complex roots All n roots are not necessarily distinct For odd n, there is at least 1 real root If there are complex roots, they occur in complex conjugate pairs, i.e.,
x1
a bi
x2
a bi
MAE3100
LECURE 6 - 15
Engineering Application
Consider a spring-mass-damper system (i.e., an automotive suspension) Forces Spring force -kx c x Damper force External force F(t) From Newtons 2nd Law
F(t)
F (t ) kx cx
m x
m cx kx x
F (t )
m cx kx 0 x
Assume a solution of the form x = ert
Factoring out ert yields a 2nd order polynomial called the characteristic equation
MAE3100
LECURE 6 - 16
r1 r2
c 2 4mk 2m
(3) (1)
2 km
(2)
x(t )
Ae r1 t
Be r2 t
( A cos t
B sin t )
c 2m
c 2 4mk 2m
x(t )
( A Bt )e
MAE3100
LECURE 6 - 17
a ( x x2 ) 2 b ( x x2 ) c
2c b b
2
Bairstows Method (Chapra and Canale s7.5) Divides the polynomial by x2 r x s Adjusts r and s until remainder vanishes Update process based on Newtons method Both are iterative and other more advanced methods exist
MAE3100
LECURE 6 - 18
a1 x5 a2 x 4 a3 x3 a4 x 2 a5 x a6
which may be rewritten as
a1 1 0 0 0
a1 0 1 0 0
a1 0 0 1 0
a1 0 0 0 1
a1 0 0 0 0
whose Eigenvalues are the roots of the polynomial See eig in MATLAB
MAE3100
LECURE 6 - 19
example:
MAE3100
LECURE 6 - 20
returns an array p with values that are the coefficients of a polynomial with roots r syntax: p = poly(r) p ( x) ( x 1)( x 1) example: find the polynomial having x2 x x 1 roots of 1 and -1 2
>> p = poly([1 -1]) p = 1 0 -1
x 1 (1) x 2 (0) x ( 1)
example:
10
MAE3100
LECURE 6 - 21
MATLAB - polyder
polyder evaluates the derivative of a polynomial p or the product of the polynomials a and b syntax: polyder(p) polyder(a,b) example: for p(x) = x3 6x2 72x 27, find dp/dx
>> p = [1 -6 -72 -27]; >> polyder(p) ans = 3 -12 -72
example:
18
MAE3100
LECURE 6 - 22
-7.1250
3.8750
-1.2500
recovers b recovers a
-2.5000
11