Transcript ch-1

NUMERICAL METHODS WITH C++ PROGRAMMING

By Dr. RM. SOMASUNDARAM Dr. RM.CHANDRASEKARAN

1

Chapter 1

ALGEBRAIC AND TRANSCENDENTAL EQUATIONS

2

NUMERICAL METHODS WITH C++ PROGRAMMING

By Dr. RM. SOMASUNDARAM Dr. RM.CHANDRASEKARAN

3

PRELIMINARIES

     

Bisection Method Regula Falsi Method Newton Raphson Method Successive Approximation Method Secant Method Graffi Root Squaring Method

4

PRELIMINARIES

Solution of equation f (x) = 0 A number  (real or complex) is a root of the equation f (x) =0 if f (  ) = 0.

Location of the root

Theorem

If f(x) is a continuous function in the closed interval [a, b] and f (a). f (b) < 0 [i.e. f (a) and f (b) are of opposite signs] then the equation f (x) = 0 has at least one real root in the open interval (a, b).

5

BISECTION METHOD

 Locate the interval (a, b) in which root lies.

 Bisect the interval (a, b).

 Choose the half interval in which the root lies.

 Bisect the half interval.

 Repeat the process until the root converges.

6

Example

 Find the root of the equation x 3 bisection method.

– x –1 = 0 by 

Solution

● ● f(1). f(2) < 0 Hence a root lies in the interval (1,2).

Bisecting , we get two half intervals (1,1.5) and (1.5,2).

The root lies in (1,1.5).

● Repeat the process until the root converges to

1.3247

.

7

y

Regula Falsi Method

x i -1 x i+2 x i x i+1 x 8

REGULA FALSI METHOD

 Locate the interval (a, b) in which the root lies.

 First Approximation to the root

X

0 =  Locate the next interval (a, X 0 ) or ( X 0, b ) in which root lies.

 Repeat the process until the root converges.

9

Example

 Find the real root of x 3 – 9x + 1 = 0.

Solution

● A root lies between 2 and 3.

● Applying Regula Falsi Method iteratively, the root converges to

2.9428

after

4

iterations .

10

SUCCESSIVE APPROXIMATION METHOD

 Rewrite the equation f(x) = 0 in the form x =  (x).

 Choose the initial approximation X 0  x 1 =  (x 0 ), x 2 =  (x 1 ),…,  The sequence of approximations converges to a root if |  ' (x) | < 1 in the interval containing the root  . 11

Example

 Solve cos x + 3 = 2x 

Solution

● ● Write x = (cos x + 3) 2  ’ (x) = (-½) sin x and f |  ’ (x) | < 1 in (0, π/2 ).

● ● Choose x 0 = π/2 = 1.5708.

Successive approximation will yield the root as 12 th iteration.

1.5236

in 12

NEWTON RAPHSON METHOD

 Locate the interval (a, b).

 Choose a or b which is nearer to the root as the first approximation x 0 to the root. Next approximation x = x 1 0 f(x ) 0 0  Repeat the process until the root converges.

13

Example

 Solve e x – 1 = 2x  Solution ● The root is near 1. ● Take x 1 = 1. ● x 2 = x 1 – f ( x 1 ) f ' ( x 1 ) = 1.3922

Successive iterations will yield the root

1.2564.

14

SECANT METHOD

 In Newton Raphson Method we have to evaluate f'(x) at every iteration.

 In this method f'(x) is approximated by the formula  f'(x n ) ~ f(x n ) f(x n 1 ) x n x n 1  Thus, x n+1 = x n 1 f(x f ( x n n ) x n ) f (x f(x n 1 ) n 1 ) 15

Example

 Find a root of x 3 – 4x + 1 = 0 using secant method.

Solution

● The root lies in (0,1) as f(0) = 1 , f(1) = –2.

● Successive application of secant formula the root

0.2541.

yields 16

Comparison

Method Iterative formula Bisection

x n+1 =

x n

+ 2

