Ma147 QS7
Ma147 QS7
Ma147 QS7
Note: These question sheets are not for credit and are provided with solutions. The intention
is that you work through the questions in your own time to support the module teaching and
use the solutions after attempting the questions to confirm understanding.
Difference equations
3. Use Euler’s Method to discretise the following first order differential equations for a small
step-size h > 0.
(a)
dx
= x2 + 2
dt
(b)
dx
= sin(x) + cos(t)
dt
(c)
dx
= xt + t2
dt
(d)
dx
= xe2t
dt
4. Solve the following first order difference equations. Where initial conditions are provided,
calculate the particular solution to the initial value problem.
(a)
xn+1 = 2xn − 2 , x0 = 1
(b) √
xn+1 = xn + 13 , x0 = 0
(c) √
xn+1 = 2xn + 7 , x0 = 2
Solutions: Solving linear inhomogeneous second order ODEs
1. Auxiliary equation:
λ2 − 2λ + 3 = 0
√
with solutions λ = 1 ± i 2, i.e. p = 1 and q = 0.
Then the general solution is given by
giving √ √
x(t) = et (l1 cos 2t + l2 sin 2t) .
Substitute initial conditions x(0) = 1 and ẋ(0) = 1 to get A = 1 and B = 0. Therefore
particular solution is given by √
x(t) = et cos 2t .
2. Auxiliary equation:
λ2 − 3λ + 2 = 0
with solutions λ1 = 1 and λ2 = 2.
Then the general solution to the homogeneous case is given by
x(t) = l1 et + l2 e2t .
As the equation is inhomogeneous (s(t) = t2 ), we also need to find the particular integral.
As s(t) is a quadratic, we’ll try a generic quadratic function xp (t) = at2 + bt + c. Then
and
ẍp (t) = 2a
giving
2at2 + (2b − 6a)t + (2a − 3b + 2c) = t2 .
When we equate terms, we get a = 1/2, b = 3/2 and c = 7/4.
Therefore the general solution to the equation is
1 3 7
x(t) = l1 et + l2 e2t + t2 + t + .
2 2 4
Substituting initial conditions into x(t) and ẋ(t) gives l1 = −1 and l2 = 1, so the particular
solution to the initial value problem is
1 3 7
x(t) = −et + e2t + t2 + t + .
2 2 4
(b) We have f (x, t) = sin(x) + cos(t), giving f (xn , nh) = sin(xn ) + cos(nh). Using our
formula, we get the difference equation
xn+1 = xn + h(sin(xn ) + cos(nh)) .
(d) We have f (x, t) = xe2t , giving f (xn , nh) = xn e2nh . Using our formula, we get
xn+1 = xn + h(xn e2nh ) .
This rearranges to get the difference equation
xn+1 = (1 + he2nh )xn .