Sie sind auf Seite 1von 17

Numerical Methods with Applications (MEC500)

Chapter 01

Truncation error & Taylor Series

Dr Baljit Singh
Faculty of Mechanical Engineering
Universiti Teknologi MARA (UiTM)
Office: T1-A18-1C
Adapted from : Ramlan Kasiran

Learning outcome
Recognizing that truncation errors occur when exact
mathematical formulations are represented by approximations.
Knowing how to use the Taylor series to estimate truncation
errors.
Understanding how to write forward, backward, and centered
finite-difference approximations of the first and second
derivatives.
Recognizing that efforts to minimize truncation errors can
sometimes increase round off errors.

Ice braking

How confident we are in our approximate result?


The question is how much error is present in our
calculation and is it tolerable?
Give me the value of the function at a single point, and the
value of all (first, second, and so on) its derivatives, and I can
give you the value of the function at any other point
Archimedes

Truncation error
Truncation errors : error that result from using an approximation
in place of an exact mathematical procedure.
Example
Math model:
dv
c
g v
dt
m
Analytical solution:

gm
v(t)
1 e(c/m)t
c

Numerical Method solution:

dv v v(ti 1) v(ti )

dt t
ti 1 ti
Taylor Series give insight into the truncation errors for the numerical
method!

Taylor theorem & series


Taylor theorem states that any smooth function (such as
trigonometric, exponential etc) can be approximated as a
polynomial (i.e power series).
Taylor series provides a means to predict the value of a function
at one point in terms of the function value and its derivatives at
another point.
Ex: f(0)=5 , f(0)=2, f(0)=6, f(0)=0 f(0.2)=?
TS is a representations of a function as an infinite sums of terms
calculated from the values of its derivatives at a single point.
Taylor Series is widely used to express functions (i.e. math
models) in an approximate manner.

WHY?

Taylor theorem & series


Why do we need to rewrite a function in the form of an infinite
series?
Example, isnt 1/(1- x) good enough as an expression? In fact,
after the rewrite, the expression 1+ x + x2 + ...+ xn + ... is
even longer and is infinite in nature.
Can we integrate

How a calculator calculate sine, cosine, tangent etc?


Give me the value of the function at a single point, and the
value of all
(first, second, and so on) its derivatives, and
I can give you the value
of the function at any
other point Archimedes
TS gives a way to find the approximate values of a functions by
basic arithmetic operations of +, -, x and /.

Taylor series
Build Taylor series term by term!
zero order approximation, only true if xi+1
and xi are very close to each other.

f(xi 1) f(xi )
first order approximation, in form of a
straight line

f(xi 1) f(xi ) f ' (xi )h

nth order approximation, (xi+1- xi)= h step


''
(3)
(n)
size f(x ) f(x ) f ' (x )h +f (xi ) h2 +f (xi ) h3 + +f (xi ) hn +R
i 1
i
i
n
2!
3!
n!

term, Rn, account


f (n+1)( ) Remainder
(n+1)
Rn =
hFor
all terms form (n+1) to
(n +1)! = Truncation Error
Xi Xi+1

Taylor series - Example


Use zero- through fourth-order Taylor Series Expansion (TSE) to
approximate the following function from xi = 0 with h=1.
f(x) = -0.1x4 -0.15x3 - 0.5x2 -0.25x + 1.2 [4th order
polynomial]
Predict the function value at xi+1!

Taylor series final remarks


In general, the nth order Taylor series expansion will be exact for
an nth order polynomial.
In other functions (eg. Exponential & sinusoids), finite number of
terms will not yield an exact estimate. Thus the remainder term
Rn is of the order of hn+1, meaning:
The more terms are used, the smaller the error, and
The smaller the spacing, the smaller the error for a given
number of terms.
In most cases, inclusion of only a few terms will give an
approximation close enough for practical purpose.
So how many terms are required to get close enough?

Taylor series final remarks


So how many terms are required to get close enough? Depends on the
Rn!
(n1)

Rn

f
( ) (n1)
h
or R n O(hn1)
(n 1)!

is not known exactly, somewhere xi xi+1


To evaluate Rn, need to find f(n+1)(x) which require f(x). If we know f(x),
we dont need TSE!
O(hn+1) means the order of truncation error is hn+1 we can control h
Useful to give comparative errors of NM
If error = O(h), halving the step size will halve the error.
If error=O(h2), halving the step size will quarter the error.
Truncation error is decreased by addition of terms to the Taylor series.
If h is sufficiently small, only a few terms may be required to obtain an
approximation close enough to the actual value for practical purposes.

Use the concept of absolute relative approximate error and


apply stopping criterion

Remainder term of TSE


Supposed TSE is truncated after the zero-order term f(xi+1) f(xi)
''
(3)
f
(x
)
f
(xi ) 3
2
i
Thus R 0 f (xi )h +
h +
h +
2!
3!
'

Now truncate after the first order gives R0 f(xi)h

Derivative mean-value theorem;


Within an interval, there exists at least one
point on the function that has a slope, f()
which is parallel to the line joining f(x i)
and f(xi+1)
Thus f() = R0/h Ro = f()h
Higher order error can be develop based on the same
reasoning!

Using Taylor Series to estimate truncation errors


Recall the falling bungee jumper?

dv v v(ti 1) - v(ti )

dt t
ti 1 - ti
Expand using TSE...
v''(ti )
v'''(ti ) 3
v(ti 1) v(ti ) v'(ti )h
h
h ...Rn
2!
3!
Truncate after first order term,..

v(ti 1) v(ti ) v'(ti )h R1

Rearrange:
v'(ti )

v(ti 1) - v(ti ) R1
h
h

Truncatio
n
error

1st order approximation


of derivative

f (2)( ) (2)
R1
h
(2)!
R1 f (2)( ) (2)
Truncationerror,
h
h (2)(h)
Truncationerror O(h)

Numerical Differentiation
The first order Taylor series can be used to calculate approximations to
derivatives:
Given:

f(xi 1) f(xi ) f '(xi )h O(h2 )


f '(xi )

Then:

f(xi 1) f(xi )
O(h)
h

This is termed a forward difference because it utilizes data at i and i+1


to estimate the derivative.

Numerical Differentiation
Type of finite divided difference approximations
[Depending the points used]
Forward:

f ' (xi )

f(xi 1) f(xi )
O(h)
h

f ' (xi )

f(xi ) f(xi 1)
O(h)
h

f ' (xi )

f(xi 1) f(xi 1)
O(h2 )
2h

Backward:
Centered:

Total numerical error


The total numerical error is the summation of the truncation and
round-off errors.
The truncation error generally increases as the step size
increases.
Round off error decreases as the step size increases

Control of numerical error


For most practical cases, exact numerical error is not known.
Therefore, we must settle for estimate of errors.
Error estimates are based on the experience and judgment of
the engineers.
Error analysis is to a certain extent an art, always observe the
following guides;
Careful with arithmetic manipulations
Use extended-precision arithmetic
Attempt to predict total numerical error using Taylor series
Perform numerical experiments try different step sizes.

Next lecture:
Solving non-linear equation

End
Class dismissed

Das könnte Ihnen auch gefallen