Singular Value Decomposition σ

advertisement
10.34, Numerical Methods Applied to Chemical Engineering
Professor William H. Green
Lecture #26: TA led Review
Singular Value Decomposition
Amxn = Umxm Smxn VnxnT
⎡
⎢
⎢
⎢
⎢
⎢
⎢⎣
⎤ ⎡
⎥ ⎢
⎥ ⎢
⎥=⎢
⎥ ⎢
⎥ ⎢
⎥⎦ ⎢⎣
U
U-1 = UT
V-1 = VT
0⎤
⎤ ⎡σ 1
⎥⎢
⎥⎡
σ2
⎥⎢
⎥⎢
⎥⎢
⎥⎢
%
⎥⎢
⎥⎢
σ
n
⎥⎢
⎥⎢
⎣
⎥⎦ ⎢⎣ 0
0 ⎥⎦
S
⎤
⎥
⎥
⎥
⎥
⎦
VT
A = U·S·VT
σ1 ~ 0
⎡1
⎢ σ1
⎢
S-1 = ⎢
⎢
⎢
⎢⎣ 0
UT·A = (UTU)S·VT
0⎤
⎥
⎥
⎥ 1/σ1 Æ ∞ (treat it as zero)
⎥
⎥
% 0⎥⎦
0
1
σ2
1
σ3
UT·A = I·S·VT
V·S-1UT·A = I·S·VTV·S-1
A·x = b
x = A-1b
A-1 = V·S-1UT
x = V·S-1UT·b
Ordinary Differential Equations
dxnm/dt = Fn(x)
x = x(to) +
∫ F (x(t ) )dt
t
to
Trapezoidal Rule:
f3
f2
f1
to
t1
t2
Error = O(∆t3)xN Î O(∆t2)
Figure 1. Integration by the
Trapezoidal Rule.
Simpson’s Error
Error = O(∆t5)xN Î O(∆t4)
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Romberg Method (Richardson Extrapolation)
∫
tn
Ftrue =
∫
tn
Ftrue =
4
1
F ( 2 N ) − F ( N ) + O (Δt )3
3
3
Ftrue =
f(t)
t0
tn
t0
t0
f (t ) dt ~ F ( N ) + C ( Δt ) 2 + ...
2
⎛ Δt ⎞
f (t ) dt ~ F ( 2 N ) + C ⎜ ⎟ + ...
⎝ 2 ⎠
(
)
Figure 2. Integration by the
Romberg Method.
N Æ ∆t
2N Æ
∆t
/2
ODE Solvers
Explicit Euler
xn+1 = xn + F(xn)h + O(h2)
Runge Kutta
xn
xn+1
Figure 3. Runge Kutta Integration of differential equations.
Runge-Kutta-order 5 Æ 6 function evaluations per time steps
use intermediate value to calculate
Ode45 uses R-K 6 function evaluation
Stiff differential equation
x = a·e-t + b·e-1000000t{ rate of time change are 1,000,000 times different
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 26
Page 2 of 5
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Figure 4. Example solution to differential equation.
must use many time steps; if big steps are used, you will oscillate around the solution.
dx
= −c ⋅ x
dt
∆t < 2/λmax
Must use Implicit Method
Predictor-Corrector Method
polynomial
tn-k tn-k+1
tn tn+1
Figure 5. Predictorcorrector method.
DAE
⎛dx⎞
M ( X )⎜
⎟ = F (X )
⎝ dt ⎠
⎤
⎡
⎥ = f(x)
⎢
⎥
⎢
⎢⎣0 0 0⎥⎦
“ode23t,”
“ode15i”
Optimization
minx f(x)
g(x) = 0
i = 1...ne
h(x) ≥ 0
i = 1...ni
CONSTRAINTS
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 26
Page 3 of 5
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
If no constraints:
⎛ ∂f
⎞
⎜ ∂x ⎟
1
⎜
⎟
∂
f
⎟
Gradient Method: Vf = ⎜
⎜ ∂x 2 ⎟
⎜⎜ ∂f
⎟⎟
⎝ ∂x n ⎠
If no gradient given: fminsearch
Figure 6. Gradient method contours.
Conjugate gradient method
As you get closer to the minimum, Newton’s Method gives good convergence:
Vxn = -Hn-1·Vfn
⎡ ∂2 f
⎢
2
⎢ ∂x1
#
H= ⎢
⎢ ∂2 f
⎢
⎣ ∂x n ∂x1
∂2 f
∂x1∂x 2
"
∂2 f ⎤
⎥
∂x1∂x n ⎥
⎥
2
⎥
f
∂
2 ⎥
∂x n ⎦
No Constraints: Broyden-Fletcher-Goldfarb-Shanno Method (BFGS)
With Constraints
Vf Æ Vgi(x)
Lagrangian
ne
Vf =
∑ λ i ∇g i ( x )
ne
L(x,λ) = f
i =1
VxL = 0
∑ λ ∇g ( x )
i =1
i
i
VλL = 0
L(x,λ) = f – Σλigi(x) + Σ(1/2μi)[gi(x)]2
KKT
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 26
Page 4 of 5
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
ne
L(x,λ,k) = f(x) -
ni
∑ λ g ( x) − ∑ k h ( x)
i =1
i
VL = 0
gi(x) = 0
hi(x) ≥ 0
ki ≥ 0
i
i i
i =1
hjkj = 0
Sequential Quadratic Programming (SQP)
minx f(x)
cm(x) – sm = 0
for equality constraints: sm = 0
for nonequality constraints: sm ≥ 0
Boundary Value Problems
⎡ ∂ 2φ ∂ 2φ ∂ 2φ ⎤
∂φ
∂φ
∂φ
vx
+ vy
+ vz
= D ⎢ 2 + 2 + 2 ⎥ + S (φ )
∂x
∂y
∂z
∂y
∂z ⎦
⎣ ∂x
∂φ
∂x
=
xn
φ n − φ n −1
x n − x n −1
∂ 2φ
∂x 2
+ O(Δx)
Types of BC: φ(xo) = φo;
∂φ
∂x
=
xn
=
xn
φ n −1 − 2φ n + φ n +1
2Δx
− 3φ o + 4φ1 − φ 2
=0
2 Δx
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 26
Page 5 of 5
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Download