Fin500J: Mathematical Foundations in Finance Topic 6: Ordinary Differential Equations Philip H. Dybvig Reference: Lecture Notes by Paul Dawkins, 2007, page 20-33, page 102-121, page 137-155 and page 340-344 http://tutorial.math.lamar.edu/terms.aspx Slides designed by Yajun Wang Fin500J Topic 6 Fall 2010 Olin Business School 1 Introduction to Ordinary Differential Equations (ODE) Recall basic definitions of ODE, order linearity initial conditions solution Classify ODE based on( order, linearity, conditions) Classify the solution methods Fin500J Topic 6 Fall 2010 Olin Business School 2 Derivatives Derivatives Ordinary Derivatives u y dy dx y is a function of one independent variable Fin500J Topic 6 Fall 2010 Partial Derivatives Olin Business School u is a function of more than one independent variable 3 Differential Equations Differential Equations Ordinary Differential Equations Partial Differential Equations 2 d y 6 xy 1 2 dx involve one or more Ordinary derivatives of unknown functions Fin500J Topic 6 Fall 2010 Olin Business School u u 2 0 2 y x 2 2 involve one or more partial derivatives of unknown functions 4 Ordinary Differential Equations Ordinary Differential Equations (ODE) involve one or more ordinary derivatives of unknown functions with respect to one independent variable Examples : dy y ex dx d2y dy 5 2 y cos( x) 2 dx dx y(x): unknown function x: independent variable Fin500J Topic 6 Fall 2010 Olin Business School 5 Order of a differential equation The order of an ordinary differential equations is the order of the highest order derivative Examples : dy y ex dx d2y dy 5 2 y cos( x) 2 dx dx d y 2 dx 2 Fin500J Topic 6 First order ODE Second order ODE 3 dy 2 y 4 1 dx Fall 2010 Olin Business School Second order ODE 6 Solution of a differential equation A solution to a differential equation is a function that satisfies the equation. Example : dx(t ) x(t ) 0 dt Fin500J Topic 6 Fall 2010 Solution x(t ) e t Proof : dx(t ) e t dt dx(t ) x(t ) e t e t 0 dt Olin Business School 7 Linear ODE An ODE is linear if the unknown function and its derivatives appear to power one. No product of the unknown function and/or its derivatives an ( x) y n ( x) an 1 ( x) y n 1 ( x) a1 ( x) y ' ( x) a0 ( x) y ( x) g ( x) Examples : dy y ex dx d2y dy 2 5 2 x y cos( x) 2 dx dx Linear ODE Linear ODE 3 d 2 y dy 2 y 1 dx dx Fin500J Topic 6 Fall 2010 Non-linear ODE Olin Business School 8 Boundary-Value and Initial value Problems Boundary-Value Problems Initial-Value Problems The auxiliary conditions are at one point of the independent variable The auxiliary conditions are not at one point of the independent variable More difficult to solve than initial value problem 2 x y ' '2 y ' y e y (0) 1, y ' (0) 2.5 same Fin500J Topic 6 y ' '2 y ' y e 2 x y (0) 1, y (2) 1.5 different Fall 2010 Olin Business School 9 Classification of ODE ODE can be classified in different ways Order First order ODE Second order ODE Nth order ODE Linearity Linear ODE Nonlinear ODE Auxiliary conditions Initial value problems Boundary value problems Fin500J Topic 6 Fall 2010 Olin Business School 10 Solutions Analytical Solutions to ODE are available for linear ODE and special classes of nonlinear differential equations. Numerical method are used to obtain a graph or a table of the unknown function We focus on solving first order linear ODE and second order linear ODE and Euler equation Fin500J Topic 6 Fall 2010 Olin Business School 11 First Order Linear Differential Equations Def: A first order differential equation is said to be linear if it can be written y p ( x) y g ( x) Fin500J Topic 6 Fall 2010 Olin Business School 12 First Order Linear Differential Equations How to solve first-order linear ODE ? y p( x) y g ( x) (1) Sol: Multiplying both sides by (x ) , called an integrating factor, gives dy ( x) ( x) p( x) y ( x) g ( x) (2) dx assuming ( x) p( x) ' ( x), (3) we get dy ( x) ' ( x) y ( x) g ( x) (4) dx Fin500J Topic 6 Fall 2010 Olin Business School 13 First Order Linear Differential Equations By product rule, (4) becomes ( ( x) y ( x))' ( x) g ( x) (5) ( x) y ( x) ( x) g ( x)dx c1 ( x) g ( x)dx c y ( x) 1 ( x) (6) (x ) from (3) ' ( x) ( x) p ( x) ' ( x) p( x) ( x) Now, we need to solve Fin500J Topic 6 Fall 2010 Olin Business School 14 First Order Linear Differential Equations ' ( x) p( x) (ln ( x))' p( x) ( x) ln ( x) p( x)dx c2 ( x) e p ( x ) dx c2 c3e p ( x ) dx (7 ) to get rid of one constant, we can use ( x) e p ( x ) dx (8) The solution t o a linear first order differenti al equation is then ( x) g ( x)dx c y ( x) e Fin500J Topic 6 p ( x ) dx Fall 2010 (9) Olin Business School 15 Summary of the Solution Process Put the differential equation in the form (1) Find the integrating factor, (x ) using (8) Multiply both sides of (1) by (x ) and write the left side of (1) as ( ( x) y ( x))' Integrate both sides Solve for the solution y (x) Fin500J Topic 6 Fall 2010 Olin Business School 16 Example 1 y y e 2x Sol: e p ( x ) dx g ( x)dx c ( 1) dx ( 1) dx 2 x e e e dx c y ( x) e p ( x ) dx e x e x e 2 x dx c ex ex c ce e x Fin500J Topic 6 Fall 2010 2x Olin Business School 17 Example 2 Sol: y ' 1 xy'2 y x x, y (1) 2 2 2 y x 1 x y ( x) e p ( x ) dx e p ( x ) dx g ( x)dx c 2 2 x dx x dx 2 2 e e ( x 1 ) dx c x x ( x 1)dx c 1 3 1 2 1 2 1 4 x x x c x x cx 2 3 3 4 4 Apply the initial condition to get c, 1 1 1 7 cc . 2 4 3 12 Fin500J Topic 6 Fall 2010 Olin Business School 18 Second Order Linear Differential Equations Homogeneous Second Order Linear Differential Equations o real roots, complex roots and repeated roots Non-homogeneous Second Order Linear Differential Equations o Undetermined Coefficients Method Euler Equations Fin500J Topic 6 Fall 2010 Olin Business School 19 Second Order Linear Differential Equations The general equation can be expressed in the form ay ' 'by 'cy g ( x) where a, b and c are constant coefficients Let the dependent variable y be replaced by the sum of the two new variables: y = u + v Therefore au' 'bu'cu av' 'bv'cv g ( x) If v is a particular solution of the original differential equation purpose au' 'bu'cu 0 The general solution of the linear differential equation will be the sum of a “complementary function” and a “particular solution”. Fin500J Topic 6 Fall 2010 Olin Business School 20 The Complementary Function (solution of the homogeneous equation) ay ' 'by ' cy 0 Let the solution assumed to be: dy re rx dx e rx (ar 2 br c) 0 y e rx d2y 2 rx r e 2 dx characteristic equation Real, distinct roots Double roots Complex roots Fin500J Topic 6 Fall 2010 Olin Business School 21 Real, Distinct Roots to Characteristic Equation • Let the roots of the characteristic equation be real, distinct and of values r1 and r2. Therefore, the solutions of the characteristic equation are: y e r1x y e r2 x • The general solution will be y c1e r1x c2e r2 x • Example y ' '5 y '6 y 0 r1 2 r2 3 Fin500J Topic 6 Fall 2010 r 2 5r 6 0 y c1e 2 x c2e3 x Olin Business School 22 Equal Roots to Characteristic Equation • Let the roots of the characteristic equation equal and of value r1 = r2 = r. Therefore, the solution of the characteristic equation is: y e rx Let y Ve rx y' e rxV 'rVerx and y' ' e rxV ' '2re rxV 'r 2Verx where V is a function of x ay ' 'by ' cy 0 ar 2 br c 0 2ar b 0 V ' ' ( x) 0 V cx d y be rx (cx d )e rx c1e rx c2 xerx Fin500J Topic 6 Fall 2010 Olin Business School 23 Complex Roots to Characteristic Equation Let the roots of the characteristic equation be complex in the form r1,2 =λ±µi. Therefore, the solution of the characteristic equation is: y e( i ) x ex (cos( x) i sin( x)), 1 y2 e( i ) x ex (cos( x) i sin( x)). 1 1 ( y1 y2 ) e x cos( x), v( x) ( y1 y2 ) e x sin( x) 2 2i It is easy to see that u and v are two solutions to the differenti al equation. Therefore, the geneal solution t o the d.e. is : u ( x) y(x) c1e λx cos (x) c2 e λx sin( x). Fin500J Topic 6 Fall 2010 Olin Business School 24 Examples (I) Solve y ' '6 y '9 y 0 (II) Solve y ' '4 y '5 y 0 characteristic equation characteristic equation r 2 4r 5 0 r 2 6r 9 0 r1 r2 3 y (c1 c2 x)e Fin500J Topic 6 r1, 2 2 i 3 x Fall 2010 y e2 x (c1 cos x c2 sin x) Olin Business School 25 Non-homogeneous Differential Equations (Method of Undetermined Coefficients) ay ' 'by 'cy g ( x) When g(x) is constant, say k, a particular solution of equation is y k /c When g(x) is a polynomial of the form a0 a1 x a2 x ... an x where all the coefficients are constants. The form of a particular solution is 2 n y 0 1 x 2 x 2 ... n x n Fin500J Topic 6 Fall 2010 Olin Business School 26 Example Solve y' '4 y'4 y 4 x 8x 3 complementary function y ' '4 y '4 y 0 y' q 2rx 3sx 2 y p qx rx 2 sx 3 y ' ' 2r 6 sx r 2 4r 4 0 characteristic equation (2r 6sx) 4(q 2rx 3sx 2 ) 4( p qx rx 2 sx 3 ) 4 x 8x3 equating coefficients of equal powers of x r2 2r 4q 4 p 0 yc (c1 c2 x)e 2 x 6s 8r 4q 4 4r 12s 0 4s 8 y yc y p y p 7 10 x 6 x 2 2 x3 Fin500J Topic 6 Fall 2010 (c1 c2 x)e 2 x 7 10 x 6 x 2 2 x 3 Olin Business School 27 Non-homogeneous Differential Equations (Method of Undetermined Coefficients) • When g(x) is of the form Te r x , where T and r are constants. The form of a particular solution is rx y Ae A T ar 2 br c • Whe n g ( x ) i s o f th e fo r m C s i n n x + D cos n x , wh ere C a nd D a re constants, the form of a particular solution is y E sin nx F cos nx (c n 2 a)C nbD E (c n 2 a) 2 n 2b 2 (c n 2 a)C nbD F (c n 2 a ) 2 n 2 b 2 Fin500J Topic 6 Fall 2010 Olin Business School 28 Example Solve complementary function 3 y ' '6 y ' 18 3 y ' '6 y ' 0 y Cx y' C 3r 2 6r 0 y' ' 0 characteristic equation 3(0) 6(C) 18 r1 0, r2 2 yc c1 c2 e 2 x C 3 y yc y p y p 3 x Fin500J Topic 6 Fall 2010 3x c1 c2e 2 x Olin Business School 29 Example Solve complementary function 3 y' '10 y'8 y 7e 4 x 3 y ' '10 y '8 y 0 y Cxe4 x y' (1 4 x)Ce4 x y' ' (16 x 8)Ce 24C 10C 7 C 4 x 3r 2 10r 8 (3r 2)( r 4) 0 characteristic equation r1 2 / 3, r2 4 yc Ae2 x / 3 Be 4 x 1 2 y yc y p 1 4 x xe Ae2 x / 3 Be 4 x 2 1 4 x y p xe 2 Fin500J Topic 6 Fall 2010 Olin Business School 30 Example Solve complementary function y ' ' y '6 y 52 cos 2 x y ' ' y '6 y 0 y C cos 2 x D sin 2 x y ' 2(C sin 2 x D cos 2 x) y ' ' 4(C cos 2 x D sin 2 x) r 2 r 6 (r 2)( r 3) 0 characteristic equation 10C 2D 52 2C 10D 0 r1 2, r2 3 yc Ae 2 x Be 3 x C 5 D 1 y yc y p y p 5 cos 2 x sin 2 x Fin500J Topic 6 Fall 2010 Ae2 x Be 3 x 5 cos 2 x sin 2 x Olin Business School 31 Euler Equations Def: Euler equations ax y' 'bxy'cy 0 2 Assuming x>0 and all solutions are of the form y(x) = xr Plug into the differential equation to get the characteristic equation ar (r 1) b(r ) c 0. Fin500J Topic 6 Fall 2010 Olin Business School 32 Solving Euler Equations: (Case I) • The characteristic equation has two different real solutions r1 and r2. • In this case the functions y = xr1 and y = xr2 are both solutions to the original equation. The general solution is: y( x) c x r1 c x r2 1 2 Example: 2 x 2 y ' '3xy'15 y 0, the characteri stic equation is : 5 2r(r-1 ) 3r-15 0 r1 , r2 3. 2 5 2 y(x) c1 x c2 x 3. Fin500J Topic 6 Fall 2010 Olin Business School 33 Solving Euler Equations: (Case II) • The characteristic equation has two equal roots r1 = r2=r. • In this case the functions y = xr and y = xr lnx are both solutions to the original equation. The general solution is: y( x) x r (c c ln x) 1 2 Example: x 2 y ' '7 xy'16 y 0, the characteri stic equation is : r(r-1 ) 7r 16 0 r 4. y(x) c1 x 4 c2 x 4 ln x. Fin500J Topic 6 Fall 2010 Olin Business School 34 Solving Euler Equations: (Case III) • The characteristic equation has two complex roots r1,2 = λ±µi. x i e( i ) ln x x cos( ln x) ix sin( ln x) So, in the case of complex roots, the general solution w ill be : y(x) x λ(c1 cos (μ ln x) c2 sin (μ ln x)) Example: x 2 y ' '3xy'4 y 0, the characteri stic equation is : r(r-1 ) 3r 4 0 r1, 2 1 3i. y(x) c1 x 1 cos( 3 ln x) c2 x 1 sin( 3 ln x). Fin500J Topic 6 Fall 2010 Olin Business School 35