Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 54

Honours Finance (Advanced Topics in Finance:

Nonlinear Analysis)
Lecture 2: Introduction to
Ordinary
Differential Equations
BY:
Abdul Ghani Khan
M.tech
School of ICT,GBU
Why bother?
• Last week we considered Minsky’s Financial Instability
Hypothesis as an expression of the “endogenous
instability” explanation of volatility in finance (and
economics)
• The FIH claims that expectations will rise during periods
of economic stability (or stable profits).
• That can be expressed as
– % rate of change of expectations = f(rate of growth),
or in symbols
1 dE  1 dY 
  f  
E dt  Y dt 
This is an ordinary differential equation (ODE); exploring
this model mathematically (in order to model it) thus
requires knowledge of ODEs
Why bother?
• In general, ODEs (and PDEs) are used to model real-life
dynamic processes
– the decay of radioactive particles
– the growth of biological populations
– the spread of diseases
– the propagation of an electric signal through a circuit
• Equilibrium methods (simultaneous algebraic equations
using matrices etc.) only tell us the resting point of a
real-life process if the process converges to equilibrium
(i.e., if the dynamic process is stable)
• Is the economy static?
Economies and economic methodology
• Economy clearly dynamic, economic methodology primarily
static.Why the difference?
• Historically: the KISS principle:
– “If we wished to have a complete solution ... we should
have to treat it as a problem of dynamics. But it would
surely be absurd to attempt the more difficult question
when the more easy one is yet so imperfectly within our
power.” (Jevons 1871 [1911]: 93)
– “...dynamics includes statics... But the statical solution…
is simpler...; it may afford useful preparation and
training for the more difficult dynamical solution; and it
may be the first step towards a provisional and partial
solution in problems so complex that a complete
dynamical solution is beyond our attainment.” (Marshall,
1907 in Groenewegen 1996: 432)
Economies and economic methodology
• A century on, Jevons/Marshall attitude still dominates most
schools of economic thought, from textbook to journal:
– Taslim & Chowdhury, Macroeconomic Analysis for Australian
Students: “the examination of the process of moving from
one equilibrium to another is important and is known as
dynamic analysis. Throughout this book we will assume that
the economic system is stable and most of the analysis will be
conducted in the comparative static mode.” (1995: 28)
– Steedman, Questions for Kaleckians: “The general point
which is illustrated by the above examples is, of course, that
our previous 'static' analysis does not 'ignore' time. To the
contrary, that analysis allows enough time for changes in
prime costs, markups, etc., to have their full effects.”
(Steedman 1992: 146)
Economies and economic methodology
• Is this valid?
– Yes, if equilibrium exists and is stable
– No, if equilibrium does not exist, is not stable, or is one of
many...
• Economists assume the former. For example, Hicks on Harrod:
– “In a sense he welcomes the instability of his system,
because he believes it to be an explanation of the tendency
to fluctuation which exists in the real world. I think, as I
shall proceed to show, that something of this sort may well
have much to do with the tendency to fluctuation. But
mathematical instability does not in itself elucidate
fluctuation. A mathematically unstable system does not
fluctuate; it just breaks down. The unstable position is one in
which it will not tend to remain.” (Hicks 1949)
Lorenz’s Butterfly
• So, do unstable situations “just break down”?
– An example: Lorenz’s stylised model of 2D fluid flow
under a temperature gradient
• Lorenz’s model derived by 2nd order Taylor expansion of
Navier-Stokes general equations of fluid flow. The result:
dx
 a y  x x displacement
dt
dy
  b  z  x  y y displacement
dt
dz
dt
 xy cz temperature gradient

• Looks pretty simple, just a semi-quadratic…


• First step, work out equilibrium:
Lorenz’s Butterfly
dx y  x,  a  0 
 a y  x  0
dt z  b  1,  b  1
dy
  b  z  x  y  0 xy  b  1  c
dt
dz x y z0
 xy cz  0   b  1  c 
