Numerical Root-Finding: Bracketing Methods
Numerical Root-Finding: Bracketing Methods
Bracketing Methods
Non-linear Equations
What are Nonlinear Equations?
Linear Equations
Non-linear Equations
10 + 5 = 15
2 + 2 = 2
++1=0
= 0 cos 2
1 1 1
= +
= 2 3
ln =
+
= 0 (1 )
=
=
=
0
0 =
Root-finding
What is Root-finding?
Example: Find the roots of 2 + 6 + 5 = 0
Example: Find the roots of 2 2 + 2 = 0.
Note:
Solve for x:
2 = ln
is the
same as
Outline
Numerical Root-Finding Methods
1. Bisection Method
2. Regula-Falsi Method
Example: Solve for x in
2 + 2 = 2
Non-linear Equations
Example: Solve for x in 2 + 2 = 2
Lets do the Bisection Method!
1. Turn your equation into a function in x.
= 2 2 2
*Again, solving for x
means finding the root
of f(x), i.e. f(x) = 0.
Bisection Method
2. Plot . Find an interval [a, b] where 1 root exists.
Choose the
interval such that
is monotonic in
[a, b] and
< 0.
NO GOOD!
=
=
Bisection Method
2. Plot . Find an interval [a, b] where 1 root exists.
Choose the
interval such that
is monotonic in
[a, b] and
< 0.
=
Exactly 1
root exists!
=
=
Bisection Method
3. Find the midpoint of [a, b] and label it as c. Evaluate
, and ().
Bounds: 4, 5
=
=4
=5
+
=
2
=
. = .
= .
Bisection Method
4. If < 0, then set the new bounds to [a, c].
If < 0, then set the new bounds to [c, b].
=
= .
= 1.887
. = .
Bisection Method
Repeat step 3. Find the midpoint of [a, b] and label it
as c. Evaluate , and ().
Bounds: 4, 4.5
=4
= 4.5
=
. = .
. = .
= .
Bisection Method
4. If < 0, then set the new bounds to [a, c].
If < 0, then set the new bounds to [c, b].
= 2.070
= .
=
. = .
. = .
Bisection Method
How do you know when to stop?
Bisection Method
5. If the interval is less than a tolerance, then STOP.
Report = as your answer. Otherwise, go to step 3.
Tolerance: = 0.01
Previous c:
4.25
Current c:
4.375
Is 4.375 4.25 <
. = .
. = .
Bisection Method
Lets look at what really happens
= 2 2 2
Bisection Method
Lets look at what really happens = 2 2 2
Iter
f(a)
f(b)
f(c)
4.5
-2
0.377417
4.5
4.25
-2
0.377417
-1.03519
4.25
4.5
4.375
-1.03519
0.377417
-0.39119
4.375
4.5
4.4375
-0.39119
0.377417
-0.02332
4.4375
4.5
4.46875
-0.02332
0.377417
0.172832
4.4375
4.46875
4.453125
-0.02332
0.172832
0.073717
4.4375
4.453125
4.445313
-0.02332
0.073717
0.024941
Bisection Method
Lets look at what really happens = 2 2 2
Iter
f(A)
f(B)
f(C)
14
4.441284
4.441345
4.441314697
-6.6E-06
0.00037
0.000182
15
4.441284
4.441315
4.441299438
-6.6E-06
0.000182
8.77E-05
16
4.441284
4.441299
4.441291809
-6.6E-06
8.77E-05
4.06E-05
17
4.441284
4.441292
4.441287994
-6.6E-06
4.06E-05
1.7E-05
18
4.441284
4.441288
4.441286087
-6.6E-06
1.7E-05
5.23E-06
19
4.441284
4.441286
4.441285133
-6.6E-06
5.23E-06
-6.6E-07
Bisection Method
Summary of steps:
1. Turn your equation into a function of x. Set a tolerance value
(typically 0.0001).
2. Plot . Find an interval [a, b] where 1 root exists.
3. Find the midpoint of [a, b] and label it as c. Evaluate
, and ().
4. If < 0, then set the new bounds to [a, c]. If
< 0, then set the new bounds to [c, b].
5. If < , then STOP. Report = as your
answer. Otherwise, go to step 3.
Bisection Method
Alternatively,
instead of
having a
tolerance, you
can also set the
maximum
number of
iterations.
N=4
Bisection Method
YOUR TASK:
Develop a program that carries out the bisection
method. Prompt the user for the initial guess
interval [a, b], and the desired tolerance.
Output the final root, and the number of
iterations needed to reach that final value.
Regula-Falsi Method
Example: Solve for x in 2 + 2 = 2
Lets do the Regula-falsi Method!
1. Turn your equation into a function in x.
= 2 2 2
*Again, solving for x
means finding the root
of f(x), i.e. f(x) = 0.
Regula-Falsi Method
2. Plot . Find an interval [a, b] where 1 root exists.
Choose the
interval such that
is monotonic in
[a, b] and
< 0.
From before:
[a, b] = [4, 5]
=
Exactly 1
root exists!
Regula-Falsi Method
3. Find c using the following formula. Evaluate ().
+
=
2
()( )
=
()
. = .
(5)(5 4)
=5
5 (4)
5 30
=5 =
= 4.286
7
7
=
Regula-Falsi Method
Why =
()()
()
?
From similar triangles:
bc
f(b)
()
=
()
f(b) f(a)
ba
a c
Regula-Falsi Method
4. If < 0, then set the new bounds to [a, c].
If < 0, then set the new bounds to [c, b].
=
= 1.726
= .
. = .
Regula-Falsi Method
Summary of steps:
1. Turn your equation into a function of x. Set a tolerance value
(typically 0.0001).
2. Plot . Find an interval [a, b] where 1 root exists.
3. Find =
()()
. Evaluate
()
().
Regula-Falsi Method
YOUR TASK:
Develop a program that carries out the regula-falsi
(false-position) method. Prompt the user for the
initial guess [a, b], and the desired tolerance.
Output the final root, and the number of
iterations needed to reach that final value.
Bracketing Methods
Problems in the
Bracketing Methods:
Practice
Solve for the only positive value of x that satisfies:
1
x
x 1 1 e
2
x
1. Bisection Method
2. Regula-Falsi Method
Use a tolerance of 0.00001.