Professional Documents
Culture Documents
Chap2 Lec
Chap2 Lec
Variable
2022
1/31
(UNIMAS) Chapter 2 2022 1 / 31
Outline
1 Bisection Method
2 Newton-Raphson Method
3 Secant Method
2/31
(UNIMAS) Chapter 2 2022 2 / 31
Bisection Method
Theorem
An equation f (x) = 0 , where
f (x) is a real continuous function,
has at least one root between xl
and xu if f (xl )f (xu ) < 0.
3/31
(UNIMAS) Chapter 2 2022 3 / 31
Bisection Method
Example
The mass for a jumper with a given drag coefficient to attain a
prescribed velocity in a set time period is described by
r ✓r ◆
gm gcd
f (m) = tanh t v.
cd m
9/31
(UNIMAS) Chapter 2 2022 9 / 31
Algorithm for the Bisection Method
10/31
(UNIMAS) Chapter 2 2022 10 / 31
Algorithm for the Bisection Method
n xl
MM BAM
xu xr
BAM |"a |%
1 50 200 125
2 125 200 162.5 23.08
3 125 162.5 143.75 13.04
4 125 143.75 134.375 6.98
5 134.375 143.75 139.0625 3.37
6 139.0625 143.75 141.4063 1.66
7 141.4063 143.75 142.5781 0.82
8 142.5781 143.75 143.1641 0.41
Thus after eight iterations |"a |% finally falls below "s = 0.5%, and
the computation can be terminated.
11/31
(UNIMAS) Chapter 2 2022 11 / 31
Algorithm for the Bisection Method
12/31
(UNIMAS) Chapter 2 2022 12 / 31
Algorithm for the Bisection Method
Example
Find the root of the function f (x) = sin 2x + x 3 3 using bisection.
Iterate until |"a | < 0.5%
✗ 1=0 Xu -2
-
Solution: f- 1111 =
gin 271+713-3
Xi Xm
Xu
-1,2
Xm = 0 0 2 I
= ,
flxm ) =
f- (1) =
9in 211 ) + (1)
3- 3
=
-1.0907 ✗ 1=1 ,
Xu =
2
✗ m=
I + I 2 ) =
1.5
2
3- 3
f/ ✗m ) 21-0.04535 ) 1-0.04535 )
fl -0.04535 ) +
-
=
sin
=
-3.04133
=
/ Eat
-01%5,345,3-1--23.0307
=
× ,=
"
✗, ✗ n= 1.5
=
1.25
Xm =
1.25 + 1.5 =
1.375
2
flxm / =
9in 211.3751 t 11.37573 -3
13/31
(UNIMAS) Chapter 2 2022 13 / 31
f- 111 ) =
sin 211-1713 -3
×,
__ 0 ,
Xn=2
I
0 2 1 -3 4.2432 -
1. 0907
-1,2 / Ea /
I ✗m = 0 2 Xm =
I -12 =
1.5 =
1.5 -
I =
33.33%
= ,
2 1.5
I
3 Xm = I -11.5 =
1.25 / Ea =
1.25-1.5 =
-20%
,
2 1.25
4 Xm = 1.251-1.5 =
1,375 ,
/ Ea / =
1.375-1.25=0.0909
2 1.375 =
9.09%
5 Xm =
1.375+1.5
=
1.4375 { a
=
1.4375
-
1.375 = 4.35%
,
2 1.4375
⑥ Xm =
1.4375+1.375=1.40625 ,
/ Ea / =
1.40625 -
1.4375 =
2.2270
2 1.40625
7 ✗m =
1.375-11.40625=1.3906 ,
/ Ea / =
1.3906-1.40625
=
1.1370
2 1.3906
8 Xm = 1.375-11.3906--1.3828 ,
/ Ea / =
1.3828 -
1.3906 =
0.56%
2 1.3828
9 Xm =
1.3751-1.3828=1.3789 / Eat =
1.3789 -
1.3828 =
0.28%
,
2 1.3789
Advantages and Drawbacks of Bisection Method
14/31
(UNIMAS) Chapter 2 2022 14 / 31
Drawbacks of Bisection Method
If a function f (x) is such that it just touches the x axis, it will
be unable to find the lower guess, xl , and upper guess, xu , such
that f (xl )f (xu ) < 0.
Figure: The equation f (x) = 1/x = 0 has no root but changes sign.
16/31
(UNIMAS) Chapter 2 2022 16 / 31
Newton-Raphson Method
f (xi ) 0
f 0 (xi ) =
xi xi+1
f (xi )
xi+1 = xi (1)
f 0 (xi )
Example
Use the Newton-Raphson method to estimate the root of
f (x) = e x x employing an initial guess of x0 = 0.
flail f- 171,7
'
/
Solution: f 0 (x) = e x 1 i xi |"a |%
which can be substituted into the 0 0
formula to give 1 0.500000000 100
f (xi ) e xi
xi 2 0.566311003 11.70929
xi+1 = xi = xi . 3 0.567143165 0.14673
f 0 (xi ) e x1i 1 5
4 0.567143290 2.204 ⇥ 10
Starting with an initial guess of
The root is x ⇡ 0.567143290 if "s
x0 = 0, this iterative equation can
is set at 0.005%. Note that the
be applied to compute
approach rapidly converges.
20/31
(UNIMAS) Chapter 2 2022 20 / 31
Algorithm of the Newton-Raphson Method
Example
Find the root of the function f (x) = sin 2x + x 3 3 using
Newton-Raphson method. Iterate until |"a | < 0.5%. Let the initial
guess to be x0 = 1.
Solution:
21/31
(UNIMAS) Chapter 2 2022 21 / 31
1-1717=9111271-1713-3
ix
/ 111=21052111-3712i-f. it
"
f- Iki ) '
Error
{a 1.50316 I 33.473%
= -
✗it , =
X; -
ginzx +713 -
3 2 1.39241 0.04886 3.94236 7.954% 1.39241
Ea =
1.37988 -
1.38002
I. 37988
= -
0.000101
=
0.0101 Yo
Algorithm of the Newton-Raphson Method
Example
Use the Newton-Raphson method to estimate the root of
f (x) = 0.9x 2 + 1.7x 5 employing an initial guess of x0 = 1 accurate
to within "s = 0.001.
Solution:
f- 1711=0.9712+1.711-5
f /x )
'
=
1.811 + 1.7
✗ it / 0.9712-11.711-5
=
✗i -
1.871 -11.7
22/31
(UNIMAS) Chapter 2 2022 22 / 31
f- 1111=0.9712-11.711-5
f- 1711=1.871+1.7
Xiflxilfltxilt-rror-i.is
'
✗ it , = Xi -
0.9712+1.721-5 1.59475 / 0.0009907
1. 821+1.7
I
① Es =
1.685714 -
I =
0.40677
1.685714
2
Es =
1.59633 -
1.685714 = -0.05599
-
1.59633
3 Es =
1.591475-1.59633=-0.0009907
1.59475
Drawbacks of the Newton-Raphson Method
Although the Newton-Raphson method is often very efficient, there
are situations where it performs poorly.
Example
Determine the positive root of
f (x) = x 10 1 using the Newton-
Raphson method and an initial
guess of x = 0.5.
25/31
(UNIMAS) Chapter 2 2022 25 / 31
Drawbacks of the Newton-Raphson Method
26/31
(UNIMAS) Chapter 2 2022 26 / 31
Drawbacks of the Newton-Raphson Method
27/31
(UNIMAS) Chapter 2 2022 27 / 31
Drawbacks of the Newton-Raphson Method
28/31
(UNIMAS) Chapter 2 2022 28 / 31
Secant Method
A potential problem in implementing the Newton-Raphson
method is the evaluation of the derivative. Although this is not
inconvenient for polynomials and many other functions, there are
certain functions whose derivatives may be difficult or
inconvenient to evaluate.
For these cases, the derivative can be approximated by a
backward finite divided di↵erence:
f (xi 1 ) f (xi )
f 0 (x) ⇡
xi 1 xi
This approximation can be substituted into (1) to yield the
following iterative equation:
f (xi )(xi 1 xi )
xi+1 = xi . (2)
f (xi 1 ) f (xi )
(2) is the formula for the secant method. 29/31
(UNIMAS) Chapter 2 2022 29 / 31
Secant Method
Notice that the approach requires two initial estimates of x.
However, because f (x) is not required to change signs between the
estimates, it is not classified as a bracketing method.
Example
Use the Secant method to find a solution to x = cos x where the two
initial guesses are x0 = 0.5 and x1 = ⇡/4. Continue until |"a |% < 0.005%
0 0.5
1 0.785398163 36.3380
2 0.736384138 6.6560
3 0.739058139 0.361812
4 0.739085149 0.003249
30/31
(UNIMAS) Chapter 2 2022 30 / 31
Secant Method
Example
Find the root of the function f (x) = sin 2x + x 3 3 using secant
method. Iterate until |"a | < 0.5%
X- Xi
Solution: f 1(1) =
sin2e) 113-3
+
=0.2
Xo 0
=
x =2
Allres
Xi f (Xi-1) Error
2 4.2432 141.44%
0.82836-1.43328
3 0.32284-2,36461-1.43528
31/31
(UNIMAS) Chapter 2 2022 31 / 31
f lil) =
sin 271 193-3
+
(( f I(i) Error
O
-
3 Present Past
A
-
0.010225 1. 730 %