che 374 computational methods in engineering · 10 bisection algorithm step 1 choose lower x l and...
TRANSCRIPT
![Page 1: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/1.jpg)
1
ChE 374Computational Methods in Engineering
Solution of Non-Linear Equations
![Page 2: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/2.jpg)
2
Roots of Equations• Many engineering problems require the
determination of the values of the variable xwhich satisfies the non-linear equation
( ) 0f x =
![Page 3: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/3.jpg)
3
Non-Linear Eqn.
• Bracketing methods– Bisection– Regula falsi (False position)
– Graphical methods to provide insight– Error formulation
![Page 4: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/4.jpg)
4
Non-Linear Eqn.• Open methods
– Systematic trial and error– Computationally efficient, but do not always
work• Newton Raphson• Secant• One-point iteration
• Roots of Polynomials– Muller’s– Bairstow’s
![Page 5: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/5.jpg)
5
Example
• Using the graphical approach to determine the value of the drag coefficient ( c ) needed for a parachutist of mass m=68.1 kg to have a velocity of 40 m/s after free falling time of 10s.
• NOTE g = 9.8 m/s2.
![Page 6: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/6.jpg)
6
Drag coefficient to attain a given velocity at a set time period
( )( )/1 e c m tgmvc
−= −
( )( )/( ) 1 e c m tgmf c vc
−= − −
![Page 7: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/7.jpg)
7
c f (c )
4
8
12
16
20
34.115
17.653
6.067
-2.269
-8.401
f (c )
-15
-10
-5
0
5
10
15
20
25
30
35
40
0 5 10 15 20 25
f (c )
( )( )/( ) 1 e c m tgmf c vc
−= − − g= 9.8m/s2, m=68.1 kg, t=10s, v = 40 m/s
The curve crosses the x axis between 12 and 16. A rough estimate of the root is 14.8. The graphical method is not very accurate, but provides a good estimate. Also helps to understand the properties of the function.
![Page 8: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/8.jpg)
8
Plot of tan (x) showing singularitiestanx
-10
-8
-6
-4
-2
0
2
4
6
8
10
0 1 2 3 4 5 6 7
tanx
![Page 9: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/9.jpg)
9
Root search algorithm%Incremental search for a root of f(x)%USAGE: [x1,x2] = rootsearch(func, a,b, dx)%INPUT:% func = handle of function that returns f(x)% a,b = limits of search% dx = search increment% OUTPUT% x1, x2 = bounds of function that returns f(x)% set to NaN if no root is found%function [x1,x2] = rootsearch(func, a,b, dx)
x1 = a;f1 = feval(func,x1);x2 = a + dx;f2 = feval(func,x2);
while f1*f2 > 0.0if x1 >= b
x1=NaN; x2 = NaN; returnendx1 = x2;f1 = f2;x2 = x1+dx;f2 = feval(func,x2);
end
![Page 10: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/10.jpg)
10
Bisection AlgorithmStep 1 Choose lower xl and upper xu guesses for the root
such that the function changes sign over the interval. This can be checked by ensuring that f(xl)f(xu) <0
Step 2 An estimate of the root xr is determined byxr = (xl + xu)/2
Step 3 Make the following evaluations to determine in which subinterval the root lies
(a) If f(xl)f(xr) <0, root lies in lower subinterval, set xu=xl and go to step 2
(b) If f(xl)f(xr) >0, root lies in upper interval, set xl = xrand return to step 2
(c) If f(xl)f(xr) =0, the root equals xr; end computation
![Page 11: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/11.jpg)
11
Number of bisections
1
(0)
Bisection is repeated until the original intervalhas been reduced to a small value, so that
If is the original intervalthe number of bisections required to attaina prescribed absolute
i ix x
x
εε−− ≤
Δ
error is
(0)
ln
ln 2
x
nε
⎛ ⎞Δ⎜ ⎟⎝ ⎠=
Slow but sure !!!
![Page 12: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/12.jpg)
12
Termination criteria and error estimatesDefine approximate percent error as
100%
root for the present iteration
root from the previous iteration
new oldr r
a newr
newroldr
x xx
x
x
ε −= ×
≡
≡
(using absolute values because we are concerned about the magnitude,Not the sign)
When the error becomes less than specified stopping criterion, the computation stopped.
![Page 13: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/13.jpg)
13
![Page 14: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/14.jpg)
14
Regula Falsi (False Position) Method
2x
1x
1( )f x
2( )f x
( )f x
3x 4x
( )11
1
( )( ) ( )
i i ii i
i i
f x x xx x
f x f x−
+−
−= −
−
![Page 15: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/15.jpg)
15
Newton Raphson Method
1( )f x′
( )f x
( )f x
3x4x
1( ) 1,2,3....( )
ii i
i
f xx x if x+ = − =′
x
2( )f x′
3( )f x′
2x 1x
![Page 16: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/16.jpg)
16
Newton Method: Properties
• Requires derivative of the function f’ = df/dx• Very fast convergence in most cases
(Quadratic convergence) !!• May not converge if the estimate is far off• May not converge if the derivative (slope) at
an estimate is close to zero• Can be used to find complex roots
![Page 17: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/17.jpg)
17
Newton : Non-convergent
![Page 18: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/18.jpg)
18
Convergence criteria for stopping iterative procedure
1
1
3 6
0
( )
a small number 10 10
i i
i ii
i
i
x x
x x xx
f x
or
ε
ε
ε
ε
−
−
− −
− ≤
−≤ ≠
≤
![Page 19: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/19.jpg)
19
Secant method• Similar to Newton’s method but different in
that the derivative f’ is approximated using two consecutive iterates
1
1
( ) ( )( ) i ii
i i
f x f xf xx x
−
−
−′ =−
( ) 1
1
( )( )( ) ( ) ( )
i i ii i i i
i i i
f x x xf x x x f xf x f x f x
−
−
⎡ ⎤−= − = − ⎢ ⎥′ −⎣ ⎦
2,3, 4,i = …• Needs two initial guesses
![Page 20: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/20.jpg)
20
Convergence of the Secant Method
1( )f x
( )f x
( )f x
3x4x
11
1
( ) 2,3,4....( ) ( )
i ii i i
i i
x xx x f x if x f x
−+
−
⎡ ⎤−= − =⎢ ⎥−⎣ ⎦
Exact root
x
2( )f x
3( )f x
Convergence of Secant method
2x 1x
![Page 21: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/21.jpg)
21
Secant : non-convergence
1x2x
( )f x
x
![Page 22: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/22.jpg)
22
Fixed Point Iteration
![Page 23: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/23.jpg)
23
Roots of Polynomials
![Page 24: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/24.jpg)
24
Roots of Polynomials2
0 1 2( ) nnf x a ax ax ax= + + + +
n = order of polynomiala’s = constant coefficients
For real coefficients
• An nth order equation will have n real or complex roots• If n is odd, at least one root is real• If complex roots exist, they exist in conjugate pairs, i.e
![Page 25: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/25.jpg)
25
Polynomial Deflation
• If a root of a polynomial has been found, it is desirable to factor the polynomial
( ) 1( ) ( )n nP x x r P x−= −
• Deflation or synthetic division
![Page 26: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/26.jpg)
26
![Page 27: ChE 374 Computational Methods in Engineering · 10 Bisection Algorithm Step 1 Choose lower x l and upper x u guesses for the root such that the function changes sign over the interval](https://reader034.vdocuments.us/reader034/viewer/2022042314/5f02ccfb7e708231d406136b/html5/thumbnails/27.jpg)
27
Roots of Polynomials
• Polynomials• Polynomial deflation• Muller’s Method• Bairstow’s Method