0% found this document useful (0 votes)
26 views

Week 04 - Lecture Notes

Uploaded by

2312233
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Week 04 - Lecture Notes

Uploaded by

2312233
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Numerical Computing

Week 04

by
Dr. Sajjad A. Ghauri / Dr. Kamran Suhaib
The Secant Method

ˆ Modification of Newton Raphson method.

ˆ Replace f ′ (xn ) with


f (xn ) − f (xn−1 )
f ′ (xn ) =
xn − xn−1

As the n + 1 term of Newton Raphson method is


f (xn )
xn+1 =xn −
f ′ (xn )
So, we have
f (xn )
xn+1 =xn − f (xn )−f (xn−1 )
xn −xn−1
(xn − xn−1 )f (xn )
xn+1 =xn −
f (xn ) − f (xn−1 )
xn (f (xn ) − f (xn−1 ) − (xn − xn−1 )f (xn )
xn+1 =
f (xn ) − f (xn−1 )
xn f (xn ) − xn f (xn−1 ) − xn f (xn ) + xn−1 f (xn )
xn+1 =
f (xn ) − f (xn−1 )
xn−1 f (xn ) − xn f (xn−1 )
xn+1 =
f (xn ) − f (xn−1 )

ˆ We required two initial starting values.

Secant Method Advantages and Disadvantages: The secant method has


the following advantages.

ˆ It converges quicker than a linear rate, making it more convergent than the bisection
method.

ˆ It does not necessitate the usage of the function’s derivative, which is not available in
a number of applications.

ˆ Unlike Newton’s technique, which requires two function evaluations in every iteration,
it only requires one.

1
The secant method has the following drawbacks.

ˆ The secant method may not converge.

ˆ The computed iterates have no guaranteed error bounds.

ˆ If f0 (α) = 0, it is likely to be challenging. This means that when x = α, the x-axis is


tangent to the graph of y = f (x).

Newton’s approach is more easily generalized to new ways for solving non-linear simultaneous
systems of equations.

Example 1: Find the root of the following equation by the secant method up-to 4 dp.

x3 − 2x − 5 =0

Solution: Here f (x) = x3 − 2x − 5.

f (2) =(2)3 − 2(2) − 5 = −1,

f (3) =(3)3 − 2(3) − 5 = −1 = 16.

This implies that root lies between 2 and 3. So x0 = 2 and x1 = 3, and as

xn−1 f (xn ) − xn f (xn−1 )


xn+1 = (1)
f (xn ) − f (xn−1 )

1st iteration: By putting n=1 in (1), we have

x1−1 f (x1 ) − x1 f (x1−1 )


x1+1 =
f (x1 ) − f (x1−1 )
x0 f (x1 ) − x1 f (x0 )
x2 =
f (x1 ) − f (x0 )

Now by substituting x0 = 2 and x1 = 3, we get

2 × 16 − 3 × (−1)
x2 =
16 − (−1)
x2 =2.0588

2
2nd iteration: When n = 2, we have

x3 =2.0812

3rd iteration: When n = 3, we have

x3 =2.0948

Approximate root of the equation x3 − 2x − 5 = 0 using the secant method is 2.0948 (correct
to 4 dp) (After 3 iterations).

Example 2: Find the root of 2 cosh(x) sin(x) = 1 using secant method correct upto 4
dps by taking initial values as 0.4 and 0.5

Solution: Here f (x) = 2 cosh(x) sin(x) − 1. As, the root lies between 0.4 and 0.5. So
x0 = 0.4 and x1 = 0.5.

Note: sin(x) will be calculated in Radian mode. For Degree mode, select the option in
Trigonometry Function Mode.

f (x0 ) = f (0.4) = −0.158,

f (x1 ) = f (0.5) = 0.0812.

xn−1 f (xn ) − xn f (xn−1 )


xn+1 = (2)
f (xn ) − f (xn−1 )

1st iteration: By putting n=1 in (2), we have

x1−1 f (x1 ) − x1 f (x1−1 )


x1+1 =
f (x1 ) − f (x1−1 )
x0 f (x1 ) − x1 f (x0 )
x2 =
f (x1 ) − f (x0 )

Now by substituting x0 = 2, x1 = 3, f (x0 ) = −0.158 and f (x1 ) = 0.0812 we get

x2 =0.466

3
Now, f (x2 ) = f (0.466) = 2 cosh(0.466) sin(0.466) − 1 = −0.0019

2nd iteration: When n = 2, we have

x3 =0.4668

Approximate root of the equation 2 cosh(x) sin(x) − 1 using the secant method is 0.4668
(correct to 4 dp) (After 2 iterations).

The False Position Method

ˆ Bisection method is a perfectly valid technique for finding the roots. Its — approach
is relatively insufficient.

ˆ In bisection method the interval in divided into two equal halves, no account is taken
of the magnitude of f (x1 ) and f (x2 ).

ˆ For example, if f (x1 ) is much closer to zero, then f (x2 ) it is likely that root is closer
to x2 than x2 .

ˆ Replacement of the curve by a straight line gives a false position of the root.

ˆ Also known as method of false position/regular falsi/linear interpolation method.

Method of False Position


or
Regular Falsi/False Position/Linear Interpolation: As

xn−1 f (xn ) − xn f (xn−1 )


xn+1 =
f (xn ) − f (xn−1 )

Provided that f (xn )f (xn−1 ) < 0 at every iteration.

Example 2: Find the root of x2.2 = 69 using false position method correct upto 4 dps
by taking initial values as 5 and 8

4
Solution: Here f (x) = x2.2 − 69. As, the root lies between 5 and 8. So x0 = 5 and x1 = 8.

f (x0 ) = f (5) = (5)2.2 − 69 = −34.5068 < 0,

f (x1 ) = f (8) = (5)2.2 − 69 = 28.0059 > 0.

xn−1 f (xn ) − xn f (xn−1 )


xn+1 = (3)
f (xn ) − f (xn−1 )

1st iteration: By putting n=1 in (2), we have

x1−1 f (x1 ) − x1 f (x1−1 )


x1+1 =
f (x1 ) − f (x1−1 )
x0 f (x1 ) − x1 f (x0 )
x2 =
f (x1 ) − f (x0 )

Now by substituting x0 = 5, x1 = 8, f (x0 ) = −34.5068 and f (x1 ) = 28.0059 we get

x2 =6.6559

Now, f (x2 ) = f (6.6559) = −4.2756

Now, we see that f (x2 )f (x1 ) < 0, this implies that root lies between 6.6559 8.

Note: If f (xn+1 ) and f (xn ) are of opposite signs then root lies between [xn , xn+1 ]. Else
f (xn+1 ) and f (xn−1 ) are of opposite signs then root lies between [xn−1 , xn+1 ].

2nd iteration: When n = 2, we have

x3 =6.8340

Now, f (x3 ) = f (6.8340) = −0.4062 < 0

f (xn+1 ) and f (xn ) are of opposite signs.

f (x3 ) and f (x2 ), No

f (x3 ) and f (x1 ), Yes

So, root lies in [6.8340,8] and repeat until answer will be correct upto 4 dps.

Modified False Position Method:

ˆ One pitfall of FP method is stagnation of an end point.

5
ˆ Stagnation is not desirable b/c it slows down The Convergence.

ˆ One end of successive intervals does not move from original end point.

ˆ Mean approximation of root converges to the exact root from one side only.

ˆ What is modification? f (x) value of a stagnant endpoint is halved if point twice or


more.

Difference between Secant and False Position Method:

ˆ Iterative equations for both methods are identical on a term by term basis.

ˆ Both use two initial-estimates to compute an approximation of the function.

ˆ Critical difference between methods is how one of initial values is replaced by new
estimate.

ˆ False Position Method: (i). Two estimates always bracket the root.
(ii). Method always converges between root is Kept within Bracket.

ˆ Secant Method: (i). Replaces valves in strict sequence.


(ii). As a result, the two values can sometimes lie on the same side of root.

EXERCISE SET 2.3

1. Let f (x) = x2 − 6 and p0 = 1. Use Newton’s method to find p2 .

2. Let f (x) = −x3 − cos x and p0 = −1. Use Newton’s method to find p2 . Could p0 = 0 be
used?

3. Let f (x) = x2 − 6. With p0 = 3 and p1 = 2, find p3 .


a. Use the Secant method.
b. Use the method of False Position.

c. Which of a. or b. is closer to 6 ?

4. Let f (x) = −x3 − cos x. With p0 = −1 and p1 = 0, find p3 .


a. Use the Secant method.

6
b. Use the method of False Position.

5. Use Newton’s method to find solutions accurate to within 10−4 for the following problems.
a. x3 − 2x2 − 5 = 0, [1, 4]
b. x3 + 3x2 − 1 = 0, [−3, −2]
c. x − cos x = 0, [0, π/2]
d. x − 0.8 − 0.2 sin x = 0, [0, π/2]

6. Use Newton’s method to find solutions accurate to within 10−5 for the following problems.
a. ex + 2−x + 2 cos x − 6 = 0 for 1 ≤ x ≤ 2
b. ln(x − 1) + cos(x − 1) = 0 for 1.3 ≤ x ≤ 2
c. 2x cos 2x − (x − 2)2 = 0 for 2 ≤ x ≤ 3 and 3 ≤ x ≤ 4
d. (x − 2)2 − ln x = 0 for 1 ≤ x ≤ 2 and e ≤ x ≤ 4
e. ex − 3x2 = 0 for 0 ≤ x ≤ 1 and 3 ≤ x ≤ 5
f. sin x − e−x = 0 for 0 ≤ x ≤ 1 3 ≤ x ≤ 4 and 6 ≤ x ≤ 7

7. Repeat Exercise 5 using the Secant method.

8. Repeat Exercise 6 using the Secant method.

9. Repeat Exercise 5 using the method of False Position.

10. Repeat Exercise 6 using the method of False Position.

You might also like