Fin500J Mathematical Foundations in Finance - PowerPoint PPT Presentation

About This Presentation
Title:

Fin500J Mathematical Foundations in Finance

Description:

... 3_Flow 4_Flow 5_Flow 6_Flow 7_Flow Microsoft Equation 3.0 Slide 1 Numerical Solutions Taylor Series Method Taylor Series Expansion First Order ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 46
Provided by: dybfinWus
Learn more at: https://dybfin.wustl.edu
Category:

less

Transcript and Presenter's Notes

Title: Fin500J Mathematical Foundations in Finance


1
  • Fin500J Mathematical Foundations in Finance
  • Topic 7 Numerical Methods for Solving Ordinary
    Differential EquationsPhilip H. Dybvig
  • Reference Numerical Methods for Engineers,
    Chapra and Canale, chapter 25, 2006
  • Slides designed by Yajun Wang

2
Numerical Solutions
  • Numerical method are used to obtain a graph or a
    table of the unknown function
  • Most of the Numerical methods used to solve ODE
    are based directly (or indirectly) on truncated
    Taylor series expansion
  • Taylor Series methods
  • Runge-Kutta methods

3
Taylor Series Method
  • The problem to be solved is a first order ODE

Estimates of the solution at different base
points are computed using truncated Taylor
series expansions
4
Taylor Series Expansion
nth order Taylor series method uses nth
order Truncated Taylor series expansion
5
First Order Taylor Series Method(Euler Method)
6
Euler Method
7
Interpretation of Euler Method
y2
y1
y0
x0 x1 x2
x
8
Interpretation of Euler Method
Slopef(x0,y0)
y1
y1y0hf(x0,y0)
hf(x0,y0)
y0
x0 x1 x2
x
h
9
Interpretation of Euler Method
y2y1hf(x1,y1)
y2
Slopef(x1,y1)
hf(x1,y1)
Slopef(x0,y0)
y1y0hf(x0,y0)
y1
hf(x0,y0)
y0
x0 x1 x2
x
h
h
10
High Order Taylor Series methods
11
Runge-Kutta Methods (Motivation)
  • We seek accurate methods to solve ODE that does
    not require calculating high order derivatives.
  • The approach is to a formula involving unknown
    coefficients then determine these coefficients to
    match as many terms of the Taylor series
    expansion

12
Runge-Kutta Method
13
Taylor Series in One Variable
Approximation
Error
14
Taylor Series in One Variableanother look
15
Definitions
16
Taylor Series Expansion
17
Taylor Series in Two Variables
yk
y
x
xh
18
Runge-Kutta Method
19
Runge-Kutta Method
20
Runge-Kutta Method
21
Runge-Kutta Method
22
Runge-Kutta MethodAlternative Formulas
23
Runge-Kutta Methods

24
Runge-Kutta Methods

25
Runge-Kutta Methods
Higher order Runge-Kutta methods are
available Higher order methods are more
accurate but require more calculations. Fourth
order is a good choice. It offers good accuracy
with reasonable calculation effort
26
Example 1Second Order Runge-Kutta Method

27
Example 1Second Order Runge-Kutta Method

28
Example 1Summary of the solution

Summary of the solution
29
Solution after 100 steps
30
Numerically Solving ODE in Matlab
  • Matlab has a few different ODE solvers, Matlab
    recommends ode45 is used as a first solver for a
    problem
  • ode45 uses simultaneously fourth and fifth order
    Runge-Kutta formula (DormandPrince)

31
Numerically Solving ODE in Matlab (Example 1)
  • Step 1 Create a M-file for dy/dx as firstode.m
  • function yprimefirstode(x,y)
  • yprime1y2x3
  • Step 2 At a Matlab command window
  • gtgtx,yode45(_at_firstode,1,2,-4)
  • gtgt x,y
  • Matlab returns two column vectors, the first with
    values of x and the second with value of y.

32
Numerically Solving ODE in Matlab (Example 1)
gtgt plot(x,y,'')
33
Solving a system of first order ODEs
  • Methods discussed earlier such as Euler,
    Runge-Kutta,are used to solve first order
    ordinary differential equations
  • The same formulas will be used to solve a system
    of first order ODEs. In this case, the
    differential equation is a vector equation and
    the dependent variable is a vector variable.

34
Euler method for solving a system of first order
ODEs
  • Recall Euler method for solving first order ODE.

35
Solving a system of n first order ODEs using
Euler method
  • Exactly the same formula is used but the scalar
    variables and functions are replaced by vector
    variables and vector values functions.
  • Y is a vector of length n
  • F(Y,x) is vector valued function

36
Example Euler method for solving a system of
first order ODEs

37
Example RK2 method for solving a system of
first order ODEs

38
Example RK2 method for solving a system of
first order ODEs

39
The general approach to solve high order ODE
convert
solve
high order ODE
System of first order ODE
convert
solve
Second order ODE
Two first order ODEs
40
Conversion Procedure
convert
solve
high order ODE
System of first order ODE
  • Select of dependent variables
  • One way is to take the original dependent
    variable and its derivatives up to one degree
    less than the highest order derivative.
  • Write the Differential Equations in terms of the
    new variables. The equations comes from the way
    the new variables are defined or from the
    original equation.
  • Express the equations in matrix form

41
Example of converting High order ODE to first
order ODEs
One degree less than the highest order derivative
42
Example of converting High order ODE to first
order ODEs
43
Numerically Solving high order ODE in Matlab
  • Step 1 First convert the second order equation
    to an equivalent system of first order ODEs, let
    z1y, z2y

44
Numerically Solving high order ODE in Matlab
  • Step 2 Create the following M-file and save it
    as F.m
  • function zprimeF(x,z)
  • zprimezeros(2,1) since output must be a
    column vector
  • zprime(1)z(2)
  • zprime(2)-xz(1)exp(x)z(2)3sin(2x)
  • Step 3 At Matlab prompt
  • gtgt x,zode45(_at_F,0,1,2,8)
  • Since z1(x)y, to print out the solution y
  • gtgt x,z(,1)

45
Numerically Solving ODE in Matlab (Example 1)
To plot y against x gtgt plot(x, z(,1))
Because the vector z has first component
z1y
Write a Comment
User Comments (0)
About PowerShow.com