Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

ECE60

Numerical Methods with


Computing

Engr. Charmaine C. Paglinawan


Instructor
Roots of Non-Linear Equation
• Polynomial Equations / Function
• General Form
The roots depend on n
n a. even – roots will be real or complex
f ( x )   an x n b. odd – at least one root will be real
0 c. total number of roots that can obtained = n
f ( x)  x 3  3x 2  2 x  1

• Transcendental Equations / Function

 
f ( x)  sin x 2  1
1/ 2

f ( x)  log  3 x  2
There can be:
f ( x)  log  x  4 x 
3 2 a. infinite number of roots
b. finite number of roots
f ( x )  e 2 x  x 2 c no root at all

2
Techniques in evaluating the roots of non-linear
equation

1. Graphical Method

80

xx f(x)=x3-4x2+x-10
f(x)=x3-4x2+x-10 60
f(x) = x³ − 4 x² + x − 10

0 -10
10 -12
21 -16 40

32 -16
43 -6 20

54 20
65 68 0
0 1 2 3 4 5 6 7
6
-20

-40

3
Techniques in evaluating the roots of non-linear equation

2. Empirical Formula
Quadratic Equation

 b  b 2  4ac
x
Factorization 2a
Completing the square
-limited to polynomial functions
Synthetic Division

4
3. Iterative Method
• Iterative Formula (recursive)
• Terminating Condition
• If by chance, the computed value is the actual root
• If a specified no. of iteration is given
• If the error criterion is met (best)

5
Bracketing Techniques -1
1. Interhalving (bisection) Method
Graphical Depiction Initial Values
x0 ; f ( x0 ) /  f ( x0 )
25 Bracket Values
20
f(x) = x³ − 7 x² + 12 x − 16
x0 ; f ( x1 ) /  f ( x1 )
15
10 Bracketing Condition
5
0
X0 X2 X1 f ( x0 )  f ( x1 )  0
0 1 2 3 4 5 6 7 8
-5
-10
Substitute x2 to the given function f(x) to obtain
-15
-20 f(x2) if f(x2) > 0 then replace “+” function limit
value of x with x2 but if f(x2) < 0, then replace
Iterative Formula:
“-” function limit value of x with x2. The
x0  x1 x1  x0 process is repeated until the terminating
x2  or x2   x0
2 2 condition is met.

midpoint formula
6
Example
• Determine a root from the function using Bisection Method.
Terminate if EA ≤ 0.0001
f(x)=x3-4x2+x-10

x -4 -3 -2 -1 0 1 2 3 4 5
y -142 -76 -36 -16 -10 -12 -16 -16 -6 20
root

1. Tabulate values of x
x0  4; f ( x0 )  6
x0  5; f ( x1 )  20 initial values

45
x2   4.5
2
f ( x2 )   4.5  4 4.5   4.5  10  4.6250
3 2

replace x1 with x2 7
x0  4; f ( x0 )  6 x0  4.25; f ( x0 )  1.2344 initial values
initial values
x1  4.5; f ( x1 )  4.625 x1  4.375; f ( x1 )  1.5527
4  4. 5 4.25  4.375
x2   4.25 x2   4.3125
2 2
replace x0 with x2 replace x1 with x2
f ( x)  1.2344 f ( x)  0.1243

x0  4.25; f ( x0 )  1.2344 x0  4.25; f ( x0 )  1.2344 initial values


initial values
x1  4.5; f ( x1 )  4.625 x1  4.3125; f ( x1 )  0.1243
4.25  4.5 4.25  4.3125
x2   4.375 x2   4.2813
2 replace x1 with x2 2
f ( x)  1.5527 f ( x)  0.5626 replace x0 with x2

8
x0 x2 x1 f(x2) Termination Condition
4.0000 4.5000 5.0000 4.6250 1. If by any choice the computed
4.0000 4.2500 4.5000 -1.2344 midpoint x2 is the actual root of
4.2500 4.3750 4.5000 1.5527 the function, i.e. x2
4.2500 4.3125 4.3750 0.1243 is substituted to the function f(x2)
4.2500 4.2813 4.3125 -0.5637 = 0.
4.2813 4.2969 4.3125 -0.2219 2. If a definite number of iteration is
4.2969 4.3047 4.3125 -0.0494 satisfied.
4.3047 4.3086 4.3125 0.0373 3. If the applied error criterion is
4.3047 4.3066 4.3086 -0.0060 satisfied using (Approximate
Relative Error) formula.
4.3066 4.3076 4.3086 0.0156
4.3066 4.3071 4.3076 0.0048
4.3066 4.3069 4.3071 -0.0006
f(x)=x3-4x2+x-10
4.3069 4.3070 4.3071 0.0021
4.3069 4.3069 4.3070 0.0007
9
• Choose lower x0 and upper x1 guesses for the root such that
the function changes sign over the interval
• Find x2 using midpoint formula
• Make the following evaluations to determine in which the
subinterval root lies:
• If f(x)<0, set “-” to x2
• If f(x)>0, set “+” to x2
• If f(x)=0, root is equal to x2, terminate the computation

