Unit 1
Unit 1
1. Errors
• Errors definitions
• The causes of errors
• Error analysis using Taylor series
• Error propagation
2. Numerical Differentiation
• Finite-divided difference approximation
3. Numerical Integration
• Trapezoidal rule
(EE3006/3006A)
1. Errors
=> Numerical errors arise from the use of approximations in computer-
based calculations to represent exact mathematical operations and
quantities:
True value = approximation + error
Accuracy: refers to how closely a computed or measured value agrees with the
true value.
Precision: refers to how closely individual computed or measured values agree
with each other.
1
(EE3006/3006A)
Increasing accuracy
Increasing precision
True value
Accuracy: how closely a computed or measured value agrees with the true value.
Precision: how closely individual computed or measured values agree with each other. 3
(EE3006/3006A)
2
(EE3006/3006A)
Error bound s :
=> Determine how big the errors of the calculation (or measurement)
-> Usually not concern with sign, but with prefixed percent tolerance.
Proof: the smallest percent tolerance for a
a s 0.5102n % number with n significant figures is
| 0.5 | 0.5
Biggest acceptable error or 0.5 10 2 n %
Biggest integer with 99 9 9 1 0 n
n digital numbers
n
5
(EE3006/3006A)
Example 1:
Use Maclaurin series expansion of e x :
x 2 x3 xn
e 1 x .... ,
x
n = 1, 2, ….
2! 3! n!
(use a polynomial to approximate exponential)
to calculate e0.5
until the prespecified error criterion
conforming to 3 significant figures.
3
(EE3006/3006A)
Solution:
1. The error bound for the requirement of 3 significant figures is:
s (0.5 1023%) 0.05%
2. With the Maclaurin series expansion, we can calculate the approximation
term by term: x 2 x3
e x 1 x ....
xn
2! 3! n!
n Result εa (%) εt (%)
1 39.3
1 1.5 33.3 9.02
2 1.625 7.69 1.44
3 1.645833333 1.27 0.175
4 1.648437500 0.158 0.0172
where the true relative error is calculated with the true value of e0.5, i.e.
1.648721. 7
(EE3006/3006A)
4
(EE3006/3006A)
Truncation Errors
• A truncation error is caused by truncating an infinite number
and approximating it by a finite number;
• Truncation error also includes discretization error, which arises
from taking a finite number of steps to approximate an infinite
process;
• In some instances, round-off error is also called truncation error
especially when the number is rounded by truncation.
=>How
=> To gain
to useinsight,
a mathematical
a widely tool
usedto analyze theseformulation
mathematical errors arisen
forin
numerical analysis?
error analysis is: TAYLOR SERIES.
(EE3006/3006A)
xi xi 1
n 1!
=> provides a means to predict the function value at one point (i.e., xi+1)
by using the function value at another point (i.e., xi) and its
derivatives.
10
5
(EE3006/3006A)
• Zero-order approximation:
f xi 1 f xi
• First-order approximation
f x i 1 f x i f ' x i x i 1 x i
{
(slope multiplied by distance)
• Second-order approximation
f ' ' xi
f xi 1 f xi f ' xi xi 1 xi xi 1 xi 2
2!
(can captures some of the curvature) 11
(EE3006/3006A)
f '' xi 2
f xi 1 f xi f ' xi h h
2!
Truncation error ......
f n xi n
h Rn
n!
f n1
n 1
For example:
1) if the error is O(h), halving the step size will halve the error;
2) if the error is O(h2), halving the step size will quarter the error!
12
6
(EE3006/3006A)
13
(EE3006/3006A)
If write the error bounds of e1 and e2 as ε1 and ε2, respectively, then we know
|e1| < ε1 and |e2| < ε2
the error bound of the absolute error of the sum approximation x+y then is
14
7
(EE3006/3006A)
2. Numerical Differentiation
The definition of differentiation is:
xi
: the
It isoperation of finding
widely used the derivative,
to handle or instantaneous
many different kinds ofrate of change
differential
of a function with respect to its variable.
equations in science and engineering:
dV
Ohm’s law: J
dx
dz (t )
Speed: v(t )
dt
Fourier’s law: q k dT
dx
15
(EE3006/3006A)
f(x)
f xi x
Δy
f xi
Δx
xi xi+Δx x
Discrete analogue: y
f xi x f xi
x xi x
16
8
(EE3006/3006A)
f ( x0 ) f (3) ( x0 )
f x 1 f x0 f x0 ( x 1 x0 ) ( x 1 x0 ) 2 ( x 1 x0 )3....
2! 3!
17
(EE3006/3006A)
9
(EE3006/3006A)
f xi f xi 1
f xi O ( h)
h
(error)
(approximation)
(EE3006/3006A)
f ( 3) ( xi ) 3
f ( xi 1 ) f ( xi 1 ) 2 f ' ( xi )h 2 h
…
3!
which can be solved for
f fx ( x )f x f ( x (3)
) i1 i 1 i1 i f1
) (xi ) 2 2
ff ' (xx
i i
Oh(h )...
2h 2h 6 (error)
(approximation)
20
10
(EE3006/3006A)
*Example 2:
Use a forward, a backward, and a centered finite-divided
difference approximation to calculate the first derivative of
21
(EE3006/3006A)
f xi 1 f xi
Solution: f xi
h
( f ( x) 0.1x 4 0.15x3 0.5x 2 0.25x 1.2 ) f xi f xi 1
f xi
h
The data needed for this example are: f xi 1 f xi 1
f xi
xi-1=0.25 f(xi-1)=1.1035156 2h
xi=0.5 f(xi)=0.925
xi+1=0.75 f(xi+1)=0.6363281
0.6363281 0.925
FDA: f 0.5 -1.15469
0.25
0.925 1.1035156
BDA: f 0.5 -0.714062
0.25
0.6363281 1.1035156
CDA: f 0.5 -0.934375
2 0.25
22
11
(EE3006/3006A)
3. Numerical Integration
Dictionary definition of integration - “to bring together, as
parts, into a whole; to unite; to indicate the total amount”
Mathematically, definite integration is represented by
b
I f ( x)dx
a
which stands for the integral of the function f(x) with respect
to the independent variable x, evaluated between the limits
from a to b.
23
(EE3006/3006A)
f(x)
a b x
b
I f ( x)dx
a
12
(EE3006/3006A)
Newton-Cotes Formulas
=> it is based on the strategy of replacing a complicated function or
tabulated data with a polynomial that is easy to integrate.
b b
I f x dx f n x dx
a a
25
(EE3006/3006A)
• Open Integration
26
13
(EE3006/3006A)
a a
f1(x)=a0+a1x.
where Integral Estimate
(EE3006/3006A)
28
14
(EE3006/3006A)
h n 1
I
2
f ( x0 ) 2
i 1
f ( xi ) f ( xn )
29
(EE3006/3006A)
*Example 3:
Use the two-segment trapezoidal rule to estimate the integral
of
f ( x) 0.2 25x 200x 2 675x3 900x 4 400x5
Solution:
For n=2, one has the step size h=0.4
f (0) 0.2, f (0.4) 2.456, f (0.8) 0.232
0.2 2(2.456) 0.232
I 0.4 1.0688
2
30
15
(EE3006/3006A)
Classwork 1:
31
(EE3006/3006A)
Reference:
(S.C. Chapra, Applied numerical methods with MATLAB for engineers and
scientists, McGraw Hill, 2008)
32
16