dt
x  
y    b  1  c 
• Three equilibria result (for b>1):      
 z   b  1 
• Not so simple after all! But  
hopefully, one is stable and  x  0 
the other two unstable…  y   0 
   
• Eigenvalue analysis gives the  z  0 
formal answer (sort of …)
x 
  b  1  c 
• But let’s try a simulation  y   
first …     b  1  c 
 z   b 1 
 
Simulating a dynamic system
• Many modern tools exist to simulate a dynamic system
– All use variants (of varying accuracy) of approximation
methods used to find roots in calculus
• Most sophisticated is 5th order Runge-Kutta; simplest Euler
– The most sophisticated packages let you see simulation
dynamically
• We’ll try simulations with realistic parameter values,
starting a small distance from each equilibrium:

a   5   x  3.742   3.742 0 
 b   15  So that the  y   3.742  ,  3.742 , 0 
           
 c   1  equilibria are  z   14   14  0 
       

Lorenz_Any.vsm
Lorenz’s Butterfly
• Now you know where the “butterfly effect” came from
– Aesthetic shape and, more crucially
• All 3 equilibria are unstable (shown later)
– Probability zero that a system will be in an equilibrium
state (Calculus “Lebesgue measure”)
• Before analysing why, review economists’ definitions of
dynamics in light of Lorenz:
– Textbook: “the process of moving from one equilibrium
to another”. Wrong:
– system starts in a non-equilibrium state, and moves
to a non-equilibrium state
– not equilibrium dynamics but far-from equilibrium
dynamics
Lorenz’s Butterfly
– Founding father: “mathematical instability does not in
itself elucidate fluctuation. A mathematically unstable
system does not fluctuate; it just breaks down”. Wrong:
• System with unstable equilibria does not “break down” but
demonstrates complex behaviour even with apparently
simple structure
• Not breakdown but complexity
– Researcher: “static … analysis allows enough time for
changes in prime costs, markups, etc., to have their full
effects”. Wrong:
• Complex system will remain far from equilibrium even if
run for infinite time
• Conditions of equilibrium never relevant to systemic
behaviour
When economists are right
• Economist attitudes garnered from understanding of linear
dynamic systems
– Stable linear systems do move from one equilibrium to
another
– Unstable linear dynamic systems do break down
– Statics is the end point of dynamics in linear systems
• So economics correct to ignore dynamics if economic
system is
– linear, or
– nonlinearities are minor;
– one equilibrium is an attractor; and
– system always within orbit of stable equilibrium
• Who are we kidding?…Nonlinearity rules:
Nonlinearities in economics
• Structural
– monetary value of output the product of price and
quantity
• both are variables and product is quasi-quadratic
• Behavioural
– “Phillips curve” relation
• wrongly maligned in literature
• clearly a curve, yet conventionally treated as linear
• Dimensions
– massively open-multidimensional, therefore numerous
potential nonlinear interactions
• Evolution
– Clearly evolving system, therefore even more complex
than “simple” nonlinear dynamics…
Why bother?

Lorenz's "strange attractor"


X displacement as a function of time
8

2
X with b=15

-0

-2

-4

-6

-8
0 10 20 30 40 50 60 70 80 90 100

Time
Why Bother?
• Lorenz’s bizarre graphs indicate
– Highly volatile nonlinear system could still be
systemically stable
• cycles continue forever but system never exceeds
sensible bounds
– e.g., in economics, never get negative prices
• linear models however do exceed sensible bounds
– linear cobweb model eventually generates negative
prices
– Extremely complex patterns could be generated by
relatively simple models
• The “kiss” principle again: perhaps complex systems could
be explained by relatively simple nonlinear interactions
Why Bother?
• But some problems (and opportunities)
– systems extremely sensitive to initial conditions and
parameter values
– entirely new notion of “equilibrium”
• “Strange attractors”
– system attracted to region in space, not a point
• Multiple equilibria
– two or more strange attractors generate very
complex dynamics
– Explanation for volatility of weather
• El Nino, etc.
Why bother?