10
Bracketing Techniques -2

2. Regula-Falsi Method (False Position)


Graphical Depiction
25
f(x) = x³ − 7 x² + 12 x − 16
20 f(x1) x0   f ( x0 ) /  f ( x0 ) initial bracket values
15

10 x1   f ( x1 ) /  f ( x1 ) of x
5
x2
0
0 1 2 3 4 5 6 7 8
-5 x0 x1
-10 f(x0)
-15

-20

11
• Bracketing Condition f(x1)

f ( x0 )  f ( x1 )  0
• Iterative Formula x2 x1

• Using similar ∆’s x0


f(x0)

x1  x2 x1  x0
 x2  x0 x1  x0
f ( x1 ) f ( x1 )  f ( x0 ) 
 f ( x0 ) f ( x1 )  f ( x0 )
 x1  x0 
x1  x2  f ( x1 )    x1  x0 
 f ( x )  f ( x )
0  x2  x0   f ( x0 ) 
1 
 f ( x )  f ( x )
0 
 x1  x0  1

x2  x1  f ( x1 )   or  x1  x0 
 f ( x )  f ( x )
0  x2  x0  f ( x0 ) 
1 
 f ( x1 )  f ( x )
0 

12
a. Substitute x2 to the function f(x) to obtain f(x2).
• If f(x2)>0 then replace “+” function limit value x with x2.
• If f(x2)<0 then replace “i” function limit value x with x2.

• The process is repeated until the terminating condition is satisfied.

13
Example-Regula Falsi
Determinethe root from the function using Regula-Falsi.
Terminate if EA ≤ 0.0001
f(x)=x3-4x2+x-10
 x1  x0 
x2  x1  f ( x1 )  
Tabulate values of x  f ( x1 )  f ( x )
0 

x 0 1 2 3 4 5  x1  x0 
y -10 -12 -16 -16 -6 20 x2  x0  f ( x0 )  
 f ( x1 )  f ( x )
0 

x0  4  f ( x0 )  6
initial values
x1  5  f ( x1 )  20
 54 
x2  5  20   4.2308
 20  6 
f ( x2 )   4.2308  4 4.2308  4.2308  10  1.6380
3 2

replace x0 with x2

14
x0  4.2308  f ( x0 )  1.6380
initial values
x1  5  f ( x1 )  20
 5  4.3208 
x2  5  20   4.2890
 20  1.6380 
f ( x2 )   4.2890   4 4.2890   4.2890  10  0.3947
3 2

replace x0 with x2

x0  4.2890  f ( x0 )  0.3947
initial values
x1  5  f ( x1 )  20
 5  4.2890 
x2  5  20    4.3028
 20  0.3947 
f ( x2 )   4.3028  44.30282  4.3028  10  0.0911
3

replace x0 with x2
15
f(x)=x3-4x2+x-10

xx00 XX22 XX11 f(x


f(x0)0) f(x
f(x2)2) f(f(x1x1))
4.0000
4.0000 4.2308
4.2308 55 -6.0000
-6.0000 -1.6386
-1.6386 2020
4.2308 4.2890 5 -1.6386 -0.3943 20
4.2890 4.3028 5 -0.3943 -0.0919 20
4.3028 4.3060 5 -0.0919 -0.0213 20
4.3060 4.3067 5 -0.0213 -0.0049 20
4.3067 4.3069 5 -0.0049 -0.0011 20
4.3069 4.3069 5 -0.0011 -0.0003 20

 x1  x0 
x2  x1  f ( x1 )  
 f ( x1 )  f ( x )
0 

 x1  x0 
x2  x0  f ( x0 )  
 f ( x1 )  f ( x )
0 

16
Practical Example - Graphical
Determine the drag coefficient c needed for a parachutist of mass m=68.1kg to
have a velocity of 40m/s after free-falling for time t=10s. Note: The acceleration
due to gravity is 9.8m/s2.

Solution:

v t  
gm
c

1  e  c m  t 
f  c 
gm
c

1  e  c m  t  v
9.8 68.1
f  c 
c
 
1  e  c 68.110  40

f  c 
667.38
c
 
1  e 0.146843c  40

17
c f(c)
1 51.14440346 Chart Title
2 44.92058624
3 39.26342879 60
4 34.11488938 50
5 29.42326769 40
6 25.14248313
30
7 21.23143759
8 17.65345264 20
9 14.37577215 10
10 11.36912276 0
0 2 4 6 8 10 12 14 16 18
11 8.607325114 -10
12 6.066949963 root
13 3.727013868
14 1.568709726 By visual inspection and rough estimate, c=14.75
15 -0.424831887
Substituting to:

f  c 
667.38
c
 
1  e 0.146843c  40
f(c)=0.059 which is approximately equal to zero

