Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
1
ChE 374Computational Methods in Engineering
Solution of Non-Linear Equations
2
Roots of Equations• Many engineering problems require the
determination of the values of the variable xwhich satisfies the non-linear equation
( ) 0f x =
3
Non-Linear Eqn.
• Bracketing methods– Bisection– Regula falsi (False position)
– Graphical methods to provide insight– Error formulation
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
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.
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
−= − −
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.
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
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
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
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 !!!
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.
13
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−
+−
−= −
−
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
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
17
Newton : Non-convergent
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
ε
ε
ε
ε
−
−
− −
− ≤
−≤ ≠
≤
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
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
21
Secant : non-convergence
1x2x
( )f x
x
22
Fixed Point Iteration
23
Roots of Polynomials
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
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
26
27
Roots of Polynomials
• Polynomials• Polynomial deflation• Muller’s Method• Bairstow’s Method