Lorenz's Strange Attractor


One small step for a butterfly, one enormous flap for mankind... Tiny error
8 in initial
6 readings
4
leads to
2
enormous
difference
X displacement

in time path
-0

-2
of system.
-4 And behind
-6 the chaos,
-8
strange
0 10 20 30 40 50 60 70 80 90 100 attractors...
Tim e
Why bother?

Lorenz's Strange Attractor


X,Y and Z displacement
Why Bother?
• Lorenz showed that real world processes could have
unstable equilibria but not break down in the long run
because
– system necessarily diverges from equilibrium but does
not continue divergence far from equilibrium
– cycles are complex but remain within realistic bounds
because of impact of nonlinearities
• Dynamics (ODEs/PDEs) therefore valid for processes with
endogenous factors as well as those subject to an external
force
– electric circuit, bridge under wind and shear stress,
population infected with a virus as before; and also
– global weather, economics, population dynamics with
interacting species, etc.
Why Bother?
• To understand systems like Lorenz’s, first have to
understand the basics
• Differential equations
– Linear, first order
– Linear, second (and higher) order
– Some nonlinear first order
– Interacting systems of equations
• Initial examples non-economic (typical maths ones)
• Later we’ll consider some economic/finance applications
before building full finance model
Maths and the real world
• Much of mathematics education makes it seem irrelevant
to the real world
• In fact the purpose of much mathematics is to
understand the real world at a deep level
• Prior to Poincare, mathematicians (such as Laplace)
believed that mathematics could one day completely
describe the universe’s future
• After Poincare (and Lorenz) it became apparent that to
describe the future accurately required infinitely
accurate knowledge of the present
– Godel had also proved that some things cannot be
proven mathematically
Maths and the real world
• Today mathematics is much less ambitious
• Limitations of mathematics accepted by most
mathematicians
• Mathematical models
– seen as “first pass” to real world
– regarded as less general than simulation models
• but maths helps calibrate and characterise behaviour of
such models
– ODEs and PDEs have their own limitations
• most ODEs/PDEs cannot be solved
– however techniques used for those that can are used
to analyse behaviour of those that cannot
Maths and the real world
• Summarising solvability of mathematical models (from
Costanza 1993: 33):

Linear Non-linear

One Several Many One Several Many


Equations equation equations equations equation equations equations

essentially
Algebraic trivial easy impossible very difficult very difficult impossible

Ordinary essentially
Differential easy difficult impossible very difficult impossible impossible

Partial essentially
Differential difficult impossible impossible impossible impossible impossible
Maths and the real world
• To model the vast majority of real world systems that
fall into the bottom right-hand corner of that table, we
– numerically simulate systems of ODEs/PDEs
– develop computer simulations of the relevant process
• But an understanding of the basic maths of the solvable
class of equations is still necessary to know what’s going
on in the insoluble set
– Hence, a crash course in ODEs, with some refreshers
on elementary calculus and algebra...
From Differentiation to Differential…
• In Maths 1.3, you learnt to handle equations of the form

dy
Dependent variable  f  x Independent variable
dx
dy
• Where f is some function. For  sin  x 
dx
example dy
 dx dx   sin  x  dx
y   cos x   c
• On the other hand, differential equations are of the
form
dy • The rate of change of y is a function of its
 f  x, y  value: y both independent & dependent
dx
• So how do we handle them? Make them look like the
stuff we know:
From Differentiation to Differential…
• The simplest differential equation is

dy
y (we tend to use t to signify time, rather than x
dt
for displacement as in simple differentiation)
• Try dy
y Divide both sides by y
solving dt
dy
this for
dt  1 A trick :
yourself: y
d
 ln y    1  dy Rewrite the equation in this form :
dt y dt
d
 ln y    1 Integrate both sides w.r.t. t :
