Roots
Roots
Roots
𝑥 =?
• For a large number of problems it is, not possible
to find exact values for the roots of the function
so we have to find approximations instead.
Roots of Equations
• Non-computer methods:
– factorizing solution (not always available)
– Graphical solution (inaccurate)
Bisection Method
Bracketing
Methods
False Position Method
Roots of
Equations Fixed Point Iteration
Open
Newton Raphson
Methods
Secant
Bracketing Methods
• Intermediate Value Theorem
If f(x) is continous in the interval [a,b] and
f(a).f(b)<0, then there exist ‘c’ such that a<c<b
and f(c)=0
Bisection Method
• Algorithm:
Set 𝑎1 = 𝑎 and 𝑏1 = 𝑏, and let 𝑐1 be the midpoint of 𝑎, 𝑏 ; that
is
𝑏1 − 𝑎1 𝑎1 + 𝑏1
𝑐1 = 𝑎1 + =
2 2
– If 𝑓 𝑐1 = 0 then 𝑐 = 𝑐1 , and we are done
– If 𝑓 𝑐1 ≠ 0, then 𝑓 𝑐1 has the same sign as either 𝑓 𝑎1 or
𝑓 𝑏1
• If 𝑓 𝑐1 and 𝑓 𝑎1 have the same sign, 𝐶 ∈ 𝑐1 , 𝑏1 , set 𝑎2 = 𝑐1 and
𝑏2 = 𝑏1
• If 𝑓 𝑐1 and 𝑓 𝑎1 have opposite sign, 𝐶 ∈ 𝑎1 , 𝑐1 , set 𝑎2 = 𝑎1 and
𝑏2 = 𝑐1
– Then re-apply the process to the interval 𝑎2 , 𝑏2 ; etc
Bisection Method
The Bisection Method to Solve f(x)=0
Given the function f defined on [a,b] satisfying f(a).f(b)<0
1. 𝑎1 = 𝑎, 𝑏1 = 𝑏, 𝑐0 = 𝑎;
2. 𝑖 = 1;
𝑎𝑖 +𝑏𝑖
3. 𝑐𝑖 = ;
2
4. If 𝑐𝑖 − 𝑐𝑖−1 < 𝜀 or 𝑓(𝑐𝑖 ) < 𝜀, then 10;
5. If 𝑓(𝑐𝑖 )𝑓(𝑎𝑖 ) > 0, then 6;
If 𝑓(𝑐𝑖 )𝑓(𝑎𝑖 ) < 0, then 8;
6. 𝑎𝑖+1 = 𝑐𝑖 , 𝑏𝑖+1 = 𝑏𝑖 ;
7. 𝑖 = 𝑖 + 1; go to 3;
8. 𝑎𝑖+1 = 𝑎𝑖 , 𝑏𝑖+1 = 𝑐𝑖 ;
9. 𝑖 = 𝑖 + 1; go to 3;
10. End of procedure
Relative Error Test
The iteration will be terminated when a bound for the relative
error is less than 𝜀:
𝑐𝑛 − 𝑐𝑛−1
<ε
𝑐𝑛
Error Bounds
Let 𝑎𝑛 , 𝑏𝑛 , and 𝑐𝑛 denote the nth computed values of 𝑎, 𝑏, and 𝑐:
𝑏𝑛 − 𝑎𝑛
𝑏𝑛+1 − 𝑎𝑛+1 = ,𝑛 ≥ 1
2
And
𝑏−𝑎
𝑏𝑛 − 𝑎𝑛 = 𝑛−1
2
Where 𝑏 − 𝑎 denotes the length of the original interval with
which we started.
Since the root 𝛼 ∈ 𝑎𝑛 , 𝑐𝑛 or 𝛼 ∈ [𝑐𝑛 , 𝑏𝑛 ], we know that
1
𝛼 − 𝑐𝑛 ≤ 𝑐𝑛 − 𝑎𝑛 = 𝑏𝑛 − 𝑐𝑛 = 𝑏𝑛 − 𝑎𝑛
2
So
1
𝛼 − 𝑐𝑛 ≤ 𝑛+1 (𝑏 − 𝑎)
2
This shows that the iterates 𝑐𝑛 → ∞ as 𝑛 → ∞
Solution
𝑥 2 − 2𝑥 − 3 = 0
𝑥 𝑥−2 −3=0
3
𝑥=
𝑥−2
3
𝑥𝑛+1 = , 𝑥0 = 4
𝑥𝑛 −2
𝑛 𝑥𝑛 𝒈(𝑥𝑛−1 ) 𝒇(𝑥𝑛 )
0 4 1.5 5
1 1.5 -6 -3.75
2 -6 -0.375 45
3 -0.375 -1.2631 -2.1093
4 -1.2631 -0.9193 1.1216
⋮ ⋮ ⋮ ⋮
14 -1.000004 -0.99999 0.000017
15 -0.99999 -1.00000 -0.000006
16 -1.00000 -1.00000 0.000002
17 -1.00000 1.00000 -0.000001
Convergence Result
Let 𝑔 ∈ 𝐶 𝑎, 𝑏 with 𝑔 𝑥 ∈ 𝑎, 𝑏 for all 𝑥 ∈
[𝑎, 𝑏]. Let 𝑔′ 𝑥 exist on (a,b) with
𝑔′ 𝑥 ≤ 𝑀 < 1, ∀𝑥 ∈ [𝑎, 𝑏]
If 𝑥0 is any point in [a,b] then the sequence
defined by 𝑥𝑛 = 𝑔 𝑥𝑛−1 , 𝑛 ≥ 1 will converge to
the unique fixed point x in [a,b]
Example: The equation 𝑥 2 − 2𝑥 − 3 = 0 with
𝑥0 = 4 has a unique root in [1, 4]
3
a. 𝑥𝑛+1 =
𝑥𝑛 −2
3
𝑔(𝑥) =
𝑥−2
−3
𝑔′ 𝑥 = 2
<0
𝑥−2
converge
b. 𝑥𝑛+1 = 2𝑥𝑛 + 3
𝑔(𝑥) = 2𝑥 + 3
′
1
𝑔 𝑥 = <1
2𝑥 + 3
converge
𝑥𝑛 2 −3
c. 𝑥𝑛+1 =
2
2
𝑥 −3
𝑔 𝑥 =
2
𝑔′ 𝑥 = 𝑥 > 1, ∀𝑥ϵ[1,4]
Not converge
Exercises
The equation 𝑥 3 + 4𝑥 2 − 10 = 0 with 𝑥0 = 1.5
has a unique root in [1,2]
Newton-Raphson Method
• We will work with tangent of the
graph of function f
• Therefore we suppose that f is
differentiable
• We chose the initial
approximation of the root 𝑥0 .
• We route a tangent line to the
graph of function f through point
𝑥0 , 𝑓 𝑥0
• The intersect with axis x will be 𝑥1 .
• Then we route a tangent line
through 𝑥1 , 𝑓 𝑥1
• The intersect with axis x will be 𝑥2
and so on
Newton-Raphson Method
• The line tangent to the graph of y= f(x) at 𝑥0 , 𝑓 𝑥0 is the
graph of the linear Taylor polynomial:
𝑦 − 𝑓(𝑥0 ) = 𝑓′(𝑥0 )(𝑥1 − 𝑥0 )
• The root of 𝑦 is 𝑥1 :
𝑓(𝑥0 ) + 𝑓′(𝑥0 )(𝑥1 − 𝑥0 ) = 0
𝑓′(𝑥0 )(𝑥1 − 𝑥0 ) = −𝑓(𝑥0 )
−𝑓(𝑥0 )
(𝑥1 − 𝑥0 ) =
𝑓′(𝑥0 )
−𝑓(𝑥0 )
(𝑥1 − 𝑥0 ) =
𝑓′(𝑥0 )
𝑓(𝑥0 )
𝑥1 = 𝑥0 −
𝑓′(𝑥0 )
Newton-Raphson Method
• Since x1 is expected to be an improvement over x0 as an
estimate of 𝛼, we repeat the procedure with x1 as initial
guess:
𝑓(𝑥1 )
𝑥2 = 𝑥1 −
𝑓′(𝑥1 )
• Repeating this process, we obtain a sequence of numbers,
iterates, x1, x2, x3, . . . hopefully approaching the root 𝛼.
• The iteration Formula
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓′(𝑥𝑛 )
is referred to as the Newton’s method, or Newton-Raphson,
for solving f(x) = 0.
The Secant Method
• The Newton method is based on
approximating the graph of y = f(x)
with a tangent line and on then
using a root of this straight line as
an approximation to the root 𝛼 of
f(x).
• From this perspective, other
straight-line approximation to y =
f(x) would also lead to methods of
approximating a root of f(x).
• One such straight-line
approximation leads to the secant
method.
• Assume that two initial guesses to 𝛼 are known and denote them by 𝑥0
and 𝑥1 . They may occur
• on opposite sides of 𝛼, or
• on the same side of 𝛼.
The Secant Method
• To derive a formula for x2, we proceed in a manner similar to
that used to derive Newton’s method:
Find the equation of the line and then find its root x2.
• The equation of the line is given by
𝑓 𝑥1 − 𝑓(𝑥0 )
𝑦 = 𝑝 𝑥 = 𝑓 𝑥1 + (𝑥 − 𝑥1 )
𝑥1 − 𝑥0
• Solving p 𝑥2 = 0, we obtain
𝑥1 − 𝑥0
𝑥2 = 𝑥1 − 𝑓 𝑥1
𝑓 𝑥1 − 𝑓(𝑥0 )
The Secant Method
• Having found𝑥2 , we can drop 𝑥0 and use𝑥1 , 𝑥2 as a new set of
approximate values for 𝛼.
• This leads to an improved values 𝑥3 and this can be continued
indefinitely.
• we obtain the general formula for the secant method
𝑥𝑛 − 𝑥𝑛−1
𝑥𝑛+1 = 𝑥𝑛 − 𝑓 𝑥𝑛
𝑓 𝑥𝑛 − 𝑓(𝑥𝑛−1 )
• It is called a two-point method, since two approximate values
are needed to obtain an improved value.
• The bisection method is also a two-point method, but the
secant method will almost always converge faster than
bisection.
Exercise
Consider the equation 𝑓 𝑥 = 𝑥 2 − 2𝑥 − 3
a. Using four steps of the newton’s method
starting at 𝑥0 = 0
b. Using four steps of the secant method starting
at 𝑥0 = −2 and 𝑥1 = 1