18
Practical Example - Bisection
x0 X2 X1 f(x2)
15.0000 14.5000 14.0000 0.5523 cont
15.0000 14.7500 14.5000 0.0590 cont
15.0000 14.8750 14.7500 -0.1841 cont
14.8750 14.8125 14.7500 -0.0629 cont c=14.7802
14.8125 14.7813 14.7500 -0.0020 cont
14.7813 14.7656 14.7500 0.0284 cont
14.7813 14.7734 14.7656 0.0132 cont
14.7813 14.7773 14.7734 0.0056 cont
14.7813 14.7793 14.7773 0.0018 cont
14.7813 14.7803 14.7793 -0.0001 cont
14.7803 14.7798 14.7793 0.0008 cont
14.7803 14.7800 14.7798 0.0003 cont
14.7803 14.7802 14.7800 0.0001 cont
14.7803 14.7802 14.7802 0.0000 stop

19
Practical Example – Regula Falsi

x0 X2 X1 f(x0) f(x2) f(x1)


15.0000 14.7869 14.0000 -0.4248 -0.0130 1.5687 continue
14.7869 14.7804 14.0000 -0.0130 -0.0004 1.5687 continue
14.7804 14.7802 14.0000 -0.0004 0.0000 1.5687 stop
14.7802 14.7802 14.0000 0.0000 0.0000 1.5687

c=14.7802

20
Homework
1. Determine the MSE (Mac Laurin Series
Expansion) of f(x)=sin(x).
2. Determine the TSE (Taylor Series Expansion) of
the function f(x) = cos(x) near x=π/2
3. Use the bisection method to find solutions
accurate to within 0.0001 for x3-7x2+14x-6.
4. Use regula-falsi method for problem 3.

21
HW Solution
• Determine the MSE (Mac Laurin Series Expansion) of
f(x)=sin(x).
f  x   sin  x   0
f V  x   cos x   1
f '  x   cos x   1
f VI  x    sin  x   0
f ' '  x    sin  x   0
f VII  x    cos x   1
f ' ' '  x    cos x   1
f IV  x   sin  x   0

Recall:
f ' (a) f ' ' (a) f ' ' ' (a) f IV (a)
f ( x)  f (a )   x  a   x  a 
2
 x  a 
3
 x  a  4  ....  f n (a)  x  a  n
1! 2! 3! 4! n!

f ( x)  0 
1
 x  0  0  x  0 2   1  x  0 3  0  x  0 4  ....  f n (a)  x  0 n
1! 2! 3! 4! n!

x3 x5 x7 xn
f ( x)  x     .... 
3! 5! 7! n!
22
• Determine the TSE (Taylor Series Expansion) of the function f(x) =
cos(x) near x=π/2
f  x   cos  2  0
f '  x    sin   2  1 f V  x    sin   2  1
f ' '  x    cos  2  0 f VI  x    cos  2  0
f '''  x   sin   2  1 f VII  x   sin   2   1
f IV  x   cos  2  0

Recall:
f IV (a )
f ( x)  f (a ) 
f ' (a)
 x  a  f ' ' (a )
 x  a 
2 f ' ' ' (a )
 x  a 
3
 x  a  4  ....  f n (a)  x  a  n
1! 2! 3! 4! n!
1
f ( x)  0   x     0  1  x    3   1  x    5  1  x    7 ....  f n (a)  x  a  n
1! 3! 5! 7! n!
3 5 7
1   1    1    1    f (a )
f ( x)    x     x     x     x   ....  n  x  a n
1!  2  3!  2 5!  2  7!  2 n!

3 5 7 n
       
x  x  x  x 
  2  2  2 2
f ( x )   x       ....  
 2 3! 5! 7! n!

23
• Use the bisection method to find solutions accurate to within 0.0001 for
x3-7x2+14x-6

x0 X2 X1 f(x2)
0.0000 0.5000 1.0000 -0.6250 root  0.5858
0.5000 0.7500 1.0000 0.9844
0.5000 0.6250 0.7500 0.2598
0.5000 0.5625 0.6250 -0.1619
0.5625 0.5938 0.6250 0.0540
0.5625 0.5781 0.5938 -0.0526
0.5781 0.5859 0.5938 0.0010
0.5781 0.5820 0.5859 -0.0257
0.5820 0.5840 0.5859 -0.0123
0.5840 0.5850 0.5859 -0.0056
0.5850 0.5854 0.5859 -0.0023
0.5854 0.5857 0.5859 -0.0006
0.5857 0.5858 0.5859 0.0002

24
• Use the bisection method to find solutions accurate to within 0.0001 for
x3-7x2+14x-6

x0 x2 x1 f(x0) f(x2) f(x1)


0.0000 0.7500 1.0000 -6.0000 0.9844 2.0000
0.0000 0.6443 0.7500 -6.0000 0.3818 0.9844
0.0000 0.6058 0.6443 -6.0000 0.1346 0.3818
0.0000 0.5925 0.6058 -6.0000 0.0456 0.1346
0.0000 0.5880 0.5925 -6.0000 0.0151 0.0456
0.0000 0.5865 0.5880 -6.0000 0.0049 0.0151
0.0000 0.5860 0.5865 -6.0000 0.0015 0.0049
0.0000 0.5859 0.5860 -6.0000 0.0008 0.0015
0.0000 0.5858 0.5859 -6.0000 0.0001 0.0008

25

You might also like