dt
d
 dt  ln y  dt  ln y    1dt  t  c Continued...
From Differentiation to Differential…

Because log of a negative ln y   t  c Take exponentials


number is not defined y  et c  et  ec  et  C
Because an
y  e t  C
exponential is
always positive y  C  e t Exponential growth

• Another approach isn’t quite so formal:


From Differentiation to Differential…
• Treat dt as a small quantity
• Move it around like a variable
• Integrate both sides w.r.t the relevant dy
y
“d(x)” term dt
– dy on LHS dy
 dt
– dt on RHS y
• Some problems with generality of this dy
approach versus previous method, but OK  y   dt
for economists & modelling issues
ln y   t  c
y  C  et
• So what’s the relevance of this to
economics and finance? How about
compound interest?
From Differential Equations to Finance
• Consider a moneylender charging interest rate i with
outstanding loans of $y.
• Who saves s% of his income from borrowers
• Whose borrowers repay p% of their outstanding principal each
year
• Then the increment to bank balances each period dt will be dx:

dy  s   i  p   y  dt  p  y  dt Divide by y & Collect terms


dy
  s   i  p   p   dt Integrate
y
dy
 y    s   i  p   p   dt
ln  y    s   i  p   p   t  c Take exponentials y  C  e  s i  p   p  t
From Differential Equations to Finance
• Under what circumstances will our moneylender’s assets
grow?
– C equals his/her initial assets:Known as “eigenvalue”;
tells how much the equation
y  t   C  e  s i  p   p t is “stretching” space

y  0   C  e  s  i  p   p  0  C  e 0  C  1  C

• The moneylender will accumulate if the power of the


exponential is greater than zero:
If s   i  p   p    0 then e  t   as t  
• The moneylender will blow the lot if the power of the
exponential is less than zero:
If   0 then e  t  0 as t  
Back to Differential Equations!
• The form of the preceding equation is the simplest
possible; how about a more general form:

Same basic idea applies: dy  f  t   y


dt
dy
 f  t   dt
y
ln  y    f  t   dt

y  C  e  f  t  dt

• f(t) can take many forms, and all your integration


knowledge from Maths 1.3 can be used… A few
examples
Back to Differential Equations!
• But firstly a few words from our sponsor
– These examples are just “rote” exercises
• most of them don’t represent any real world system
– However the ultimate objective is to be able to
comprehend complex nonlinear models of finance that
do purport to model the real world
• so put up with the rote and we’ll get to the final
objective eventually!
Back to Calculus!

Try the following:


•Won’t pursue the last one because
dy •Not a course in integration
t y  0
dt
•Most differential equations
dy 2
t  y  0 analytically insoluble anyway
dt
dy •Programs exist which can do most
 sin  t   y  0
dt (but not all!) integrations a human can
dy bt
e  y  0 do
dt •But a quick reminder of what is done
dy bt
 e  sin  t   y  0 to solve such ODEs
dt
•Also of relevance to work we’ll
do later on systems of ODEs
Back to Calculus!

• Some useful rules from differentiation and integration:


– Product rule: d  u  v   u  d v  v  d u
dx dx dx
• Simple to derive from first principles: consider a
function which is the product of two other functions:

f t  e  sin  t 
   bt
Back to Calculus!

Consider f  u  v where f, u, v are functions of x 10

Then f  f   u  u    v  v 
10

d f  f  f
f  x   lim
dx x  0 x 5

 lim
 u  u    v  v   u  v
x  0 x u( x )

u  v  u  v  u  v  v  u  u  v
v( x )
0

 lim u( x ) .v( x )

x  0 x
u  v u  v v  u
 lim   5
x  0 x x x
dv du
 u  v
dx dx 10 10
10 5 0 5 10
10 x 10

• These rules then


sin(x)
exp(-bx)
sin(x)*exp(-bx)

reworked to give us
“integration by parts” for
complex integrals:
Back to Calculus!

