Numerical Integration Techniques: A Brief Introduction
Numerical Integration Techniques: A Brief Introduction
Numerical Integration
Techniques
A Brief Introduction
+
Objectives
Start
Make
Make
CUDA acceleration
+
Schedule
+
Preliminaries
Basic
Calculus
Derivatives
Taylor series expansion
w dw
Basic
Programming Skills
Octave
+
Numerical Differentiation
Definition of Differentiation
df
f (x h) f (x)
f '(x) lim
h0
dx
h
+
Numerical Differentiation
Forward Difference
Approximation Formula
df
f (x h) f (x)
f '(x)approx
dx
h
Is it accurate?
+
Numerical Differentiation
Error Analysis
1 2
1 3
f(x h) f (x) hf '(x) h f ''(x) h f '''(x)
2
6
which implies
f (x h) f (x)
1
1 2
f '(x)approx
f '(x) hf ''(x) h f '''(x)
h
2
6
Truncation Error
1
1 2
et hf ''(x) h f '''(x) O(h)
2
6
+
Numerical Differentiation
Error Analysis
Roundoff Error
Denoted
Total Error
er
e et er
10
+
Numerical Differentiation
Backward Difference
Definition
f (x) f (x h)
f '(x)approx
h
Truncation Error
1
1
et hf ''(x) h2 f '''(x) O(h)
2
6
No Improvement!
11
+
Numerical Differentiation
Central Difference
Definition
f (x h) f (x h)
f '(x)approx
2h
Truncation Error
1 2
1 4 (5)
et h f '''(x)
h f (x) O(h2 )
6
120
12
+
Numerical Differentiation
13
Example
f (x) ex
At point x=1.15
14
+
Numerical Differentiation
Multi-dimensional & High-Order
Multi-dimensional
2
dx dx dx
4h2
High-Order
xy y x
4h2
15
+
Euler Method
16
IVP
The
Differential Equations
Initial Conditions
y(t0 ) y0
Problem
+
Euler Method
17
Forward Difference
y(t t) y(t)
y'(t)
t
Which
implies
+
Euler Method
18
t0 0
ti i t
t t
n
The
+
Euler Method
Explicit Euler Method - Algorithm
19
+
Euler Method
20
We
t
et O(t2 ) O(t)
t
This
+
Euler Method
21
Backward Difference
y(t) y(t t)
y'(t)
t
Which
implies
+
Euler Method
22
+
Euler Method
23
A Simple Example
Try
to solve IVP
y'(t) et t
y(0) 1
What
The
analytical solution is
1 2
y e t 2
2
t
+
Euler Method
24
A Simple Example
Using
yi1 yi dt(e ti )
We
choose
accuracy
+
Euler Method
25
A Simple Example
0.1
0.2
0.3
0.4
0.5
exact
dt=0.0
5
error
dt=0.0
25
error
dt=0.0
125
error
+
Euler Method
26
Instability
For
y'(t) ky(t), k 0
The
choice of t matters!
+
Euler Method
27
Instability
Assume
k=5
y'(t) 5y(t)
y(0) 1
Analytical
Solution is
5t
y(t) e
Try
28
1
0 1 tk 1 t
k
29
30
2
t 1 tk 1
k
+
Euler Method
31
exact
dt=0.5
0.4
0.135335
0.8
1.2
1.6
2
error
dt=0.2
5
error
dt=0.0
02
error
+
Euler Method
32
yi1 yi dt5yi1
Which
implies
yi
yi1
1 5dt
33
Choose dt=0.5,
Oscillation eliminated!
Not elegant, but works.
+
The Three-Variable Model
Single Cell
The
Differential Equations
tV (DV) (I fi I so I si ) I ext
tv (1 p)(1 v) / v pv/ v
w
(1
p)(1
w)
/
pw/
w
w
t
I fi vp(V Vc )(V Vm) / d
I so (V Vo )(1 p) / o p/ r
I si w(1 tanh[k(V Vcsi )]) / (2 si )
p
1 if V Vc
0 if V Vc
1 if V VV
0 if V VV
34
+
The Three-Variable Model
Single Cell
Simplify
the model
tV (I fi I so I si ) I ext
1 if V 72
0 if V 72
1 if V 79.5
0 if V 79.5
35
+
The Three-Variable Model
Single Cell
Using
36
+
The Three-Variable Model
Single Cell
At
37
+
The Three-Variable Model
Single Cell
At
38
39
+
Heat Diffusion Equations
The
Model
The
u
u
t
u f
t0
The
40
+
Heat Diffusion Equation
Laplace Operator
Laplace
Operator (Laplacian)
f 2 f (f )
Divergence
div( f ) f
Gradient
41
+
Heat Diffusion Equation
Laplace Operator
Meaning
u (u)
(thegradientof temperaturedistribution)
themagnitudeof temperaturechangeover space
Meaning
42
+
Heat Diffusion Equation
Laplace Operator
Cartesian
coordinates
x1, x2 ,, xn
n
2 f
f 2
i1 xi
1D
space (a cable)
2 f
f 2
x
43
+
Heat Diffusion Equation
Laplace Operator
Compute
Similar
to Numerical Differentiation
44
+
Heat Diffusion Equation
Laplace Operator
Boundaries
Assume
0
2x
f (x) f (x)
Laplacian
at boundaries
f
x0
x2
x2
45
+
Heat Diffusion Equation
Exercise
Write a program in
Octave to solve the
following heat diffusion
equation on 1d space:
u
t u
u(x, 0) 10sin(
0 x 10
0.9
x
)
10
46
+
Heat Diffusion Equation
Exercise
TIPS:
Write a program in
Octave to solve the
following heat diffusion
equation on 1d space:
u
t u
u(x, 0) 10sin(
0 x 10
0.9
x
)
10
47
48
+
Heat Diffusion Equation
Discrete Form
49
+
Heat Diffusion Equation
Stability
2dt
0 1
1
2
dx
2dt dx2
50
+
The END
Thank You!
51