Download - Chapter 3

Transcript
Page 1: Chapter 3

CHAPTER 3

NUMERICAL METHOD

Page 2: Chapter 3

3.1 The Trapezium Rule

• OBJECTIVES : The objectives of this lesson

are to enable students to

• a) derive the trapezium rule by dividing the area

represented by dx into n ( n 7 )

trapezium each with width h.

• b) use the trapezium rule to approximate

b

a

)x(f

b

a

.dx)x(f

Page 3: Chapter 3

Introduction

• What happens when a mathematical function cannot be

integrated ? In these cases a numerical method can be used

to find an approximate value for the integral

• As the definite integral is a number which represents the

area between y = f (x) , the x-axis and the lines

• x = a and x =b .

b

a

dxxf .)(

Page 4: Chapter 3

• Therefore , even if cannot be

found, approximate value for can be

found by evaluating the appropriate area using

another method. The two common methods are the

trapezium rule and Simpson’s rule.

• However, here we will discuss the trapezium rule as

requested by our syllabus.

b

a

.dx)x(f

b

a

.dx)x(f

Page 5: Chapter 3

The trapezium rule

• This method divides the area A under the curve

• y = f(x) is into n vertical strips. The width of each

strip is h.

• The area under the curve sum of areas of n

trapezia.

• Note : approximately equal to

Page 6: Chapter 3
Page 7: Chapter 3

Let y0, y1 , y2, …., yn be the values of the function f (x) . These correspond to the (n+1) ordinates x0 , x1, x2, ……..,xn respectively.

Page 8: Chapter 3

• Using

2

1 Area of trapezium = ( width x sum of parallel sides )

The area of the first trapezium is

A1 = 2

1 h ( y0 + y1 )

The areas of the second and the third trapezia are then

A2 = 2

1 h ( y1 + y 2 )

A3 = 2

1 h ( y 2 + y 3 )

Page 9: Chapter 3

• Verify that if this process is continued then

A n-1 = h ( y n-2 + y n-1 )

A n = h ( y n-1 + y n )

• Now add all of these separate areas together. The approximate value of A is given by

• A A1 + A2 + A3 + … + A n-1 + A n

• h ( y 0 + y1 ) + h ( y1 + y 2 ) + h ( y2 + y

3 ) + … + h ( y n-2 + y n-1 ) + h ( y n-1 + y n )

• h ( y 0 + 2y1 +2y2 +2y3 +… + 2yn-1 + yn )

2

1

2

1

2

1

2

1

2

1

2

1

2

12

1

Page 10: Chapter 3

• This method of approximating the area under a curve by n trapezia of equal width h is called the trapezium rule, and the result can be summarized as :

• dx h y 0 + y n + 2 ( y1

+ y2 + … + y n-1 )

• where h = and yr = f ( xr )

b

a

)x(f2

1

n

ab

Page 11: Chapter 3

• Example 1

• Evaluate dx using 5 strips by the

trapezium rule.

• Notation: Working must have 4 or more decimal

places.

6

1ln x

Solution

The integration interval ( b- a ) = 6 –1 = 5 unitsSo h =

n

ab =

5

5 = 1

Page 12: Chapter 3

The value of x at which y is calculated are :1, 2, 3, 4, 5, 6Tabulating the results as follows help the final calculation :

X y First and last ordinates Remaining ordinates

123456

y0

y1

y2

y3

y4

y5

0

1.792

0.6931.0991.3861.609

Totals 1.792 4.787

Page 13: Chapter 3

6

1ln x

2

h dx ( y0 + y5) + 2 ( y1 +… +y4 )

=

2

1 1.792 + 2 ( 4.787 )

= 5.683

Page 14: Chapter 3

Example 2

• Use the trapezium rule, with five

ordinates, to evaluate e x ² dx .

• Correct your answer to three decimal

places.

8.0

0

Solution:

For five ordinates, ( yo , y1 , y2 , y3 , y4 ) evenly spaced in the

range

0 ≤ x ≤ 0.8 , we need to divide this range into four equal parts

The integration interval ( b- a ) = 0.8 - 0 = 0.8 units

Page 15: Chapter 3

• So, h = = = 0.2

• The value of x at which y is calculated are :

• 0 , 0.2, 0.4, 0.6 , 0.8

x Y First and last ordinates

Remaining ordinates

00.20.40.60.8

y0

y1

y2

y3

y4

1

1.8965

1.04081.17351.4333

Totals 2.8965 3.6476

n

ab 4

8.0

Page 16: Chapter 3

• e x ² dx ≈ ( y0 + y4 ) + 2 ( y1 +… +y 3 ) = 2.8965 + 2 ( 3.6476 ) = 1.0192

= 1.019 ( three decimal

places )

8.0

0 2

h

2

2.0

Page 17: Chapter 3

3.2 Solutions of non – linear equations

• OBJECTIVE : The objective of this lesson is to enable students to understand the method of finding roots using the iteration method by writing:

• f(x) = 0 in the form of x = g(x). The iteration scheme is xn+1 = g(xn) , n = 1,2,3….. The method fails when g(x) > 1 in the neighborhood of the roots of the equation.

Page 18: Chapter 3

Introduction

• Many equations cannot be solved exactly, but various methods of finding approximate numerical solutions exist.

• The most commonly used methods have two main parts:

• (a) finding an initial approximate value

• (b) improving this value by an iterative process

Page 19: Chapter 3

• Initial Values:• The initial value of the roots of f(x) = 0 can be

located approximately by either a graphical or an algebraic method.

• Graphical Method:• Either

(a) Plot ( or sketch ) the graph of y = f(x). The real roots are the points where the curve

cuts the x axis.• Or

(b) Rewrite f(x) = 0 in the form F(x) = G(x).Plot ( or sketch ) y =F(x) and y = G(x). The real roots are at the points where these graphs intersect.

Page 20: Chapter 3

Example 1

• Find the approximate value of the equation ln x + x - 4 = 0 by using the graphical method.

y = 4-x

y

0 1 2 3 4 the intersection is at x 2.9

x

y

y = ln x

Page 21: Chapter 3

• Algebraic Method

• Find two values a and b such that f(a) and

f(b) have different signs.

• At least one root must lie between a and b if

f(x) is continuous.

• If more than one root is suspected between

a and b, sketch a graph of y = f(x).

Page 22: Chapter 3

• Iterative Method

• All iterative methods follow the same basic pattern. A sequence of approximations

• x1, x2 , x3 , x4 ….. is found , each one closer to

the root of f(x)=0.

• Each approximation is found from the one before it using a specified method.

• The process is continued until the required accuracy is reached.

• Two methods we have to discuss are Iteration Method and Newton-Raphson Method.

Page 23: Chapter 3

• Iteration Method

• Rewrite the equation f(x) = 0 in the form x = g(x).• If the initial approximation is x1 , then calculate

• x2 = g(x1)• x3 = g(x2)• x4 = g(x3)

and so on …..

• This method fails if g (x) > 1 near the root. • So, the value of g(x1) should be < 1.

Page 24: Chapter 3

Example 2

• Using the iteration method, find the solution of f(x) = x + ex near x = -0.6 to three decimal places.

Solution

Iteration method

Write the given equation as x = - ex x = g(x)g (x) = - ex

g(x) = - ex, g(-0.6) = -e-0.6 = 0.5488 ( < 1 )

Page 25: Chapter 3

x1 = -0.6

x2 = -e-0.6 = -0.5488

x3 = -e-0.5488 = -0.5453

x4 = -e-0.5453 = -0.5797

x5 = -e-0.5797 = -0.5601

x6 = -e-0.5601 = -0.5712

x7 = -e-0.5712 = -0.5648

x8 = -e-0.5648 = -0.5684

x9 = -e-0.5684 = -0.5664

x10 = -e-0.5664= -0.5676

x11 = -e-0.5676 = -0.5668

• x12 = -e-0.5668 = -0.5673 the required solution is x = - 0.567

( three decimal places )#

Page 26: Chapter 3

Example 3

• Show that the equation has a

root between 0.2 and 0.3.

• Taking 0.2 as first approximation find the

root of the equation ,giving your answer to

three significant figures by using the

iteration method.

0412 x

x

Page 27: Chapter 3

• Solution

• f(x) = x2 - + 4

• f(0.2) =

• f(0.3) = = 0.756 ( positive )

• therefore f(x) has a root between x = 0.2 and x = 0.3.

x

1

42.0

1)2.0( 2 = - 0.96 ( negative )

43.0

1)3.0( 2

Page 28: Chapter 3

0412 x

x 41 2 xx

4

12

x

x

g(x) = 12

2)4(

4

1

xx

g'(x) = )4()4( 222 xdx

dx

= )2()4( 22 xx =

22 )4(

2

x

x

g'(0.2) =

4)2.0(

)2.0(2

22

= 0.0245 ( <1 ) therefore, g(x) = iteration function

Page 29: Chapter 3

• x = g(x)

• x1 = 0.2

• x2 = = 0.2475

• x3 = = 0.2462

• x4 = = 0.2463

the required solution is 0.246 (3 sig. figs)

4)2.0(

12

4)2475.0(

12

4)2462.0(

12

x3 and x

4 have same value when

round up to three sig.figs. Hence

we should stop the working.

Page 30: Chapter 3

3.3 Solutions of non-linear equations

• OBJECTIVE : The objective of this lesson

is to enable students to

• find the root by the Newton-Raphson

method using the formula

• xn+1 = xn - , n = 1,2,3, …)('

)(

n

n

xf

xf

Page 31: Chapter 3

Newton-Raphson Method

• If x1 is an approximation to root of f(x) =0 , then a better

approximation x2 is given by

.

• Repeat this process as required .

)(xf

)f(xxx

1

112

)(x f

)f(xxx

n

nn1 n

• The iteration is stop when m

nn xx 105.01

Page 32: Chapter 3

Example 1

• Using the Newton-Raphson Method, find

the solution of f(x) = x + ex near x = - 0.5

to three decimal places.

• Solution

• Let f(x) = x + ex

• So f (x) = 1 + ex

Page 33: Chapter 3

• x1 = -0.5

• = =

= -0.5663

• = = - 0.5671

• = = - 0.5671

• The required solution is x = -0.567

( three decimal places ) # .

)(x f

)f(xxx

1

112

(-0.5) f

f(-0.5)0.5-

)e (1

)e(-0.50.5-

0.5-

0.5-

3x(-0.5663) f

f(-0.5663)0.5663-

4x(-0.5671) f

f(-0.5671)0.5671-

Page 34: Chapter 3

Example 1

Sketch the graph of y = ex and y = 2 – x

where x< 2, on the same axes.

Get the first approximation, x0 for the equation

ex = 2 – x where 0 < xo < 1.

Hence, by using Newton-Raphson method ,

solve the equation of e-x = x2

1

for x < 2 to three decimal places.

Page 35: Chapter 3

2

1

Solution :

y

y = ex

1 x

y = 2 - x

00.4

Page 36: Chapter 3

• Newton-Raphson method:

• e-x = = 2 – x

• ex = 2 – x ex – 2 + x = 0

• f(x) = ex – 2 + x f ’(x) = ex + 1

• x1 = first approximation = 0.4 ( from graph )

x2

1xe

1

Page 37: Chapter 3

)('

)(1

nxf

nxfnxnx

)4.0('

)4.0(4.02 f

fx 0.4 - [

1

4.024.0

4.0

e

e] = = 0.4043

)4043.0('

)4043.0(40.03 f

fx = 0.4043 - [

1

4043.024043.0

4043.0

e

e] = 0.4433

)4433.0('

)4433.0(4433.04 f

fx = 0.4433 - [

1

4433.024433.0

4433.0

e

e] = 0.4428

)4428.0('

)4428.0(4428.05 f

fx = 0.4428 - [

1

4428.024428.0

4428.0

e

e] = 0.4428

The required solution is 0.443 ( three decimal places ).

Page 38: Chapter 3

EXERCISES

• 1.)By taking 0.2 as first approximation find the root of the equation ,giving your answer to three

significant figures by using the Newton Raphson method.

•(Ans : 0.246)

0412 x

x

Page 39: Chapter 3

• 2.) Show that the equations 2sin x – x = 0 has

a root between x = 1(radian) and x= 2 (radian).

Find the root of the equation by using

i) iteration method

ii) Newton Raphson method

Giving your answer to two decimal places.