d dv du
 u  v  u   v 
dx dx dx
d  u  v   u  dv  v  du Treat integration as a
multiplication operator
u  dv  d  u  v   v  du

 u  dv  u  v   v  du
• Convert difficult integration into an easier one by either
– reducing “u” component to zero by repeated
differentiation
– repeating “u” and solving algebraically
Back to Calculus!
• Practically
– choose for “u” something which either
• gets simpler when integrated; or
• cycles back to itself when integrated more than once
– For our example:

f t  e  sin  t 
   bt

These don’t get •Try sin:


any simpler, but •cycles back
do “cycle” •formulas exist for
expansion
Back to Calculus!

 f  t  dt   e  bt  sin t  dt ( X ) Reproduces this


Put u  sin t  , du  cos t   dt
1 bt
Put dv  e bt
 dt , v   e  bt
 dt   e
b
This gives Stage One :
1 bt 1 bt
e
 bt
 sin t  dt  sin t    e    e  cos t   dt
b b

Next differentiation of this


Back to Calculus!

• Stage Two:

X  functiona (t )  functionb  t   X
1  functionb  t    X  functiona (t )
functiona (t )
X  e bt
 sin  t  dt 
1  functionb  t  
• Finally, Stage Three: we were trying to solve the ODE:
dy bt
 e  sin  t   y  0
dt
Back to Differential Equations!
• We got to the point where the equation was in soluble form:

dy
 y   sin  t   dt
bt
 e

• Then we solved the integral:


functiona (t )
X  e bt
 sin  t  dt 
1  functionb  t  
functiona  t 
• Now we solve the LHS ln  y  
and take exponentials: 1  functionb  t 
functiona  t 
1 functionb  t 
y  Ce
Back to Differential Equations!
• So far, we can solve (some) ordinary differential
equations of the form:

dy
 f t  y  0
dt
• These are known as:
– First order
• because only a first differential is involved
– Linear
• Because there are no functions of y such as sin(y)
– Homogeneous
• Because the RHS of the equation is zero
Back to Differential Equations!
• Next stage is to consider non-homogeneous equations:

dy
 f t  y  gt 
dt
• g(t) can be thought of as a force acting on a system
• We can no longer “divide through by y” as before,
since this yields
dy  g  t  
   f  t    dt
y  y 
• which still has y on both sides of the equals sign, and
if anything looks harder than the initial equation
• So we apply the three fundamental rules of
mathematics:
The three fundamental rules of mathematics

• (1) What have you got that you don’t want?
– Get rid of it
• (2) What haven’t you got that you do want?
– Put it in
• (3) Keep things balanced
• Take a look at the equation again

dy
What does this look almost like?  f t  y  gt 
dt

d d d
The product rule:  u  v  u  v  v  u
dx dx dx
Non-Homogeneous First Order Linear ODEs
• The LHS of the expression

dy
 f  t   y  g  t  is almost in product rule
dt form
• Can we do anything to put it exactly in that
form?
– Multiply both sides by an expression (t)
dy
so that   t    t   f t   y  t   gt 
dt
• Now we have to find a (t) such that
d
   t   y     t   dy    t   f  t   y
dt dt
• This is only possible if d   t     t   f  t 
dt
The Integrating Factor Approach
• This is a first order linear homogeneous ODE, which we
already know how to solve (the only thing that makes it
apparently messy is the explicit statement of a
dependence on t in (t), which we can drop for a while):

d
    f t
dt
d
 f  t   dt

d
    f  t   dt
This is known as the “integrating factor” ln      f  t   dt
  t   e  f  t  dt
The Integrating Factor Approach
• So if we multiply

 f  t   y  g  t  by   t   e
dy  f  t   dt
we get
dt
 f  t  dt dy  f  t  dt d   f  t  dt   f  t  dt
e  
 f t e  y   ye  
  g t e
dt dt  

• Anybody dizzy yet?


