Can rearrange 1 dy 1
y dt dt = y dy = a dt
Note that y = / is the steady solution of the ode. This is referred to as the particular integral.
39
The general solution is the sum of the homogeneous solution and the particular integral. As we shall see later, the sum of the solution to the homogeneous equation and the particular integral is the most general solution.
dy + y = t dt
The complementary function (solution of homogeneous problem) is A et. For the particular integral, try y = a + bt and substitute:
b + (a + bt) = t.
Equating coefficients The general solution
b t = t b = 1/
b + a = 0 a = 1/2 y = A et 1/2 + t/..
dy + y = e t dt
Try y = a et and the general solution
a et + a et = et y = Ae
t
a = 1/() .
t e t e( ) t + = e A+
dy + y = e t dt
In analogy with previous example, could try y = et, but this is a solution to the homogeneous equation, and so would not satisfy the right-hand side Try instead y = a t et: (a et a t et) + a t et = et
a=1 y = A et + t et = (A + t) et
We can see why the solution has this form by considering the previous example in the limit . In this limit
t 1 + ( ) t + ! 1 e( ) lim A + lim lim +t . = A + = A +
Since A is arbitrary, then we may absorb the 1/() into the constant, and so obtain the particular integral t et.
+ Ae t A = y0 e t y =
0
0
t t + y0 e (
40
Difference equations
zn = (zn-1,zn-2,,zn-m).
The order of the difference equation indicates the number of previous values of zn the next value depends on. A first order difference equation, zn = (zn-1), uses only one previous value. The difference equation is linear if is linear in zn-1, zn-2,. The most general first order linear difference equation is therefore
z1 = 0 z0 + 0, z2 = 1 z1 + 1 = 1(0 z0 + 0) + 1 etc.
Can, at least in principle, easily calculate this using a computer. Note, however, that in some circumstances the solution may be unstable due to round-off error in the calculation.
zn = zn-1 + z0 known z1 = z0 + z2 = z1 + = 2 z0 + (1 + ) n zn = zn 1 + = z0 + 1 + + 2 + ! + n 1
= n z0 + =
1 1
n
n + z0 1 1
a + ar + ar + ! + ar
2
n 1
a (1 r n )
1 r
; r 1
41
Difference equations
yn =
+ n A = + n y0
which has the same form as the difference equation in 2.2.1 with = et and = (1)/.
dy + y = dt dy dt t =
n1 < t < tn
yn yn 1 yn yn 1 = . tn tn1 t
(Euler)
yn yn 1 + yn 1 = t
yn = (1 t ) yn 1 + t
= t, then
yn =
t t n n + y0 (1 t ) = + y0 (1 t ) t t
Now since y 0 as t , then we must have t < 1 for the approximation yn to converge. In the previous section we showed that for an exact solution, the coefficient needed to be 1 2 2 1 3 3 t t + ! 2! 3!
= et = 1 t +
42
Difference equations
so our difference equation may be seen to be just using the first two terms of the Taylor Series for et. We could alternatively used the difference equation
yn yn 1 + ( yn + yn 1 ) = t 2 yn =
1 1 t 2 yn 1 + t 1 + 1 t 2
n
(Crank-Nicholson)
1 1 t 2 = y0 + 1 1 + 2 t
1 1 t 2 1 1 + 2 t
= (1 1 t ) 1 1 t + 1 2 t 2 1 3 t 3 + ! 2 2 4 8 = 1 t + 1 2 t 2 1 3 t 3 + ! 2 4
shows that this is a better approximation to et, and so should be more accurate for a given t. Moreover, note that (for > 0) |1 t| < |1+ t| so || < 1 and yn 0 as n regardless of the choice of t. This means the difference equation is stable.
zn+1 + zn = 0
Try zn = K an (using similarity with differential equation giving y = K ex or earlier analysis of difference equation noting that zn+1 = zn); K is arbitrary constant.
zn+1 + zn = 1
Look for particular integral. Try zn = const = A and substitute: A + A = 2A = 1 A = . Hence general solution is sum of these, i.e.
zn = K (1)n +
End of Lecture 5
zn+1 + zn = n
Might guess particular integral to be zn = n, but this would give
zn+1 + zn = (n+1 + n) = n +
which leaves us with too much. More generally, try zn = A + Bn
Difference equations
zn+1 + zn = n2
Try zn = A + Bn + Cn2
B = , A = B = . zn = K(1)n + n
zn+1 + zn = an
Try zn = Aan
zn+1 + zn = n an
Try zn = (A + Bn)an
dy + y = dt
y = ant n
n =0 dy = nant n 1 = nant n 1 dt n =0 n =1
(y = a0 at t = 0)
[We shall assume this is OK since if y is differentiable, then dy/dt exists and is finite.] Substitute into ode:
nant n1 + ant n =
n =1 n =0
( n + 1) a
n=0
n +1
+ an t n = 0
Need to equate coefficients to zero for all powers of t (each tn is linearly independent).
n=0
a1 + a0 = 0
44
n>0
Solution:
an +1 =
n +1
an
(recurrence relation)
1 1 + y0 1 t + 2 t 2 3t 3 + ! 2! 3!
=
+ y0 e t
as we know from earlier. For more complicated equations we may not be able to explicitly sum the series generated, or even be able to give an explicit expression for the coefficients. However, may still be able to evaluate the solution using a computer (but may have convergence issues).
Bank interest
Capital sum S(t) accrues interest at a rate r (r = const) i.e. S increases by a proportion r dt in time dt S(t + dt) = S(t) + r dt S(t) S ( t + dt ) S ( t ) dt rS ( t ) = 0 Banks typically have dt equal to one day.
Banks often say they do things pro rata, so we shall approximate the above difference equation with dS rS = 0 S = S0 ert dt S0 is initial capital.
Of course, the Bank of England changes the base rate from time to time, so r = r(t), leading to r dt S = S e
0
Repaying mortgage
Borrow a sum S0, subject to interest at rate r but making repayments at rate p. Assuming pro rata handling by bank, then the amount owed is dS = rS p ; dt S(0) = S0.
45
First order linear equations For the mortgage to decrease, then clearly require p > rS. S= S p p + S0 e rt r r p < rS0
Difference equations
p > rS0 t p
1 1 rS r = t = T ln 1 0 . p S rS r p 1 0 0 r p
Total sum paid is of course pT. Note that if p is close to rS0, there is a large change in pT for a small change in p. Hence, it is generally very beneficial to try to pay your mortgage off faster than you are required to. To repay your mortgage in T years, you need to make repayments at rate p= rS0e rT rS0 = rt e 1 1 e rT
Assume you borrow 100,000 at an annual interest rate of 6% over a 20 year period. Your repayments are ~8586/year or ~715/month. In total you repay around 171.7k! Paying things off faster so that you take only 15 years increases your repayments to ~843/month, but decreases the total cost to ~151.7k. Enough for a nice car!
Radioactive decay
The probability that a radioactive isotope, such as U, Th, Pu, 14C, will decay in a unit of time is independent of time. Suppose you have a quantity Q, then the decay rate 1 is independent of time and dQ Q = Q = Q0 et/. dt Here is the characteristic decay time (time for Q to be reduced by a factor of e), also referred to as the e-folding time. Sometimes we are interested in the half-life, t the time for the radioactivity to reduce by a factor of 2. Noting that Q = Q0e t / = Q0 2 t / t1/ 2 , then t/ =t/t ln 2 t = ln 2 0.693 .
46
Difference equations
from a good conductor of heat (e.g. metal), then it is often a good approximation to assume the temperature of the block is uniform (constant in space). Suppose H is the heat (thermal energy) of the block, given by
H = m C p dT
Tr T
where Tr is a reference temperature, m is the mass of the block and Cp is the heat capacity of the block. For many materials Cp is approximately constant, so H = m Cp(T Tr). The heat of the block changes due to a heat flux Q from the block to the environment as
dH dT = mC p = Q . dt dt
If the heat flux depends only on the difference between the temperature of the block and the temperature of the environment, T0, then
Q (T T0 ) = Q0 + dQ 1 d 2Q 2 T T0 ) + ! (T T0 ) + 2 ( dT 0 2 dT 0
Taylor series
The zeroth law of thermodynamics requires that there is only a heat flux between two bodies when there is a temperature difference, hence Q0 = 0. If TT0 is small, can ignore quadratic and higher terms, so
mC p dT dQ (T T0 ) . dt dT T =T0
[Approximations like this are the basis of many of the differential equations found in physics.] Let = T T0, and = 1 dQ , so mC p dT T =T0
d + = 0 = 0 et. dt
Note that if thermal conductivity of block is poor, then temperature gradients within block make this description inappropriate. The Newton cooling described here ignores heat transfer by natural convection, radiation, etc.
= const.
Integrating:
y ( t ) = y ( t1 ) + a y ( t ) dt
t1 t
= y ( t1 ) + a
t1
y ( t) dt
Initial conditions are less straight forward than normal: just knowing y(0) is not sufficient! 47
y ( t ) dt = Y ( ) + a Y ( t ) dt
0
Set t1 = 2
End of Lecture 6
y ( t ) = y ( t1 ) + a y ( t ) dt
t1 t
= Y ( ) + a y ( t ) dt + a y ( t ) dt
0
t = Y ( ) + a Y ( t ) dt + a Y ( ) + a y ( t ) dt dt 0 0 t 2 t = Y ( ) + a Y ( t ) dt + aY ( )( t 2 ) + a 2 Y ( t ) dt dt 0 0 0
= Y ( ) + a Y ( t ) dt + aY ( )( t 2 ) + a 2
0
t 2
( t 2 t)Y ( t) dt
0
= (1 + a ( t 2 ) ) Y ( t ) + a Y ( t ) dt + a 2
0
t 2
( t 2 t)Y ( t) dt
0
y=1
dy/dt = 0 dy/dt = 1
1 dt = 1 + ( t 1) = t
0
t dt = 2 + 2 ( t 1)
1
t 1 1
1 12 = t 2 t + 2 2
t 2
y (t ) = y ( 2) +
or
1 + ( t 1) dt = y ( 2 ) + 1 + t dt
0 2
= y ( 2) + (t 2) +
1 2 (t 2) 2
48
Difference equations
t 2
( t 2 t)Y ( t) dt
0
or
= 1 + 1 dt + ( t 2 ) +
0
t 2
( t 2 t) dt
0 2
= 1 + 1 + t 2 + (t 2) 1 = 2 t + t2 2
y ( t ) = y ( 3) +
t 1
1 2 (t 2) 2
y ( t ) dt =
7 + 2
t 1
2 t
2
t + 2 dt
= 3t4 =
7 1 3 1 2 + t t + 2t 2 6 2 2
t 1
7 1 3 1 + t 3t 2 + 3t 1 8 t 2 2t + 1 4 + 2 ( t 1 2 ) 2 2 6 1 7 3 3 1 1 1 = + 6 + + 1 + 2 t + t 2 + t 3 6 2 2 2 2 2 2 5 7 1 = + t t 2 + t3 2 2 6
y ( t ) = y ( 3) +
t 1
y ( 2 ) + ( t 2 ) + 2 ( t 2 )
2 t 3
dt
or
=
= y ( 3) +
y ( 2 ) + t + 2 t
0
dt
7 1 1 2 3 + 2 ( t 3) + ( t 3) + ( t 3) 2 2 6
4t5
=
y (t ) = y ( 4) +
t 1
y dt
3
t 1 2 3 4
49
Difference equations
t 2
y ( t ) = y ( 2 ) +
y dt
2 t 3
= 1 cos +
1 + cos t dt
y dt
3 t 4
2 2 + t sin t dt
1 2 ( t ) 2 2 + cos ( t ) cos 2 2
9 = 1 5 + 2 + ( 2 3 ) t cos t 2
4 t 5
y ( t ) = y ( 4 ) + =
y dt
1 6 + 75 2 64 3 + ( 6 42 + 48 2 ) t + ( 6 12 ) t 2 + t 3 + 6sin t 6
50
10
12
Homogeneous equation
For f = 0 can treat as before: 1 dy = q y dt ln y = q ( t ) dt
y ( t ) = y0 e
q ( t ) dt
y = y0 at t = 0.
Inhomogeneous equation
From homogeneous solution can see that ye
+ q dt Try solution of the form u ( t ) = ye
+ q ( t ) dt
= y0 e
+ q ( t ) dt q ( t ) dt
= y0 = const
+ q dt du dy + q dt dy + q dt = e + qye = + qy e dt dt dt
51
This transformed equation is said to be exact (right-hand side does not depend on u We can integrate
+ q dt e u= f ( t ) dt t
t
t0
q dt t
y=e
t0
+ q dt e f ( t ) dt t
t t0 0
Since the ode is linear, the sum of the homogeneous solution and the particular integral is also a solution of the ode. Thus the general solution is
q dt
y = y0 e
t0
q dt t
+e
t0
+ q dt e f ( t ) dt t
t t0 0
dy + ty = t dt
t dt + q dt Integrating factor: e = e =e
1 2 t 2
1 t2 2
dy + ty = e dt e y = t e
1 t2 2
1 t2 2
dy d t t + e ty = e y = te dt dt
1 2 2 1 2 2
1 t2 2
1 t 2 2
t0
dt = e
1 2
1 t 2 2
=e t
0
1 2 2
1 t2 2
1 t2 2 0
y = 1 e
(t
2 2 0 t
) = 1 e (t
2 t0
1 t2 2
52
q dt t
y = y0 e
+e t
0 t
+ q dt e t0 f ( t ) dt t0
t
t dt
t dt t
= y0 e
+e
+ t dt e t0 t dt t0
t
= y0 e
2 1 t 2 t0 2
+e
2 1 t 2 t0 2
) + ( t t ) t dt e t
1 2 2 2 0 0
= y0 e
1 t2 2
+ e2 0 e
1 2
1 t2
2 1 t 2 1 t0 2 2
t0
1 t 2 2
t dt
t
= y0 e = y0 e
(t
2 t0
) +e
1 t2 2
2 1 t 2 t0 2
+e
1 t2 2
(e
e 12 t t0
2 1 t2 2
e2 0
1 t2
= y0 e
2 1 t 2 t0 2
+1 e
2 1 t 2 t0 2
= 1 (1 y0 ) e
2 1 t 2 t0 2
dy + y = ex dx
dy + y sin x = ecos x dx
dy x d x dy ex + y = ex +e y = e y = e x e x = e2 x dt dt dt
( )
e y= e
x x0
2 x
1 1 dx = e 2 x = e 2 x e 2 x 2 x 2
)
x0 arbitrary
y=
1 x 2x 2x 1 1 e e e = e x e2 x e x = e x Ae x 2 2 2
cos x
y=
x0
dx = ( x x0 ) x0 arbitrary
y = ( x x0 ) ecos x
53
dy + ty = t dt
dy + y = ex dx dy + y sin x = ecos x dx
y = ex y = x ecos x
y = ex y = ecos x
Theorem
If y = u satisfies
d du dv ( u + Av ) + q ( u + Av ) = + qu + A + qv = f dt dt dt
dy xy = x 2 ; y = 1 at x = 0 dx
+ q dt x dx Integrating factor: e = e =e
1 2
x2
1 x2 2
dy xy = e dt
1 2
x2
dy xye dt y = e
x2
d ye dt
1 2
x2
)=e
1 x2 2
x2
1 x2 2
1 x2 2
x 2 dx
1 x2 2
1 x2 2
f = 1; g = e
1 x2 2
y=e
1 2
x2
{ xe
+ e
1 x2 2
dx
But we cannot do this integral! As it appears often, a function representing the integral has been invented: the error function
erf ( x ) =
e
0
t 2
dt
y = x +
1 2
x2
x erf + Ae 2
1 2
x2
dy xy = x 2 dx
dy = nan x n 1 dx n = 0
dy xy = nan x n 1 x an x n x 2 dx n=0 n=0
= ( n + 1) an +1 an 1 x x = 0
n 2 n=0
a-1 = 0
an +1 =
an 1 n +1
n2
3a3 a1 1 = 0
55