Professional Documents
Culture Documents
MBE 2036
Finding Roots
Part 5
Review
Round-off error
Computer has range limit
Floating point numbers approximated by binary number
Truncation error
dv v v (t i 1) v (t i )
Eq. 1.31
dt t t i 1 t i
Truncation error
truncate the series after the first derivative term:
Taylor series
f '' ( x i ) 2 f ( 3 ) ( x i ) 3
f ( xi 1 ) f ( xi ) f ( xi )h
'
h h ...
2! 3!
f ( n ) ( xi ) n
h Rn (Eq 4.1)
n!
where the step size h xi 1 xi
Truncation Errors
v (ti1) v (t i ) v ' (t i )(t i 1 t i ) R1 Eq 4.7
v (ti1 ) v (t i ) R1
v ' (t i ) Eq
ti+1 4.8is the step size
-ti=h,
(t i 1 t i ) (t i 1 t i )
Halving the step size would in principle halve the error of the derivative
Optimal
point
-Application case-
Finding Roots
Roots of Equations
Consider our parachutists example:
c
m t
v g(1 - e m ) Eq. 1.29
c
Determine: The time t for a parachutist to attain a
prescribed velocity v, with a given mass m and
given drag coefficient c
Roots of Equations
For a quadratic equation:
f(x) ax bx c 2
Eq 5.1
- b b 2 4ac
x Eq 5.2
2a
Roots of Equations
c
m t
v g(1 - e m ) Eq. 1.29
c
c
m t
f(c) g(1 - e m
)- v 0 Eq. 5.3
c
Root of equations
f(x)=0
How to solve?
Graphical Method
Suppose mass m=68.1kg, g = 9.8 m/s2 and we want to
find c which it will make v=40m/s after falling for time
t=10s
c
m t
f(c) g(1 - e m ) - v 0 Eq. 5.3
c
f(c)
This is the c making f(c)=0
Graphical Method
c
m t
f(c) g(1 - e m ) - v 0 Eq. 5.3
c
Graphical Method
c f(c)
1 51.14440
2 44.92059
3 39.26343
4 34.11489 f(c)
5 29.42327 c=14
6 25.14248
7 21.23144
c=15
8 17.65345
9 14.37577
10 11.36912
11 8.60733 root
12 6.06695
13 3.72701
14 1.56871
15 -0.42483
16 -2.26875
17 -3.97666
18 -5.56079 c
19 -7.03214 ~14.75
20 -8.40062 Figure 5.1
Graphical Method
The graphical method gives a rough estimation
of the root and the value of c is 14.75
The result can be substituted back to Eq 5.5 to
confirm the estimate: Very close to zero
667.38
f(14.75) (1 e 0.146843 14.75 ) 40 0.059
14.75
The result can also be checked by substituting
the estimated c to Eq 1.29 Very close to 40 m/s
9.8 68.1
v (1 e (14.75/68.1)10 ) 40.059
14.75
Graphical Method
Although graphical method is not very precise, it
can still give rough estimates of the roots
The graphical method provides useful
information for understanding the properties of
the functions
These estimates can be used as the initial
guesses for other numerical methods for finding
the roots and anticipating the pitfalls of the
numerical methods
xL xU x xL xU x
If f(xL) and f(xU) in both Figure 5.2 and 5.3 have the same sign, either there
will be no roots or there will be an even number of roots within the interval
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 18
x x
xL xU xL xU
If f(xL) and f(xU) in both Figure 5.4 and 5.5 have different signs,
there will be an odd number of roots within the interval
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 19
Discontinuous
function
x x
The function is
xL tangential to xU xL xU
the x axis
Both cases have even number of roots even f(xL)
and f(xU) in both Figure 5.6 and 5.7 have
different signs
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 20
Bracketing methods
Two initial guesses that bracket the root:
x
xL xU
Bisection Method
Bisection method is a common Bracketing method
It uses an incremental search technique to find root. The
basic principle is:
In general, if f(x) is real and continuous in the interval from xL and
xU and f(xL) and f(xU) have opposite signs, i.e.
f(xL) f(xU) < 0
then there is at least one real root between f(xL) and f(xU)
Problem ! We are actually trying to find the root so the true value is not known.
Hence, it is not too practical to use the above as the termination criterion
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 26
c
m t
f(c) g(1 - e m
)- v 0 Eq.
f(c)
5.3
c
c
Note: If we are not given the initial search range, we could use Figure 5.1 to help us to select the initial guesses. In this case, we
may choose the search range between 14 and 16 instead.
x L xU
xr Eq 5.6
=14 f(c)
2
Step 3: Check the root:
We check whether the root is actually in the
middle, upper subinterval or lower subinterval:
c
1st Iteration f(xr)=f(14)= 1.5687 > 0 f(12)f(14) > 0
14.75 - 14.5
a 100 1.6949%
14.75
f (xL)f(xr)>0
xL=14, xU=16
2nd Iteration
12 14 16 xr=15
f (xL)f(xr)<0
xL=14, xU=15
3rd Iteration
12 14 16 xr=14.5
f (xL)f(xr)>0
xL=14.5, xU=15
4th Iteration
12 14 16 xr=14.75
3 14 15 14.5 3.448
xL xr +x/2
xU
x = xU - xL
True root If the true root lies between xU and xL, the
(the upper limit of the true root) true root must lies within:
xL
-x/2 xr xU x Nice! It tells us the
xr maximum error of our
2
estimate of the true root
True root
(the lower limit of the true root)
x Lnew xUnew
xrnew Eq 5.8
2
x = xUnew - xLnew x
2
xUnew xLnew
xrnew xrold Eq 5.9
2
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 36
xU xL
2 x xL
a 100% U 100% Eq 5.10
xU xL xU xL
2
Besides the ability to analysis the exact upper bound of the true error
The bisection method also allows us to calculate the number of iterations
required to obtain an absolute error before starting the iterations
Before starting the technique, the absolute error is:
EA0=xU0 xL0 = x0
After the first iteration, the error becomes:
EA1 = x0/2
Because each succeeding iteration halves the error, a general formula
relating the error and the number of iterations, n, is:
x 0 This is the maximum error
E An Eq 5.11
2n
If EA,d is the desired error, the above equation can be written as:
x 0
log
x 0 x 0
E A,d
2n n log 2n log n
EA E A,d log 2
x 0
n log 2
Eq 5.12
E A,d
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 39
Bisection Algorithm
This program is not
Function(xL, xU, es, imax, xr, iter,ea) a real program. It
% es: stopping criterion just shows the main
sequences and
% ea: approximate percent relative error logics of the
% imax: the maximum number of iteration program.
iter = 0
fL = f(xL) % f( ) is the function for evaluation
DO
xr_old = xr
xr = (xL + xU)/2
fr=f(xr)
iter = iter +1
IF xr 0 THEN
ea =ABS((xr xr_old)/xr)*100
END IF
Department of Mechanical and Biomedical Engineering City University of Hong Kong
MBE2036 Engineering Computing, part 5, version 2.0 41
Flow chart
Learning Outcomes
After this lecture, the student would be able to understand the
following: