Professional Documents
Culture Documents
A) -2
B) 1
C) 2
D) 4
E) 8
A) -12
B) -10
C) -6
D) 6
E) 12
E7 – Lecture Series
Lecture 23
• Monte-Carlo Integration
• Numerical Methods for Ordinary Differential
Equations (I)
Fall 2021
Instructor: Shaofan Li
Four-dimensional Sphere
Summary of Accuracy for Numerical Integration
Bonus Point
What is Monte Carlo Simulation (MCS) method ?
and variance
Summary: Monte Carlo Integration Method
Sample Mean MC algorithm
Central limit theorem says that mean of the distribution of the sample means is equal to
the population mean irrespective of the distribution of the population when the sample size
is greater than 30.
To understand the Central Limit Theorem is to know where God is living.
------------ Anonymous
II. Ordinary Differential Equations
• Many practical problems in science and engineering involve rates (derivatives).
• Equations which are composed of an unknown function and its derivatives are called
differential equations (DEs)
Examples from: Numerical Methods for Engineers by S.C. Chapra and R.P. Canale
Classification of Differential Equations
DEs can be divided into several types: Ordinary/Partial, Linear/Non-Linear…
where
𝑑2𝑢 𝑑𝑢
𝑡 = 𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 𝑢ሷ = 𝑢ሶ =
𝑑𝑡 2 𝑑𝑡
Ordinary Differential Equations (ODEs)
Example: Simple Pendulum
In practice, we are interested in finding a solution that satisfy some constraints, which is called
the particular solution of the DE. These constraints are called as boundary conditions.
Consider the free falling of an object under gravity, which is defined by the 2nd order ODE:
𝑑2 𝑥
2
=𝑔
𝑑𝑡
We can integrate this equation two times to obtain the general solution (with two constants):
𝑑𝑥 1 2
= 𝑔𝑡 + 𝐶1 𝑥 = 𝑔𝑡 + 𝐶1 𝑡 + 𝐶2
𝑑𝑡 2
Notice that 𝐶1 is the initial velocity and 𝐶2 is the initial position of the object:
1 2
𝑥 = 𝑔𝑡 + 𝑣0 𝑡 + 𝑥0
2
We need two boundary conditions (initial velocity and position) to obtain the particular solution!
Solutions to ODEs: Analytical Solution
If we assume that rotations are small, we can use the small-angle approximation
Previous examples are rare cases where we can obtain the analytical solution easily,
since the problem is simple enough or we can make assumptions to simplify the problem.
Consider the first order ODE defined on an interval with a given boundary (or initial) condition:
𝑑𝑦
= 𝑓(𝑡, 𝑦) 𝑡 ∈ [𝑡0 , 𝑡𝑛 ] 𝑦(𝑡 = 𝑡0 ) = 𝑦0
𝑑𝑡
We can divide the interval into equal lengths of h (step-size) to obtain the numerical grid:
[𝑡0 , 𝑡1 , 𝑡2 , … , 𝑡𝑛−1 , 𝑡𝑛 ] where 𝑡0 < 𝑡1 < 𝑡2 , … , 𝑡𝑓−1 < 𝑡𝑛 and 𝑡𝑖+1 = 𝑡𝑖 + ℎ 𝑓𝑜𝑟 𝑖 = 1,2, … , 𝑛
Starting with the initial value 𝑦0 , we can predict the next function value by making use of
the slope at 𝑡0 to extrapolate linearly over the step size h
𝑦1 = 𝑦0 + ℎ ∙ 𝑓 𝑡0 , 𝑦0
Euler’s Method
𝑦1 = 𝑦0 + ℎ ∙ 𝑓 𝑡0 , 𝑦0
𝑦1 = 𝑦0 + ℎ ∙ 𝑓 𝑡0 , 𝑦0
𝑦2 = 𝑦1 + ℎ ∙ 𝑓 𝑡1 , 𝑦1
𝑦3 = 𝑦2 + ℎ ∙ 𝑓 𝑡2 , 𝑦2
𝑦𝑖+1 = 𝑦𝑖 + ℎ ∙ 𝑓 𝑡𝑖 , 𝑦𝑖
𝑦2 𝑦3 𝑦4
The algorithm is ‘explicit’ since it only requires information at
𝑦1
the previous time step 𝑡𝑖 to compute the state at 𝑡𝑖+1
𝑡
Implicit Euler Method
𝑡 ∈ [𝑡0 , 𝑡𝑛 ] 𝑦(𝑡 = 𝑡0 ) = 𝑦0
𝑑𝑦
= 𝑓(𝑡, 𝑦)
𝑑𝑡
Another method can be derived using the 1st order Taylor expansion around 𝑡𝑖+1 and evaluating it at 𝑡𝑖
𝑦 0 =1 𝑥 ∈ [0,4]
Euler’s method converges to the analytical solution as step size gets smaller.