Week1 Introduction
Week1 Introduction
Analysis
1
Rules in class
Reference book:
• Steven C. Chapra, Raymond P. Canale,
“Numerical Methods for Engineers, 6th edition”,
McGraw-Hill.
2
Learning outcomes
3
Introduction
Why study Numerical Analysis?
4
Introduction
5
Introduction
A few applications of Numerical Methods in Engineering:
• Communication/power
Network simulation
Train and traffic networks
6
Introduction
7
Introduction
8
My research: CFD
9
My research: CFD
10
Next: What is yours?
11
Part 1
Introduction
12
Introduction
Why study Numerical Methods?
Numerical Analysis is a Discipline:
Need to understand concepts and theory
- Know what problems can be solved.
- Know what problems cannot be solved, or when
problems will be troublesome.
Need to understand methods and techniques
- Know why methods work, or judge when they are
working.
- Be able to create or modify tools (software) as
needed.
- Evaluate errors, convergence, and stability of
arithmetic approximations.
13
Introduction
14
Introduction
15
Outlines of the Course
16
Introduction
• Roots of equations :
– We will be interested in
x 0 \ f ( x 0 ) 0.
methods for solving
17
Introduction
a11x1 a12x 2 b1
a 21x1 a 22x 2 b 2
– We will study methods for
computing the set of values
that simultaneously satisfy
a system of algebraic
equations.
– Applications: calculus of
structures, electric circuits,
supply networks, fit of
curves, etc.
18
Introduction
• Optimization:
19
Introduction
• Fitting curves. Fitting techniques can be divided into two groups:
20
Introduction
• Integration:
b
I f ( x )dx
a
– Determine the area
f(x)
below a given curve.
a b x
– It can also be used to
solve differential
equations.
21
Introduction
• Ordinary differential
equations :
dy
= f ( t; y)
dt
22
Introduction
• Partial differential
equations:
2u 2u
f ( x, y )
2 2
x y
y
– Used for characterizing
engineering problems
where the behavior of the
physical magnitude can
be expressed in terms of
speed change with
respect to two or more
variables.
– Approximation by finite x
differences or the finite
element method.
23
Chapter 1
24
Engineering Problem Solving
25
Mathematical Model
dv mg cv c(Kg / s )
;
dt m
• Analytic solution (t=0, v=0):
c
v ( t i 1 ) v ( t i ) g v ( t i ) ( t i 1 t i )
m FD
27
Analytical solution to Newton's Second Law
28
Analytical solution to Newton's Second Law
29
Numerical Solution to Newton's Second Law
Suppose
30
Mathematical Models
• To solve the problem numerically, one replaces the derivative by
a finite difference, thus transforming the problem into a very
simple one containing only simple algebraic operations:
31
Numerical Solution to Newton's Second Law
32
Comparison between Analytical vs. Numerical
Solution
33
Mathematical Models
• To solve the problem numerically, one replaces the derivative by
a finite difference, thus transforming the problem into a very
simple one containing only simple algebraic operations:
34
Numerical Differentiation
f x i1 f x i
Forward: f xi
h
f x i1 f x i1
Centered: f xi
2h
How big a step size should we select?
One- or two-sided formula:
What are the advantages of each?
How is optimal step size affected by:
- precision of numerical calculations?
- precision with which f is computed?
- choice of formula?
35
Chapter 2
36
• Structured Programming
• Modular Programming (module, function)
• Flowchart
• Algorithm
37
Chapter 3
38
APPROXIMATION AND ERRORS
Numerical Methods
Instead of solving for the exact solution we solve
math problems with a series of arithmetic
operations.
b
1
Example: x dx
a
analytical solution: ln(b) – ln(a)
numerical solution e. g., Trapezoidal Rule
Error Analysis
(a) identify the possible sources of error
(b) estimate the magnitude of the error
(c) determine how to minimize and control error
39
Mathematical Models
• Comparing solutions:
Numerical solution, Dt=2sec
60
50
40
Exact solution
V (m/sec)
30
10
0
0 2 4 6 8 10 12 14 16 18 20
T (sec)
40
Approximations and Rounding Errors
• Unfortunately, computers introduce errors in the calculations.
However, since many engineering problems have not analytical
solution, we are forced to use numerical methods
(approximations). The only option we have is to accept the error
and try to reduce it up to a tolerable level.
• The only way of minimizing the errors is by knowing and
understanding why they occur and how we can diminish them.
• The most frequent errors are:
– Rounding errors, due to the fact that computers can work
only with a finite representation of numbers.
– Truncation errors, due to differences between the exact
and the approximate (numeric) formulations of the
mathematical problem being dealt with. penyederhanaan dari persamaan
yang kompleks
• Before analyzing each one of them, we will see two important
concepts on the computer representation of numbers.
41
Approximations and Rounding Errors
• Significant figures of a number:
42
Approximations and Rounding Errors
43
Approximations and Rounding Errors
• Accuracy and precision:
– The errors associated with
measurements can be
characterized observing
their accuracy and
precision.
45
Approximations and Rounding Errors
• Error definitions:
– True value = approximation + absolute error.
– Absolute error = true value - approximation .
– Relative error = absolute error / true value .
absolute error
t 100%
true value
– In real cases not always one can know the true value, thus:
aproximate error
a 100%
approximate value
46
Approximations and Rounding Errors
– Thus, the stopping criterium of a numerical method can be:
a s
s prefixed percent tolerance
s (0.5 * 102n )%
47
Approximations and Rounding Errors
• Numerical systems:
– A numerical system is a
104 103 102 101 100
convention to represent
8 6 4 0 9
quantities. Since we have
10 fingers in our hands, the 9x
0x
1=
10 =
9
0
4 x 100 = 400
most popular numerical 6 x 1000 = 6000
a) 8 x 10000 = 80000
system has basis 10. It uses 86409
10 different digits. 27 26 25 24 23 22 21 20
1 0 1 0 1 1 0 1
representation.
48
Round-off Errors
(anan-1...a1a0.b1b2..bk..)q
(anan-1...a1a0.b1b2..bk..)q =anqn+an-1qn-1+...+a1q+a0q0+b1q-1+b2q-2+...
Example:
(1011.01)2=1x23+0x22+1x2+1x20+0x2-1+1x2-2=11.25
49
Round-off Errors
Example:
(26.1)10=(11010.00011)2
50
Round-off Errors
51
Approximations and Rounding Errors
52
Approximations and Rounding Errors
• Floating point representation:
– This representation is used for fractional quantities. It has
the fraction part, called mantissa, and an integer part, called
exponent or characteristic.
m * be
53
Approximations and Rounding Errors
• IEEE-floating point formats: there are two types of
“precision” (simple and double). They differ in the
number of digits available for storing the numbers:
• Simple precision (32 bits): 1 bit for the sign, 8 bits
for the exponent, 23 bits for the mantissa.
• Double precision (64 bits, two words of 32 bits): 1
bit for the sign, 11 bits for the exponent, 52 bits for
the mantissa.
54
IEEE 754 Floating-Point Standard
S Exponent8 Fraction23
S Exponent11 Fraction52
(continued)
55
Significant Digits
56
Chopping
Example:
=3.14159265358 to be stored on a base-10 system
carrying 7 significant digits.
=3.141592 chopping error t=0.00000065
If rounded
=3.141593 t=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.
57
Rounding and Chopping
• Machine epsilon:
58
Round-off error