You are on page 1of 30

Numerical Methods

- An Introduction -

Mathematical Modeling and

Engineering Problem Solving
Requires understanding of engineering systems
By observation and experiment
Theoretical analysis and generalization

Computers are great tools, however, without

fundamental understanding of engineering
problems, they will be useless.

Chapter 1

A mathematical model is represented as a functional

relationship of the form

Dependent
independent
forcing
Variable =f variables, parameters, functions
Dependent variable: Characteristic that usually reflects the
state of the system
Independent variables: Dimensions such as time and space
along which the systems behavior is being determined
Parameters: reflect the systems properties or composition
Forcing functions: external influences acting upon the
system

Chapter 1

Newtons 2nd law of Motion

States that the time rate change of momentum of
a body is equal to the resulting force acting on it.
The model is formulated as

F=ma
F =net force acting on the body (N)
m=mass of the object (kg)
a =its acceleration (m/s2)
Chapter 1

Example, modeling of a falling parachutist:

dv F

dt m
F FD FU
FD mg
FU cv
dv mg cv

dt
m
6

dv
c
g v
dt
m
This is a differential equation and is written in terms of
the differential rate of change dv/dt of the variable
that we are interested in predicting.
If the parachutist is initially at rest (v=0 at t=0), using
calculus
Independent variable

gm
( c / m ) t
v(t )
1 e
c
Dependent variable
Forcing function
Chapter 1

Parameters

Approximations and Round-Off Errors

For many engineering problems, we cannot
obtain analytical solutions.
Numerical methods yield approximate results,
results that are close to the exact analytical
solution. We cannot exactly compute the
errors associated with numerical methods.
The question is how much error is present in
our calculation and is it tolerable?

Accuracy. How close is a computed or measured

value to the true value
Precision (or reproducibility). How close is a
computed or measured value to previously
computed or measured values.
Inaccuracy (or bias). A systematic deviation from
the actual value.
Imprecision (or uncertainty). Magnitude of
scatter.
Chapter 3

Significant Figures
Number of significant figures indicates precision. Significant digits of a
number are those that can be used with confidence, e.g., the number of
certain digits plus one estimated digit.
53,800 How many significant figures?
5.38 x 104
5.380 x 104
5.3800 x 104

3
4
5

Zeros are sometimes used to locate the decimal point not significant
figures.
0.00001753
0.0001753
0.001753

4
4
4

Error Definitions
True Value = Approximation + Error
Et = True value Approximation (+/-)
True error

true error
True fractional relative error
true value
true error
True percent relative error, t
100%
true value

We usually not know the true value a priori. Then

Approximate error
a
100%
Approximation
Iterative approach, example Newtons method

a Current approximat ion - Previous approximat ion 100%

Current approximat ion

a s

Pre-specified % tolerance based on

the knowledge of your solution

If the following criterion is met

s (0.5 10 (2-n) )%
you can be sure that the result is correct to at least n significant
figures.

Chapter 3

14

Round-off Errors
Numbers such as , e, or 7 cannot be expressed
by a fixed number of significant figures.
Computers use a base-2 representation, they
cannot precisely represent certain exact base-10
numbers.
Fractional quantities are typically represented in
computer using floating point form, e.g.,
Integer part

m.be
mantissa

exponent
Base of the number system
used

Figure 3.3

Chapter16
3

Chapter 3

17

Figure 3.5

Chapter 3

18

156.78

10 system

0.15678x103 in a floating point base-

1
Suppose only 4
0.029411765
34
decimal places to be stored
1
0
0.0294 10
m 1
2
Normalized to remove the leading zeroes. Multiply
the mantissa by 10 and lower the exponent by 1
0.2941 x 10-1
Additional significant figure is
retained
Chapter19
3

1
m 1
b

Therefore
for a base-10 system 0.1 m<1
for a base-2 system
0.5 m<1
Floating point representation allows both fractions and
very large numbers to be expressed on the computer.
However,
Floating point numbers take up more room.
Take longer to process than integer numbers.
Round-off errors are introduced because mantissa holds only a
finite number of significant figures.

Chapter20
3

Chopping
Example:
=3.14159265358 to be stored on a base-10 system carrying 7
significant digits.
=3.141592 chopping error

et=0.00000065

If rounded
=3.141593
et=0.00000035
Some machines use chopping, because rounding adds to the
computational overhead. Since number of significant figures
is large enough, resulting chopping error is negligible.

Chapter 3

21

Truncation Errors and the Taylor Series

Non-elementary functions such as trigonometric,
exponential, and others are expressed in an approximate
fashion using Taylor series when their values, derivatives,
and integrals are computed.
Any smooth function can be approximated as a
polynomial. 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.

Figure 4.1

Chapter23
4

Example:
To get the cos(x) for small x:

x2 x4 x6
cos x 1
2! 4! 6!
If x=0.5
cos(0.5) =1-0.125+0.0026041-0.0000127+
=0.877582
From the supporting theory, for this series, the error is
no greater than the first omitted term.
x8

8!

for

x 0.5 0.0000001
24

Any smooth function can be approximated as a

polynomial.
f(xi+1) f(xi) zero order approximation, only
true if xi+1 and xi are very close
to each other.
f(xi+1) f(xi) + f (xi) (xi+1-xi) first order
approximation, in form of a
straight line

Chapter 4

25

nth order approximation

f
f ( xi 1 ) f ( xi ) f ( xi )( xi 1 xi )
( xi 1 xi ) 2
2!
f (n)

( xi 1 xi ) n Rn
n!

(xi+1-xi)= h

f
( ) ( n 1)
Rn
h
(n 1)!
( n 1)

Reminder term, Rn, accounts for all terms from

(n+1) to infinity.
Chapter 4

26

is not known exactly, lies somewhere

between xi+1> >xi .
Need to determine f n+1(x), to do this you need
f '(x).
If we knew f(x), there wouldnt be any need to
perform the Taylor series expansion.
However, R=O(hn+1), (n+1)th order, the order
of truncation error is hn+1.
O(h), halving the step size will halve the error.
O(h2), halving the step size will quarter the
error.
Chapter 4

27

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.

Chapter28
4

Overflow: Any number larger than the largest number

that can be expressed on a computer will result in an
overflow.
Underflow (Hole) : Any positive number smaller than the
smallest number that can be represented on a computer
will result an underflow.
Stable Algorithm: In extended calculations, it is likely
that many round-offs will be made. Each of these plays
the role of an input error for the remainder of the
computation, impacting the eventual output. Algorithms
for which the cumulative effect of all such errors are
limited, so that a useful result is generated, are called
stable algorithms. When accumulation is devastating
and the solution is overwhelmed by the error, such
algorithms are called unstable.

Chapter 4

29

Figure 4.8

Chapter 4

30