– It’s complicated, but there is a light at the
end of the tunnel
• Next, we solve the equation by taking
integrals of both sides:
d   f  t  dt   f  t  dt  f  t  dt
 dt  y  e dt  y  e  
  g t e dt
The Integrating Factor Approach
• And finally the solution is:

 f  t  dt
 gt   e dt
y
 f  t  dt
e
• This is a bit like line dancing: it looks worse than it
really is.
dy
– Let’s try a couple of examples: firstly, try dt  2  t  y  t

• (Actually, line dancing probably is as bad as it looks,


and so is this)...
The Integrating Factor Approach

dy
• The first one  2  t  y  t becomes
dt
dy
   2t    y   t using the integrating factor
dt
d dy
• Now we need a  such    y     2 t    y
dt dt
that
d
• Which is only possible   2  t  
dt
if
• This is a first order homogeneous DE: piece of cake!

d
 2  t  dt  ln       2  t  dt  t    e
2 t 2


The Integrating Factor Approach
• Thus we multiply
dy
 2  t  y  t by e  t to yield
2

dt
t 2 dy
dt
t 2
e   y  2t e 
dt

d t 2

e  y  te t 2

• Then we integrate:
Back to basics #2:

d t 2

 dt e  y dt  e  y   t  e dt
t 2 t 2 the Chain Rule in
reverse

Next problem: how to integrate this?


The Chain Rule
• This expression:

t e
t 2
dt

• “Looks like”  eu du where u  t 2 since


d
dt
  t 2   2  t

 d   t 2   t  dt so u  t 2
1
• Or in differential form:
2

• That integral is elementary:  e u


du  e u
c

• Now substituting for u and taking account of the


constant:
t 2 1 u 1

t 2 1 t 2

 t  e du   2   e du   2  e  c   2  e  C
The Integrating Factor Approach
• Finally, we return to


d t 2

 dt e  y dt  e  y   t  e dt
t 2 t 2

1 t 2
• Putting it all together: e t 2
 y   e C
2
1 t 2
 e C
2 1 C 1
y t 2
   t 2    C  e is the solution to
t2

e 2 e 2
dy
 2t  y  t
dt

• Before we try another example, the general


principle behind the technique above is the chain
rule in reverse:
The Chain Rule

Rate of change of 10
10

composite function is rate Slope of one


of change of one times the 5

other
If F  x   f  g  x  
u( x )

v( x )
0

then F '  x   f '  g  x    g '  x 


( u( x ) .v( x ) )

v( u( x ) )

* slope of other
• In reverse, the 5

substitution method of
=slope of composite
integration: 10 10
10 5 0 5 10

If F  x    f  x dx then F '  x   f  x 


10 x 10
sin(x)
exp(-bx)
sin(x)*exp(-bx)

So  f  g  t    g '  t  dt   F '  g  t    g '  t  dt


e(sin(x))

 F  gt    C
Back to Differential Equations!
• Try the technique with
dy 2
t  y 1
dt
dy 2
• Stage One: Finding :  t  y  1 Times integrating factor :
dt
dy 2 d
   t    y     y    iff
dt dt
d
  t2  
dt
d
 t 2  dt

d 1 3
  ln      t 2
 dt  t
3
1 3
t
 e 3
Linear First Order Non-Homogeneous
• Stage Two: apply :

1
dy 2 t3
 t  y  1 Times integrating factor   e 3
dt
dy 2
1 3
t dy
1 3
t d  1 3
t  1 3
t
   t    y  e   t  e  y   e  y   e
3 2 3 3 3
dt dt dt  
d  3t 3 
1 1 3 1 3
t t
 dt  e  y dt  e  y   e dt  c
  3 3

• Stage Three: integrating RHS…


– there is no known integral! (common situation in
ODEs)
–1 Completing
3 1 3 1
the maths as best we can:
3
 t t  t
y  e   e dt  e 3  c This can only be estimated numerically
3 3

You might also like