Numerical
Computing
1
Chapter #1
Introduction
2
Why use Numerical Methods?
• To solve problems that cannot be solved exactly
x u2
1 e du
2
2
3
Why use Numerical Methods?
• To solve problems that are intractable!
4
How do we solve an engineering
problem?
Problem Description
Mathematical Model
Solution of Mathematical Model
Using the Solution
5
The Correct Model Would Account for
Varying Thermal Expansion Coefficient
Tc
D D(T)dT
Ta
6
Can You Roughly Estimate the
Contraction?
Tc
D D(T)dT Ta=80oF; Tc=-108oF; D=12.363”
Ta
Tc
D D(T)dT
Ta
7
Can You Find a Better Estimate for
the Contraction?
Tc
D D(T)dT
Ta
Ta = 80oF
Tc = -108oF
D = 12.363"
8
Estimating Contraction
Accurately
Change in diameter
(D) by cooling it in dry
ice/alcohol is given by
Tc
D D(T)dT
Ta
Ta = 80oF
Tc = -108oF
D = 12.363"
1.2278
105T2 6.1946
103T 6.0150
D0.0137
" 9
Introduction to Numerical Methods
Mathematical Procedures
10
Mathematical Procedures
• Nonlinear Equations
• Differentiation
• Simultaneous Linear Equations
• Curve Fitting
– Interpolation
– Regression
• Integration
• Ordinary Differential Equations
• Other Advanced Mathematical Procedures:
– Partial Differential Equations
– Optimization
– Fast Fourier Transforms
11
Nonlinear Equations
How much of the floating ball is under water?
Diameter=0.11m
Specific Gravity=0.6
x 0.165x 3.99310 0
3 2 4
12
Nonlinear Equations
How much of the floating ball is under the water?
f (x) x3 0.165x2 3.993104 0
13
Differentiation
What is the acceleration
at t=7 seconds?
v(t) 2200ln 16 4
10
9.8t a dv
1610 5000
t
4
dt
14
Differentiation
What is the acceleration at t=7 seconds?
Time (s) 5 8 12
Vel (m/s) 106 177 600
a dv
dt
15
Simultaneous Linear Equations
Find the velocity profile, given
Time (s) 5 8 12
Vel (m/s) 106 177 600
v(t) at2 btc, 5t 12
Three simultaneous linear equations
25a5bc 106
64a8bc 177
144a12bc 600
16
Interpolation
What is the velocity of the rocket at t=7 seconds?
Time (s) 5 8 12
Vel (m/s) 106 177 600
17
Regression
Thermal expansion coefficient data for cast steel
18
Regression (cont)
19
Integration
Finding the diametric contraction in a steel shaft when
dipped in liquid nitrogen.
Tfluid
D D dT
Troom
20
Measuring Errors
21
Why measure errors?
1) To determine the accuracy of numerical
results.
2) To develop stopping criteria for iterative
algorithms.
22
True Error
• Defined as the difference between the true value
in a calculation and the approximate value found
using a numerical method etc.
True Error = True Value – Approximate Value
23
Example—True Error
The derivative, f (x) of a function f (x) can be
approximated by the equation,
f ' (x) f (x h) f (x)
h
If f (x) 7e and h 0.3
0.5x
a) Find the approximate value of f ' (2)
b) True value of f ' (2)
c) True error for part (a)
24
Example (cont.)
Solution:
a) For x 2 and h0.3
f ' (2) f (20.3) f (2)
0.3
f (2.3) f (2)
0.3
7e 0.5(2.3)
7e0.5(2)
0.3
22.10719.028 10.263
0.3
25
Example (cont.)
Solution:
b) The exact value of f ' (2) can be found by using
our knowledge of differential calculus.
f (x) 7e0.5x
f ' (x) 70.5e0.5x
3.5e0.5x
So the true value of f ' (2) is
f ' (2) 3.5e0.5(2)
9.5140
True error is calculated as
Et True Value – Approximate Value
9.5140
10.2630.722
26
Relative True Error
• Defined as the ratio between the true
error, and the true value.
True Error
Relative True Error ( t ) =
True Value
27
Example—Relative True Error
Following from the previous example for true error,
find the relative true error for f (x) 7e0.5x at f '(2)
with h 0.3
From the previous example,
Et 0.722
Relative True Error is defined as
t TrueError
TrueValue
0.722 0.075888
9.5140
as a percentage,
100%7.5888
t 0.075888 %
28
Approximate Error
• What can be done if true values are not
known or are very difficult to obtain?
• Approximate error is defined as the
difference between the present
approximation and the previous
approximation.
Approximate Error ( Ea ) = Present Approximation – Previous Approximation
Example—Approximate Error
For f (x) 7e0.5x at x 2 find the following,
a) f (2) using h 0.3
b) f (2) using h0.15
c) approximate error for the value of f (2) for part b)
Solution:
a) For x 2 and h 0.3
f ' (x) f (x h) f (x)
h
f ' (2) f (20.3) f (2)
0.3
30
Example (cont.)
Solution: (cont.)
f (2.3) f (2)
0.3
7e 0.5(2.3)
7e0.5(2)
0.3
22.10719.028 10.263
0.3
b) For x 2 and h0.15
f ' (2) f (20.15) f (2)
0.15
f (2.15) f (2)
0.15
31
Example (cont.)
Solution: (cont.)
7e0.5(2.15)
7e0.5(2)
0.15
20.5019.028 9.8800
0.15
c) So the approximate error, Ea is
Ea Present Approximation – Previous Approximation
9.8800
10.263
0.38300
32
Relative Approximate Error
• Defined as the ratio between the
approximate error and the present
approximation.
Approximate Error
Relative Approximate Error ( a) =
Present Approximation
33
Example—Relative Approximate Error
For f (x) 7e0.5x
at x 2, find the relative approximate
error using values from h 0.3 and h0.15
Solution:
From Example 3, the approximate value of f (2) 10.263
using h 0.3 and f (2) 9.8800using h0.15
Ea Present Approximation – Previous Approximation
9.8800
10.263
0.38300
34
Example (cont.)
Solution: (cont.)
Approximate Error
a
Present Approximation
0.383000.038765
9.8800
as a percentage,
a 0.038765
100
% 3.8765
%
Absolute relative approximate errors may also need to
be calculated,
a |0.038765| 0.038765
or3.8765
%
35
How is Absolute Relative Error used as a
stopping criterion?
If |a| s where s is a pre-specified tolerance, then
no further iterations are necessary and the process is
stopped.
If at least m significant digits are required to be
correct in the final answer, then
|a| 0.5102m%
36
Table of Values
For f (x) 7e at x 2with varying step size, h
0.5x
h f (2) a m
0.3 10.263 N/A 0
0.15 9.8800 3.877% 1
0.10 9.7558 1.273% 1
0.01 9.5378 2.285% 1
0.001 9.5164 0.2249% 2
37