x n

1

False position

x n+1 = n n n-1 n-1

Order of convergence

Gain of one bit per iteration

Evaluation of functions for iteration

1 1 1

Reliability of convergence

Guaranteed convergence Guaranteed convergence

Successive approximation x n =

(x n-1 ) Newton raphson Secant

x n+1 x n+1 = x n 1 2 1.62 1 2 1 Easy to programme.No guaranteed convergence Convergence depends on stating value. Fast convergence No guarantee if not near the root 17

GRAEFFES’ ROOT SQUARING METHOD

  This is a direct method. This method is used to find all the roots of a polynomial equation with real coefficients.  For any nth degree polynomial equation the following results will apply.

Results

● ● ● ● There will be n roots for an nth degree polynomial equation.

There will be at least one real root if n is odd.

Complex roots occur only in pairs. Descartes' rule of signs will be true.

18

Descartes’ Rule of Signs

 Number of positive roots of f(x) = 0 is equal to the number of sign changes of the coefficients or is less than this number by an even integer.

 The number of negative roots of changes in f(–x).

f(x) = 0 is obtained by considering the number of sign 19

Root Squaring

Let f(x) = a 0 x n + a 1 x n-1 + a 2 x n-2 + L + a n = 0 Then f(x) f( –x) = a 0 2 x 2n + L + (-1) n a n 2 = 0.

– (a 1 2 – 2a 0 a 2 ) x 2n-2 + (a 2 2 – 2a 1 a 3 + 2a 0 a 4 )x 2n-4 Substitute y = -x 2 the equation reduces to y n + C 1 where C y 1 n-1 = a + C 2 1 2 y n-2 + L + C n-1 – 2a 0 a 2 , C 2 = a 2 2 y + C n – 2a 1 a = 0 3 + 2a 0 a 4 , … C n = a n 2 The derived polynomial is of the same degree as the original polynomial and its roots are – x 1 2 , – x 2 2 , …, –x n 2 where x 1 , x 2 are the roots of the original polynomial. , …, x n If we apply this root squaring process repeatedly it will yield successive derived polynomial having roots which are negative of successively higher even powers (2

k

after

k

squaring) of the roots of original polynomial.

20

Root Squaring

After y x n 1 m + b

k

1 , -x y 2 squaring n-1 m , + b 2 y let the reduced polynomial be n-2 …, - x n m + L + b n = 0.Then the roots of this polynomial are: where m = 2 k .

Let R i = -x we get |R 1 i 2 , i = 1, 2, | > > |R 2 …, n. Assuming |x 1 | > |x 2 | > | > > |R 3 | … >> |R n | L > |x n | Hence – b 1 b 2 – b 3 (-1) n b n = = =    R R R i i i = R 1 R 2 = R R j 1 ~ R R j R k … R n 1 R 2 ~ R 1 R 2 R 3 We get R i = Fix sign using – b i i = 1, 2, …, n and |R i | b i 1 Descartes’ rule and actual substituition.

= | b i | | b i 1 | 21

Example

Solve x 3 – 2x 2 – 5x + 6 = 0 using Root squaring method

Solution k 2 k Coefficients First squaring

0 1 2 1 2 4

a 0

1 1 1 1 1

a 1

-2 4 10 14 196-98 98

a 2

-5 25 24 49 2401-1008 1393

Second squaring Third squaring 3 8

1

1

9604-2786

6818 a 3

6 36 36 1296 1296 1940449- 254016 1679616

1686433 1679616

22

Squaring

|x 1 | = |x 2 | = |b 1 | 1/8 = b 2 b 1 1 / 8 = (6818) 1/8 = 3.0144 1686433 1 / 8 = 1.9914 6818 |x 3 | = b 3 1 / 8 2 = 1679616 1 / 8 = 0.9995 1686433 By Descartes’ rule of signs and by actual substitution, we get the roots as 3.01443, -1.9914, 0.9995

.

The exact roots are 3, -2, 1. 23