MATH1231 4,851 words·25 min read

Ordinary Differential Equations

In many practical applications (physics, economics, engineering, applied science and so on), we know something about the relationship between a quantity and its rates of change, but we do not have an exact formula for the quantity itself. For example, a simple population model states that a population grows at a rate proportional to its current size; writing P(t)P(t) for the population at time tt, this becomes

dPdt=kP,\frac{dP}{dt}=kP,

where kk is the constant of proportionality. An equation like this, involving one (or more) derivatives of a function, is called a differential equation. Some other simple examples:

The whole point of this chapter is: given a differential equation for an unknown function, find an explicit formula (or formulae) for that function.

3.1 An introduction#

Note

Definition
An ordinary differential equation is an equation expressed in terms of exactly one independent variable and one (or more) of the derivatives of a function of this variable. The order of an ordinary differential equation is the order of the highest derivative present.

Basically, an ODE is any equation with derivatives in it, and the order is just the highest derivative you can find. The equations are called 'ordinary' because they involve ordinary derivatives; this distinguishes them from partial differential equations, which involve partial derivatives (second year material). For example,

d3ydx3+sin⁡x dydx=3x2y\frac{d^3y}{dx^3}+\sin x\,\frac{dy}{dx}=3x^2y

is an ODE of order 3 (independent variable xx, with yy a function of xx), while

(d2xdt2)3/2+dxdt−tx=0\left(\frac{d^2x}{dt^2}\right)^{3/2}+\frac{dx}{dt}-tx=0

is an ODE of order 2. Notice how the 3/23/2 power does not affect the order; only the highest derivative present matters.

Also note that the same ODE can be dressed up in several notations; the equations

d2ydx2+4xdydx=ex,f′′(x)+4xf′(x)=ex,y′′+4xy′=ex\frac{d^2y}{dx^2}+4x\frac{dy}{dx}=e^x, \qquad f''(x)+4xf'(x)=e^x, \qquad y''+4xy'=e^x

all represent the same ODE.

Note

Definition
A solution to an nnth order ordinary differential equation is a function which is nn-times differentiable and satisfies the given equation.

Example. Consider the ODE

dydx=x2+5.\frac{dy}{dx}=x^2+5.

Then y(x)=x33+5xy(x)=\dfrac{x^3}{3}+5x is a solution (differentiate it and you get back x2+5x^2+5). But so is y(x)=x33+5x+6y(x)=\dfrac{x^3}{3}+5x+6, and y(x)=x33+5x−45y(x)=\dfrac{x^3}{3}+5x-45; each of these is called a particular solution. Every solution to this ODE can be written in the form

y(x)=x33+5x+C,y(x)=\frac{x^3}{3}+5x+C,

where C∈RC \in \mathbb{R}; this family of solutions is called the general solution. Basically, a particular solution is one specific function, whilst the general solution is the whole family with the arbitrary constant(s) still floating around.

In the example above, yy could be written explicitly as a function of xx, giving an explicit solution. This cannot always be done; sometimes we must settle for an implicit solution, where yy is only defined implicitly by some equation.

Example. Show that yy, given implicitly by the equation

y2=cos⁡(x2+y2),y^2=\cos(x^2+y^2),

is a particular solution to the ODE

2xsin⁡(x2+y2)+(2ysin⁡(x2+y2)+2y)dydx=0.2x\sin(x^2+y^2)+\big(2y\sin(x^2+y^2)+2y\big)\frac{dy}{dx}=0.

To verify that yy solves the ODE, we first need dydx\dfrac{dy}{dx}. Implicitly differentiating both sides with respect to xx (using the chain rule on the right),

2ydydx=−sin⁡(x2+y2)×(2x+2ydydx)2ydydx+2ysin⁡(x2+y2)dydx=−2xsin⁡(x2+y2)2xsin⁡(x2+y2)+(2ysin⁡(x2+y2)+2y)dydx=0,\begin{align*} 2y\frac{dy}{dx} &= -\sin(x^2+y^2)\times\left(2x+2y\frac{dy}{dx}\right) \\ 2y\frac{dy}{dx}+2y\sin(x^2+y^2)\frac{dy}{dx} &= -2x\sin(x^2+y^2) \\ 2x\sin(x^2+y^2)+\big(2y\sin(x^2+y^2)+2y\big)\frac{dy}{dx} &= 0, \end{align*}

which is exactly the ODE. Hence the ODE is satisfied and yy is a (particular) solution. Note we only verified a given solution here; in Section 3.5 we will actually find the general solution to this ODE from scratch.

3.2 Initial value problems#

In most practical applications, we also know the value of the unknown function (and possibly its derivatives) at some particular point. This extra information, together with the ODE, forms an initial value problem.

Note

Definition
An initial value problem is an nnth order ODE together with a set of values of the solution and its first (n−1)(n-1) derivatives at some fixed point x0x_0. These values are called the initial conditions of the initial value problem.

'Initial value problem' is usually abbreviated as IVP. The strategy for solving an IVP is: find the general solution to the ODE (with its unspecified constants), then impose the initial conditions to pin down the constants. Note that an nnth order ODE needs nn conditions since the general solution has nn arbitrary constants.

Example. Solve the IVP

d2ydx2=6x,y′(0)=2,y(0)=−1.\frac{d^2y}{dx^2}=6x, \qquad y'(0)=2, \quad y(0)=-1.

Integrating the ODE once,

dydx=3x2+C,\frac{dy}{dx}=3x^2+C,

where C∈RC\in\mathbb{R}. Imposing y′(0)=2y'(0)=2 gives C=2C=2. Integrating again,

y=x3+2x+D,y=x^3+2x+D,

where D∈RD\in\mathbb{R}. Imposing y(0)=−1y(0)=-1 gives D=−1D=-1. Therefore the solution to the IVP is

y=x3+2x−1,y=x^3+2x-1,

which is valid for all x∈Rx\in\mathbb{R}.

Not every IVP is this friendly. In general, three questions arise:

  1. Does the IVP have a solution at all?
  2. Is the solution unique?
  3. If the initial values are given at a point aa, how far on either side of aa does the solution extend?

The next two examples show that even 'simple' looking IVPs can misbehave.

Example. Solve the IVP

dydx=y,y(0)=0.\frac{dy}{dx}=\sqrt{y}, \qquad y(0)=0.

Assuming y≠0y\neq0, we can separate:

1y dy=dx2y=x+C.\begin{align*} \frac{1}{\sqrt{y}}\,dy &= dx \\ 2\sqrt{y} &= x+C. \end{align*}

The initial condition gives C=0C=0, and rearranging,

y(x)=x24.y(x)=\frac{x^2}{4}.

However, notice that the constant function y(x)=0y(x)=0 is also a solution to the IVP (both sides are 00). Hence this IVP does not have a unique solution.

Example. Solve the IVP

dydx=1x,y(1)=2.\frac{dy}{dx}=\frac{1}{x}, \qquad y(1)=2.

How far does the solution extend on either side of the point 11?
The ODE says dydx\dfrac{dy}{dx} does not exist at 00, so the solution cannot cross 00. On the interval (0,∞)(0,\infty) the general solution is y(x)=ln⁡x+Cy(x)=\ln x + C, and y(1)=2y(1)=2 gives C=2C=2. Hence

y(x)=ln⁡x+2,x>0.y(x)=\ln x+2, \qquad x>0.

So the solution only extends over (0,∞)(0,\infty); you could patch on ln⁡∣x∣+D\ln|x|+D for x<0x<0, but for practical applications the break in the domain at 00 means we would not use it there.

3.3 Separable ODEs#

A separable ODE is one where the two variables (say xx and yy) can be separated, so that all the yy's end up on one side of the equation and all the xx's on the other. In general, a separable ODE is one that can be written in the form

dydx=g(x)h(y).\boxed{\frac{dy}{dx}=\frac{g(x)}{h(y)}.}

To solve it, write

h(y) dy=g(x) dx,h(y)\,dy=g(x)\,dx,

integrate both sides to obtain an implicit solution H(y)=G(x)+CH(y)=G(x)+C, and then (whenever possible) isolate yy to get the explicit solution. If initial conditions are given, use them to determine CC.

The fact that this symbolic manipulation with dydy and dxdx 'works' traces back to the chain rule: h(y)dydx=g(x)h(y)\dfrac{dy}{dx}=g(x), and integrating both sides with respect to xx turns ∫h(y)dydx dx\displaystyle\int h(y)\frac{dy}{dx}\,dx into ∫h(y) dy\displaystyle\int h(y)\,dy. Do not assume you can manipulate the symbols dydy and dxdx in other creative ways and still get valid results.

Example. Solve the initial value problem

dydx=y2(1+x2),y(0)=1.\frac{dy}{dx}=y^2(1+x^2), \qquad y(0)=1.

Separating the variables and integrating,

1y2 dy=(1+x2) dx∫1y2 dy=∫(1+x2) dx−1y=x+x33+C,\begin{align*} \frac{1}{y^2}\,dy &= (1+x^2)\,dx \\ \int\frac{1}{y^2}\,dy &= \int(1+x^2)\,dx \\ -\frac{1}{y} &= x+\frac{x^3}{3}+C, \end{align*}

where C∈RC\in\mathbb{R}; this is the implicit solution. Imposing y(0)=1y(0)=1,

−11=0+0+C,-\frac{1}{1}=0+0+C,

so C=−1C=-1. Making yy the subject,

−1y=x+x33−1y=−33x+x3−3.\begin{align*} -\frac{1}{y} &= x+\frac{x^3}{3}-1 \\ y &= \frac{-3}{3x+x^3-3}. \end{align*}

Therefore the explicit solution is y=33−3x−x3y=\dfrac{3}{3-3x-x^3}.

Example. Solve the equation

sinh⁡ycos⁡2x dydx=tan⁡x+4.\sinh y\cos^2x\,\frac{dy}{dx}=\tan x+4.

Separating and simplifying,

sinh⁡y dy=tan⁡x+4cos⁡2x dxsinh⁡y dy=(tan⁡xsec⁡2x+4sec⁡2x) dx∫sinh⁡y dy=∫(tan⁡xsec⁡2x+4sec⁡2x) dxcosh⁡y=12tan⁡2x+4tan⁡x+C,\begin{align*} \sinh y\,dy &= \frac{\tan x+4}{\cos^2x}\,dx \\ \sinh y\,dy &= (\tan x\sec^2x+4\sec^2x)\,dx \\ \int\sinh y\,dy &= \int(\tan x\sec^2x+4\sec^2x)\,dx \\ \cosh y &= \frac{1}{2}\tan^2x+4\tan x+C, \end{align*}

where C∈RC\in\mathbb{R}. In this case it is best to leave the solution in implicit form, since cosh⁡\cosh is not one-to-one; 'inverting' it would silently throw away solutions.

Example. (Newton's law of cooling)
(a) Newton's law of cooling states that the rate of heat loss of a body is proportional to the difference in temperature between the body and its surroundings. Set up an ODE for this and solve it.
(b) A hot object is placed into a room of temperature 20∘20^\circC. The object is initially too hot for the thermometer to measure, but after 6 minutes its temperature is 80∘80^\circC, and after 8 minutes it is 50∘50^\circC. What was the original temperature?

(a) Suppose TT is the temperature of the object at time tt, AA is the ambient (room) temperature and kk is the constant of proportionality. Then

dTdt=k(T−A).\frac{dT}{dt}=k(T-A).

This is separable:

1T−A dT=k dt∫1T−A dT=∫k dtln⁡(T−A)=kt+CT−A=ekt+CT=A+Kekt,\begin{align*} \frac{1}{T-A}\,dT &= k\,dt \\ \int\frac{1}{T-A}\,dT &= \int k\,dt \\ \ln(T-A) &= kt+C \\ T-A &= e^{kt+C} \\ T &= A+Ke^{kt}, \end{align*}

where K=eC>0K=e^C>0.

(b) Here A=20A=20, T(6)=80T(6)=80 and T(8)=50T(8)=50. Substituting into the solution,

{80=20+Ke6k50=20+Ke8k.\begin{cases} 80=20+Ke^{6k} \\ 50=20+Ke^{8k}. \end{cases}

So Ke6k=60Ke^{6k}=60 and Ke8k=30Ke^{8k}=30; dividing the second equation by the first,

e2k=12k=−ln⁡22.\begin{align*} e^{2k} &= \frac{1}{2} \\ k &= -\frac{\ln2}{2}. \end{align*}

Then, from Ke6k=60Ke^{6k}=60,

K=60e−6k=60e3ln⁡2=60×8=480.\begin{align*} K &= 60e^{-6k} \\ &= 60e^{3\ln2} \\ &= 60\times8 \\ &= 480. \end{align*}

Finally,

T(0)=20+480e0=500.T(0)=20+480e^0=500.

Therefore the initial temperature of the object was 500∘500^\circC.

3.4 First order linear ODEs#

A first order linear ODE can be written in the form

dydx+f(x)y=g(x),\boxed{\frac{dy}{dx}+f(x)y=g(x),}

where ff and gg are given functions of the single variable xx. The ODE is called linear because there are no non-linear terms (like y2y^2, sin⁡y\sin y or y′\sqrt{y'}) involving yy or y′y'; note that ff and gg are allowed to be as ugly as they like in xx.

The method for solving these is very slick:

  1. Write the ODE in the standard form above.
  2. Calculate h(x)=e∫f(x) dxh(x)=e^{\int f(x)\,dx} (ignoring the constant of integration). This is called the integrating factor.
  3. Multiply the ODE through by h(x)h(x):

h(x)dydx+h(x)f(x)y=g(x)h(x).h(x)\frac{dy}{dx}+h(x)f(x)y=g(x)h(x).

By the product rule, the left-hand side always collapses to

ddx(h(x) y)=g(x)h(x).\frac{d}{dx}\big(h(x)\,y\big)=g(x)h(x).

  1. Integrate both sides and rearrange for yy. Do not forget the constant of integration in this step; if it is accidentally omitted then you lose half the solution.

Basically, the integrating factor is a magic multiplier engineered so that the messy left-hand side becomes the derivative of a single product h(x)yh(x)y; this works because h′(x)=f(x)h(x)h'(x)=f(x)h(x) by the chain rule, which is exactly the coefficient needed for the product rule to run backwards.

Example. Solve dydx+3y=e−x\dfrac{dy}{dx}+3y=e^{-x}.
The ODE is already in standard form with f(x)=3f(x)=3, so the integrating factor is

h(x)=e∫3 dx=e3x.h(x)=e^{\int3\,dx}=e^{3x}.

Multiplying through by e3xe^{3x} and contracting the left-hand side,

e3xdydx+3e3xy=e2xddx(e3xy)=e2xe3xy=12e2x+Cy=12e−x+Ce−3x,\begin{align*} e^{3x}\frac{dy}{dx}+3e^{3x}y &= e^{2x} \\ \frac{d}{dx}\big(e^{3x}y\big) &= e^{2x} \\ e^{3x}y &= \frac{1}{2}e^{2x}+C \\ y &= \frac{1}{2}e^{-x}+Ce^{-3x}, \end{align*}

where C∈RC\in\mathbb{R}. Therefore the general solution is y=12e−x+Ce−3xy=\frac{1}{2}e^{-x}+Ce^{-3x}; notice how forgetting the +C+C would have lost the entire Ce−3xCe^{-3x} family.

Example. Solve the IVP

(x−1)3dydx+4(x−1)2y=x+1,y(0)=2.(x-1)^3\frac{dy}{dx}+4(x-1)^2y=x+1, \qquad y(0)=2.

First rewrite in standard form by dividing by (x−1)3(x-1)^3:

dydx+4x−1y=x+1(x−1)3.\frac{dy}{dx}+\frac{4}{x-1}y=\frac{x+1}{(x-1)^3}.

The integrating factor is

h(x)=e∫4x−1dx=e4ln⁡(x−1)=eln⁡(x−1)4=(x−1)4.h(x)=e^{\int\frac{4}{x-1}dx}=e^{4\ln(x-1)}=e^{\ln(x-1)^4}=(x-1)^4.

It is important to simplify h(x)h(x) like this before continuing; leaving it as e4ln⁡(x−1)e^{4\ln(x-1)} makes the next steps unusable.
Multiplying the standard form by (x−1)4(x-1)^4,

(x−1)4dydx+4(x−1)3y=x2−1ddx((x−1)4y)=x2−1(x−1)4y=x33−x+C.\begin{align*} (x-1)^4\frac{dy}{dx}+4(x-1)^3y &= x^2-1 \\ \frac{d}{dx}\big((x-1)^4y\big) &= x^2-1 \\ (x-1)^4y &= \frac{x^3}{3}-x+C. \end{align*}

Imposing y(0)=2y(0)=2,

(0−1)4×2=0−0+C,(0-1)^4\times2=0-0+C,

so C=2C=2. Therefore

y=x33−x+2(x−1)4=x3−3x+63(x−1)4.y=\frac{\frac{x^3}{3}-x+2}{(x-1)^4}=\frac{x^3-3x+6}{3(x-1)^4}.

Note the solution is valid on (−∞,1)(-\infty,1) or (1,∞)(1,\infty) but never at x=1x=1; in fact no real-valued solution of the original ODE can have 11 in its domain.

Example. An investor has a salary of $60,000\$60{,}000 per year, expected to increase at $1000\$1000 per annum. An initial deposit of $1000\$1000 is invested in a program paying 8%8\% per annum, and the investor deposits 5%5\% of their salary each year. Find the amount invested after tt years (assuming interest and deposits are calculated continuously).
Let y(t)y(t) denote the dollars invested after tt years. Then

dydt=0.08y+0.05(60000+1000t),\frac{dy}{dt}=0.08y+0.05(60000+1000t),

i.e. (rate of increase of investment) == (8%8\% of investment) ++ (5%5\% of salary). In standard form,

dydt−0.08y=3000+50t,\frac{dy}{dt}-0.08y=3000+50t,

which is first order linear with integrating factor h(t)=e∫−0.08 dt=e−0.08th(t)=e^{\int-0.08\,dt}=e^{-0.08t}. Hence

ddt(e−0.08ty)=(3000+50t)e−0.08t.\frac{d}{dt}\big(e^{-0.08t}y\big)=(3000+50t)e^{-0.08t}.

Integrating the right-hand side by parts, with u=3000+50tu=3000+50t and v′=e−0.08tv'=e^{-0.08t} (so v=−12.5e−0.08tv=-12.5e^{-0.08t}),

∫(3000+50t)e−0.08t dt=−12.5(3000+50t)e−0.08t+∫625e−0.08t dt=−(37500+625t)e−0.08t−7812.5e−0.08t+C=−(625t+45312.5)e−0.08t+C.\begin{align*} \int(3000+50t)e^{-0.08t}\,dt &= -12.5(3000+50t)e^{-0.08t}+\int625e^{-0.08t}\,dt \\ &= -(37500+625t)e^{-0.08t}-7812.5e^{-0.08t}+C \\ &= -(625t+45312.5)e^{-0.08t}+C. \end{align*}

So e−0.08ty=−(625t+45312.5)e−0.08t+Ce^{-0.08t}y=-(625t+45312.5)e^{-0.08t}+C, and dividing through,

y(t)=−625t−45312.5+Ce0.08t.y(t)=-625t-45312.5+Ce^{0.08t}.

Imposing y(0)=1000y(0)=1000 gives C=46312.5C=46312.5, hence

y(t)=46312.5 e0.08t−625t−45312.5.y(t)=46312.5\,e^{0.08t}-625t-45312.5.

Therefore after 10 years, the investment totals y(10)≈$51507.86y(10)\approx\$51507.86.

Example. Some ODEs are both separable and linear; solve dydx+2y=4\dfrac{dy}{dx}+2y=4 both ways and check the answers agree.
Method 1 (separable). Write dydx=4−2y\dfrac{dy}{dx}=4-2y and separate:

14−2y dy=dx−12ln⁡∣4−2y∣=x+Cln⁡∣4−2y∣=−2x+C14−2y=Ke−2xy=2+C2e−2x.\begin{align*} \frac{1}{4-2y}\,dy &= dx \\ -\frac{1}{2}\ln|4-2y| &= x+C \\ \ln|4-2y| &= -2x+C_1 \\ 4-2y &= Ke^{-2x} \\ y &= 2+C_2e^{-2x}. \end{align*}

Method 2 (linear). Here f(x)=2f(x)=2, so h(x)=e2xh(x)=e^{2x} and

ddx(e2xy)=4e2xe2xy=2e2x+Cy=2+Ce−2x.\begin{align*} \frac{d}{dx}\big(e^{2x}y\big) &= 4e^{2x} \\ e^{2x}y &= 2e^{2x}+C \\ y &= 2+Ce^{-2x}. \end{align*}

Both methods produce the same family y=2+Ce−2xy=2+Ce^{-2x}; the arbitrary constants just get relabelled along the way. So when an ODE is both types, use whichever method you spot first (separation is usually less writing).

3.5 Exact ODEs#

Here is another approach to solving (some) first order ODEs. Suppose HH is a function of two variables xx and yy satisfying

H(x,y)=C,H(x,y)=C,

where CC is a real constant. If we consider yy as a function of xx and differentiate both sides with respect to xx, then the chain rule from Chapter 1 gives

∂H∂x+∂H∂ydydx=0.\frac{\partial H}{\partial x}+\frac{\partial H}{\partial y}\frac{dy}{dx}=0.

Denoting ∂H∂x\dfrac{\partial H}{\partial x} and ∂H∂y\dfrac{\partial H}{\partial y} by FF and GG respectively, we obtain the differential equation

F(x,y)+G(x,y)dydx=0.F(x,y)+G(x,y)\frac{dy}{dx}=0.

Conversely, if we want to solve an ODE of this form and there happens to exist an HH with F=∂H∂xF=\dfrac{\partial H}{\partial x} and G=∂H∂yG=\dfrac{\partial H}{\partial y}, then the solution is simply H(x,y)=CH(x,y)=C. The difficulty is that this condition on FF and GG is not easy to verify directly. Fortunately, the mixed derivative theorem says that for a 'nice' HH,

∂2H∂y ∂x=∂2H∂x ∂y,i.e.∂F∂y=∂G∂x,\frac{\partial^2H}{\partial y\,\partial x}=\frac{\partial^2H}{\partial x\,\partial y}, \quad\text{i.e.}\quad \frac{\partial F}{\partial y}=\frac{\partial G}{\partial x},

and this second condition is easy to check.

Note

Definition
An ordinary differential equation of the form

F(x,y)+G(x,y)dydx=0F(x,y)+G(x,y)\frac{dy}{dx}=0

is called exact if

∂F∂y=∂G∂x.\frac{\partial F}{\partial y}=\frac{\partial G}{\partial x}.

Note

Theorem
Suppose that an ordinary differential equation of the above form is exact. Then its solution is given by H(x,y)=CH(x,y)=C, where CC is a constant and HH is a function satisfying

∂H∂x=Fand∂H∂y=G.\frac{\partial H}{\partial x}=F \quad\text{and}\quad \frac{\partial H}{\partial y}=G.

Basically: an exact ODE is one whose left-hand side is secretly the total derivative of some two-variable function HH, and the exactness test (equality of the mixed partials) is how you detect this without knowing HH. Note the ODE can equivalently be written as dydx=−F(x,y)G(x,y)\dfrac{dy}{dx}=-\dfrac{F(x,y)}{G(x,y)} or as F(x,y) dx+G(x,y) dy=0F(x,y)\,dx+G(x,y)\,dy=0.

Example. Show that the differential equation

dydx=−2x+y+12y+x+1\frac{dy}{dx}=-\frac{2x+y+1}{2y+x+1}

is exact, and hence find its solution.
First rewrite the ODE as

(2x+y+1)+(2y+x+1)dydx=0,(2x+y+1)+(2y+x+1)\frac{dy}{dx}=0,

and write F=2x+y+1F=2x+y+1 and G=2y+x+1G=2y+x+1. Then

∂F∂y=1=∂G∂x,\frac{\partial F}{\partial y}=1=\frac{\partial G}{\partial x},

so the ODE is exact. Hence there is a function HH with ∂H∂x=F\dfrac{\partial H}{\partial x}=F and ∂H∂y=G\dfrac{\partial H}{\partial y}=G. Integrating FF with respect to xx (treating yy as a constant), and integrating GG with respect to yy (treating xx as a constant),

H(x,y)=x2+xy+x+C1(y),H(x,y)=y2+xy+y+C2(x),\begin{align*} H(x,y) &= x^2+xy+x+C_1(y), \\ H(x,y) &= y^2+xy+y+C_2(x), \end{align*}

where the 'constants of integration' C1(y)C_1(y) and C2(x)C_2(x) are functions of yy and xx respectively. Comparing the two expressions,

H(x,y)=x2+xy+y2+x+y,H(x,y)=x^2+xy+y^2+x+y,

and so the solution to the ODE is

x2+xy+y2+x+y=C,x^2+xy+y^2+x+y=C,

where C∈RC\in\mathbb{R}. (Technically HH should carry its own arbitrary constant +K+K, but it just merges into CC on the right-hand side, so it is customary to ignore it.) Since this is a quadratic in yy you could use the quadratic formula to write yy explicitly, but the answer is much cleaner left in implicit form.

Example. Solve the differential equation

2xsin⁡(x2+y2)+(2ysin⁡(x2+y2)+2y)dydx=0.2x\sin(x^2+y^2)+\big(2y\sin(x^2+y^2)+2y\big)\frac{dy}{dx}=0.

Write F(x,y)=2xsin⁡(x2+y2)F(x,y)=2x\sin(x^2+y^2) and G(x,y)=2ysin⁡(x2+y2)+2yG(x,y)=2y\sin(x^2+y^2)+2y. Then

∂F∂y=4xycos⁡(x2+y2)=∂G∂x,\frac{\partial F}{\partial y}=4xy\cos(x^2+y^2)=\frac{\partial G}{\partial x},

so the equation is exact. This time we use a slightly different approach to find HH. Integrating FF with respect to xx,

H(x,y)=−cos⁡(x2+y2)+C1(y).H(x,y)=-\cos(x^2+y^2)+C_1(y).

To determine C1(y)C_1(y), differentiate this with respect to yy and compare with GG:

∂H∂y=2ysin⁡(x2+y2)+C1′(y)=2ysin⁡(x2+y2)+2y,\begin{align*} \frac{\partial H}{\partial y} &= 2y\sin(x^2+y^2)+C_1'(y) \\ &= 2y\sin(x^2+y^2)+2y, \end{align*}

so C1′(y)=2yC_1'(y)=2y, whence C1(y)=y2C_1(y)=y^2. Hence H(x,y)=−cos⁡(x2+y2)+y2H(x,y)=-\cos(x^2+y^2)+y^2 and the solution is

y2−cos⁡(x2+y2)=C,y^2-\cos(x^2+y^2)=C,

where C∈RC\in\mathbb{R}. Notice how taking C=0C=0 recovers y2=cos⁡(x2+y2)y^2=\cos(x^2+y^2), which is exactly the particular solution we verified back in Section 3.1; and here it is not possible to make yy explicit at all.

Example. Solve the differential equation

(ex−sin⁡y) dx+cos⁡y dy=0.(e^x-\sin y)\,dx+\cos y\,dy=0.

Write F(x,y)=ex−sin⁡yF(x,y)=e^x-\sin y and G(x,y)=cos⁡yG(x,y)=\cos y. Since

∂F∂y=−cos⁡ybut∂G∂x=0,\frac{\partial F}{\partial y}=-\cos y \quad\text{but}\quad \frac{\partial G}{\partial x}=0,

the ODE is not exact. What happens if we barge ahead with the method regardless? Integrating FF with respect to xx gives H(x,y)=ex−xsin⁡y+C1(y)H(x,y)=e^x-x\sin y+C_1(y), and then

∂H∂y=−xcos⁡y+C1′(y)=cos⁡y\frac{\partial H}{\partial y}=-x\cos y+C_1'(y)=\cos y

forces C1′(y)=(1+x)cos⁡yC_1'(y)=(1+x)\cos y, which contradicts C1(y)C_1(y) being independent of xx; no such HH exists.
Fortunately, not all is lost. Multiplying the whole ODE by e−xe^{-x} gives

(1−e−xsin⁡y) dx+e−xcos⁡y dy=0,(1-e^{-x}\sin y)\,dx+e^{-x}\cos y\,dy=0,

and since e−xe^{-x} is never zero, this has the same solutions as the original. Checking the exactness test again with F=1−e−xsin⁡yF=1-e^{-x}\sin y and G=e−xcos⁡yG=e^{-x}\cos y,

∂F∂y=−e−xcos⁡y=∂G∂x,\frac{\partial F}{\partial y}=-e^{-x}\cos y=\frac{\partial G}{\partial x},

so the new equation is exact. Integrating FF with respect to xx,

H(x,y)=x+e−xsin⁡y+C1(y),H(x,y)=x+e^{-x}\sin y+C_1(y),

and comparing ∂H∂y=e−xcos⁡y+C1′(y)\dfrac{\partial H}{\partial y}=e^{-x}\cos y+C_1'(y) with GG shows C1′(y)=0C_1'(y)=0. Therefore the solution is

x+e−xsin⁡y=C,x+e^{-x}\sin y=C,

where C∈RC\in\mathbb{R}. In general, finding a multiplier that fixes a non-exact ODE like this is difficult and lies beyond the scope of this course; here it was handed to us.

Example. (Classify, then solve.) For each of the following, name the method (separable, linear or exact) before touching any algebra, then solve.
(a) dydx=xy2\dfrac{dy}{dx}=xy^2
(b) xdydx+2y=x3x\dfrac{dy}{dx}+2y=x^3, for x>0x>0
(c) (2xy+1)+(x2+2y)dydx=0(2xy+1)+(x^2+2y)\dfrac{dy}{dx}=0
(d) dydx=ex+y\dfrac{dy}{dx}=e^{x+y}

(a) The right-hand side factors as (function of xx)×\times(function of yy), so this is separable (it is not linear because of the y2y^2):

1y2 dy=x dx−1y=x22+Cy=−2x2+C1,\begin{align*} \frac{1}{y^2}\,dy &= x\,dx \\ -\frac{1}{y} &= \frac{x^2}{2}+C \\ y &= \frac{-2}{x^2+C_1}, \end{align*}

where C1=2CC_1=2C. (The constant function y=0y=0 is also a solution; separation quietly divided it away.)

(b) Dividing by xx gives dydx+2xy=x2\dfrac{dy}{dx}+\dfrac{2}{x}y=x^2, which is the linear standard form (it is not separable since the x2x^2 term stops the right side from factorising). The integrating factor is h(x)=e∫2xdx=e2ln⁡x=x2h(x)=e^{\int\frac{2}{x}dx}=e^{2\ln x}=x^2, so

ddx(x2y)=x4x2y=x55+Cy=x35+Cx2.\begin{align*} \frac{d}{dx}\big(x^2y\big) &= x^4 \\ x^2y &= \frac{x^5}{5}+C \\ y &= \frac{x^3}{5}+\frac{C}{x^2}. \end{align*}

(c) This is in the form F+Gdydx=0F+G\dfrac{dy}{dx}=0 with F=2xy+1F=2xy+1 and G=x2+2yG=x^2+2y; checking the exactness test, ∂F∂y=2x=∂G∂x\dfrac{\partial F}{\partial y}=2x=\dfrac{\partial G}{\partial x}, so it is exact. Integrating FF with respect to xx gives H=x2y+x+C1(y)H=x^2y+x+C_1(y), and comparing ∂H∂y=x2+C1′(y)\dfrac{\partial H}{\partial y}=x^2+C_1'(y) with GG gives C1′(y)=2yC_1'(y)=2y, so C1(y)=y2C_1(y)=y^2. The solution is

x2y+x+y2=C.x^2y+x+y^2=C.

(d) This looks like none of the types, but since ex+y=exeye^{x+y}=e^xe^y it is separable in disguise:

e−y dy=ex dx−e−y=ex+Cy=−ln⁡(C1−ex),\begin{align*} e^{-y}\,dy &= e^x\,dx \\ -e^{-y} &= e^x+C \\ y &= -\ln(C_1-e^x), \end{align*}

where C1=−CC_1=-C (and we need ex<C1e^x<C_1 for the log to make sense).
The decision order I use: try to separate first; if that fails, hunt for the linear standard form; if that also fails, rearrange into F+G y′=0F+G\,y'=0 and run the exactness test.

3.6 Solving ODEs by using a change of variable [X]#

This section is MATH1241/extension [X] material only, so imma keep it brief.

Not every first order ODE is separable, linear or exact, but some can be transformed into one of these types by a suitable change of variable; you solve the transformed equation for the new variable, then convert back.

Example. Use the substitution y(x)=x⋅v(x)y(x)=x\cdot v(x) to solve

dydx=xy−y2x2.\frac{dy}{dx}=\frac{xy-y^2}{x^2}.

By the product rule, dydx=v+xdvdx\dfrac{dy}{dx}=v+x\dfrac{dv}{dx}. Substituting (and using y=xvy=xv on the right),

v+xdvdx=x(xv)−(xv)2x2v+xdvdx=v−v2xdvdx=−v2−1v2 dv=1x dx(now separable)1v=ln⁡∣x∣+Cv=1ln⁡∣x∣+C.\begin{align*} v+x\frac{dv}{dx} &= \frac{x(xv)-(xv)^2}{x^2} \\ v+x\frac{dv}{dx} &= v-v^2 \\ x\frac{dv}{dx} &= -v^2 \\ -\frac{1}{v^2}\,dv &= \frac{1}{x}\,dx \quad (\text{now separable}) \\ \frac{1}{v} &= \ln|x|+C \\ v &= \frac{1}{\ln|x|+C}. \end{align*}

Since v=yxv=\dfrac{y}{x}, the general solution is

y=xln⁡∣x∣+C,y=\frac{x}{\ln|x|+C},

where C∈RC\in\mathbb{R}.

Example. Solve

dydt+2y+y2t2e2t=0\frac{dy}{dt}+2y+y^2t^2e^{2t}=0

using the substitution z=1/yz=1/y.
The y2y^2 term means this is not linear in yy, but it will turn out linear in zz. Differentiating y=1zy=\dfrac{1}{z} with respect to tt gives dydt=−1z2dzdt\dfrac{dy}{dt}=-\dfrac{1}{z^2}\dfrac{dz}{dt}, so the ODE becomes

−1z2dzdt+2z+t2e2tz2=0dzdt−2z=t2e2t(multiplying through by −z2)ddt(e−2tz)=t2(integrating factor e−2t)e−2tz=t33+C0z=e2t(t33+C0).\begin{align*} -\frac{1}{z^2}\frac{dz}{dt}+\frac{2}{z}+\frac{t^2e^{2t}}{z^2} &= 0 \\ \frac{dz}{dt}-2z &= t^2e^{2t} \quad (\text{multiplying through by } -z^2) \\ \frac{d}{dt}\big(e^{-2t}z\big) &= t^2 \quad (\text{integrating factor } e^{-2t}) \\ e^{-2t}z &= \frac{t^3}{3}+C_0 \\ z &= e^{2t}\left(\frac{t^3}{3}+C_0\right). \end{align*}

Since y=1/zy=1/z, the solution is

y=3e2t(t3+C),y=\frac{3}{e^{2t}(t^3+C)},

where C=3C0∈RC=3C_0\in\mathbb{R}. Notice how the substitution converted a nonlinear ODE in yy into a first order linear ODE in zz.

3.7 Modelling with first order ODEs#

Many real-life problems can be analysed by converting them into mathematics; the theoretical framework (with all its simplifying assumptions) is called a mathematical model, and its reliability is judged by how well it predicts what actually happens. To construct one, you should

  1. describe accurately the data you have,
  2. decide exactly what information you want out of the model,
  3. decide which variables are dependent and which are independent, and
  4. describe how the dependent variables change as the independent ones vary (this is usually where the differential equation appears).

We have already built two models: Newton's law of cooling and the investment example in Section 3.4.

Mixing problems#

Example. A martini is, in essence, a mixture of gin and vermouth. James Blond insists his martinis be prepared as follows: initially, 40 cc of gin are placed in a large container; then gin is poured in at 2 cc/sec while vermouth is poured in at 6 cc/sec. The mixture is constantly shaken (not stirred) and flows out at 4 cc/sec.
(a) Find an expression for the volume of vermouth in the container tt seconds after pouring commences.
(b) James likes his martini roughly two parts gin to three parts vermouth. How many seconds should elapse before he inserts a cocktail glass into the outflow?

(a) Let V(t)V(t) denote the volume of vermouth (in cc) at time tt; we know V(0)=0V(0)=0. The key modelling equation for any mixing problem is

dVdt=(rate of inflow)−(rate of outflow).\frac{dV}{dt}=(\text{rate of inflow})-(\text{rate of outflow}).

The inflow of vermouth is 66 cc/sec. For the outflow, the total volume of liquid at time tt is

40+2t+6t−4t=40+4t,40+2t+6t-4t=40+4t,

so the proportion (by volume) of vermouth in the container is V(t)40+4t\dfrac{V(t)}{40+4t}, and since liquid leaves at 44 cc/sec, vermouth leaves at 4V(t)40+4t=V(t)10+t\dfrac{4V(t)}{40+4t}=\dfrac{V(t)}{10+t} cc/sec. Hence we obtain the IVP

dVdt=6−V10+t,V(0)=0.\frac{dV}{dt}=6-\frac{V}{10+t}, \qquad V(0)=0.

This is first order linear with integrating factor

h(t)=e∫110+tdt=eln⁡(10+t)=10+t,h(t)=e^{\int\frac{1}{10+t}dt}=e^{\ln(10+t)}=10+t,

so

ddt((10+t)V)=6(10+t)(10+t)V=60t+3t2+C.\begin{align*} \frac{d}{dt}\big((10+t)V\big) &= 6(10+t) \\ (10+t)V &= 60t+3t^2+C. \end{align*}

Imposing V(0)=0V(0)=0 gives C=0C=0, hence

V(t)=3t2+60t10+t.V(t)=\frac{3t^2+60t}{10+t}.

(b) Two parts gin to three parts vermouth means three-fifths of the liquid is vermouth, so we require

V(t)40+4t=353t2+60t4(10+t)2=355(3t2+60t)=12(10+t)215t2+300t=12t2+240t+12003t2+60t−1200=0t2+20t−400=0t=−10+500≈12.36,\begin{align*} \frac{V(t)}{40+4t} &= \frac{3}{5} \\ \frac{3t^2+60t}{4(10+t)^2} &= \frac{3}{5} \\ 5(3t^2+60t) &= 12(10+t)^2 \\ 15t^2+300t &= 12t^2+240t+1200 \\ 3t^2+60t-1200 &= 0 \\ t^2+20t-400 &= 0 \\ t &= -10+\sqrt{500} \approx 12.36, \end{align*}

where we took the positive root of the quadratic. Therefore James should insert the glass about 12.3612.36 seconds after mixing begins.

Example. (Mixing with a changing volume.) A tank can hold 100 litres. Initially it holds 50 litres of pure water. Brine containing 2 grams of salt per litre runs in at 3 litres per minute, and the well-stirred mixture runs out at 1 litre per minute. How much salt does the tank contain at the moment it starts to overflow?
Let x(t)x(t) be the mass of salt (in grams) after tt minutes; x(0)=0x(0)=0. The volume is not constant here: it gains 3−1=23-1=2 litres per minute, so the volume at time tt is 50+2t50+2t litres. Salt flows in at 2×3=62\times3=6 g/min and flows out at (concentration)×\times(outflow rate) =x50+2t×1=\dfrac{x}{50+2t}\times1 g/min. Hence

dxdt=6−x50+2t,x(0)=0.\frac{dx}{dt}=6-\frac{x}{50+2t}, \qquad x(0)=0.

The most common mistake in these problems is using a constant volume in the outflow concentration; whenever the inflow and outflow rates differ, the denominator must be a function of tt.
The ODE is linear with integrating factor

h(t)=e∫150+2tdt=e12ln⁡(50+2t)=50+2t,h(t)=e^{\int\frac{1}{50+2t}dt}=e^{\frac{1}{2}\ln(50+2t)}=\sqrt{50+2t},

so

ddt(50+2t  x)=650+2t50+2t  x=2(50+2t)3/2+Cx=2(50+2t)+C50+2t.\begin{align*} \frac{d}{dt}\big(\sqrt{50+2t}\;x\big) &= 6\sqrt{50+2t} \\ \sqrt{50+2t}\;x &= 2(50+2t)^{3/2}+C \\ x &= 2(50+2t)+\frac{C}{\sqrt{50+2t}}. \end{align*}

Imposing x(0)=0x(0)=0,

0=100+C50,0=100+\frac{C}{\sqrt{50}},

so C=−10050=−5002C=-100\sqrt{50}=-500\sqrt{2}. The tank overflows when 50+2t=10050+2t=100, i.e. at t=25t=25 minutes, at which point

x(25)=200−5002100=200−502=50(4−2).\begin{align*} x(25) &= 200-\frac{500\sqrt{2}}{\sqrt{100}} \\ &= 200-50\sqrt{2} \\ &= 50(4-\sqrt{2}). \end{align*}

Therefore the tank contains 50(4−2)≈129.350(4-\sqrt{2})\approx129.3 grams of salt at the point of overflowing.

Population models#

Suppose the city of Mathopolis initially has 3,000,000 inhabitants and (initially) grows at 2% per annum. Can we predict the population in 10, 20 or 100 years? We compare three models on this same data.

Example. (Model 1: exponential growth.) Assume the rate of change of population is proportional to the population, with constant growth rate rr:

dPdt=rP,P(0)=P0.\frac{dP}{dt}=rP, \qquad P(0)=P_0.

This is separable:

∫1P dP=∫r dtln⁡P=rt+CP(t)=P0ert.\begin{align*} \int\frac{1}{P}\,dP &= \int r\,dt \\ \ln P &= rt+C \\ P(t) &= P_0e^{rt}. \end{align*}

(This model goes back to Thomas Malthus, 1798.) For Mathopolis, P0=3,000,000P_0=3{,}000{,}000 and r=0.02r=0.02, so P(t)=3000000e0.02tP(t)=3000000e^{0.02t}; after 100 years this predicts about 22.17 million people.
Criticisms: the model predicts indefinite growth, ignoring that resources and space are finite; and external factors (disease, disasters, wars) are ignored.

Example. (Model 2: limited growth.) Now suppose there is a critical population PcP_c which, when exceeded, causes the population to decrease; below it the population increases. Try

dPdt=k(Pc−P),P(0)=P0,\frac{dP}{dt}=k(P_c-P), \qquad P(0)=P_0,

where k>0k>0 (so dPdt>0\dfrac{dP}{dt}>0 when P<PcP<P_c and dPdt<0\dfrac{dP}{dt}<0 when P>PcP>P_c). Separating (in the case P<PcP<P_c),

∫1Pc−P dP=∫k dt−ln⁡(Pc−P)=kt+CPc−P=Ae−ktP(t)=Pc−(Pc−P0)e−kt,\begin{align*} \int\frac{1}{P_c-P}\,dP &= \int k\,dt \\ -\ln(P_c-P) &= kt+C \\ P_c-P &= Ae^{-kt} \\ P(t) &= P_c-(P_c-P_0)e^{-kt}, \end{align*}

where imposing P(0)=P0P(0)=P_0 gave A=Pc−P0A=P_c-P_0 (the case P>PcP>P_c gives exactly the same formula). Note that P(t)→PcP(t)\to P_c as t→∞t\to\infty.
For Mathopolis, take Pc=7,000,000P_c=7{,}000{,}000 (the maximum sustainable size). Since dPdt=0.02P0=60000\dfrac{dP}{dt}=0.02P_0=60000 at t=0t=0,

60000=k(7000000−3000000),60000=k(7000000-3000000),

so k=0.015k=0.015 and

P(t)=7000000−4000000e−0.015t.P(t)=7000000-4000000e^{-0.015t}.

Criticism: if PP is close to 00 then dPdt≈kPc\dfrac{dP}{dt}\approx kP_c, so the model says tiny populations grow fastest, which is silly.

Example. (Model 3: the logistic model.) To fix the small-population problem, try

dPdt=kP(Pc−P),P(0)=P0,\frac{dP}{dt}=kP(P_c-P), \qquad P(0)=P_0,

where k>0k>0; now dPdt\dfrac{dP}{dt} is small when PP is small (Verhulst, 1838). Separating and using partial fractions on the left,

∫1P(Pc−P) dP=∫k dt1Pc∫(1P+1Pc−P)dP=∫k dt1Pc(ln⁡P−ln⁡(Pc−P))=kt+Cln⁡(PPc−P)=kPct+C1PPc−P=AekPct,\begin{align*} \int\frac{1}{P(P_c-P)}\,dP &= \int k\,dt \\ \frac{1}{P_c}\int\left(\frac{1}{P}+\frac{1}{P_c-P}\right)dP &= \int k\,dt \\ \frac{1}{P_c}\big(\ln P-\ln(P_c-P)\big) &= kt+C \\ \ln\left(\frac{P}{P_c-P}\right) &= kP_ct+C_1 \\ \frac{P}{P_c-P} &= Ae^{kP_ct}, \end{align*}

where imposing P(0)=P0P(0)=P_0 gives A=P0Pc−P0A=\dfrac{P_0}{P_c-P_0}. Rearranging for PP,

P=(Pc−P)AekPctP(1+AekPct)=PcAekPctP=PcAekPct1+AekPct,\begin{align*} P &= (P_c-P)Ae^{kP_ct} \\ P\big(1+Ae^{kP_ct}\big) &= P_cAe^{kP_ct} \\ P &= \frac{P_cAe^{kP_ct}}{1+Ae^{kP_ct}}, \end{align*}

and substituting in AA then multiplying top and bottom by (Pc−P0)e−kPct(P_c-P_0)e^{-kP_ct},

P(t)=PcP0P0+(Pc−P0)e−kPct.\boxed{P(t)=\frac{P_cP_0}{P_0+(P_c-P_0)e^{-kP_ct}}.}

Once again P(t)→PcP(t)\to P_c as t→∞t\to\infty. The resulting S-shaped curve is called a logistic curve: growth is approximately exponential at the start, then slows and approaches PcP_c asymptotically.
For Mathopolis, 60000=kP0(Pc−P0)=k×3000000×400000060000=kP_0(P_c-P_0)=k\times3000000\times4000000 gives k=5×10−9k=5\times10^{-9}, so kPc=0.035kP_c=0.035 and

P(t)=210000003+4e−0.035t.P(t)=\frac{21000000}{3+4e^{-0.035t}}.

Comparing the three forecasts (in millions):

Initially After 10 years After 20 years After 100 years
Model 1 3.00 3.66 4.48 22.17
Model 2 3.00 3.56 4.04 6.11
Model 3 3.00 3.61 4.21 6.73

All three models still ignore external factors (PcP_c itself can shift with technology or climate). Notice how the more realistic the model, the harder the mathematics; at the extreme end, the (partial) differential equations modelling fluid flow (the Navier–Stokes equations) are so hard that existence of smooth solutions is a Millennium problem worth one million US dollars.

3.8 Second order linear ODEs with constant coefficients#

We now consider a special class of second order equations, of the form

d2ydx2+adydx+by=f(x),\frac{d^2y}{dx^2}+a\frac{dy}{dx}+by=f(x),

where aa and bb are real numbers. These arise naturally in wave mechanics and predator-prey models; you have already seen d2xdt2+n2x=0\dfrac{d^2x}{dt^2}+n^2x=0 used to model simple harmonic motion.

The homogeneous case#

We first look at the case when f(x)≡0f(x)\equiv0 (i.e. f(x)=0f(x)=0 for all xx).

Note

Definition
A second order linear ODE with constant coefficients is said to be homogeneous if it is of the form

d2ydx2+adydx+by=0,\frac{d^2y}{dx^2}+a\frac{dy}{dx}+by=0,

where aa and bb are real numbers.

It turns out we can always solve these. The first key observation:

Note

Lemma
If y1y_1 and y2y_2 are two solutions to the homogeneous equation, then any linear combination Ay1+By2Ay_1+By_2, where AA and BB are real numbers, is also a solution.

Proof. Let y=Ay1+By2y=Ay_1+By_2. Then

y′′+ay′+by=(Ay1+By2)′′+a(Ay1+By2)′+b(Ay1+By2)=A(y1′′+ay1′+by1)+B(y2′′+ay2′+by2)(regrouping by linearity of differentiation)=A×0+B×0(since y1,y2 are solutions)=0.■\begin{align*} y''+ay'+by &= (Ay_1+By_2)''+a(Ay_1+By_2)'+b(Ay_1+By_2) \\ &= A(y_1''+ay_1'+by_1)+B(y_2''+ay_2'+by_2) \quad (\text{regrouping by linearity of differentiation}) \\ &= A\times0+B\times0 \quad (\text{since } y_1,y_2 \text{ are solutions}) \\ &= 0. \quad \blacksquare \end{align*}

It can also be shown that every second order ODE has at most two linearly independent solutions (proved in second year); here two solutions are linearly independent if and only if they are not constant multiples of each other. So the entire game is: find two linearly independent solutions y1,y2y_1,y_2, and then y=Ay1+By2y=Ay_1+By_2 is the general solution.

To hunt for a solution, we try a function that does not change too much when differentiated, since the terms on the left-hand side need to cancel each other out to give zero. If y=eλxy=e^{\lambda x} (with λ\lambda constant), then y′=λeλxy'=\lambda e^{\lambda x} and y′′=λ2eλxy''=\lambda^2e^{\lambda x}, so substituting,

λ2eλx+aλeλx+beλx=0λ2+aλ+b=0(dividing by eλx≠0).\begin{align*} \lambda^2e^{\lambda x}+a\lambda e^{\lambda x}+be^{\lambda x} &= 0 \\ \lambda^2+a\lambda+b &= 0 \quad (\text{dividing by } e^{\lambda x}\neq0). \end{align*}

Hence y=eλxy=e^{\lambda x} is a solution if and only if λ\lambda is a root of this quadratic.

Note

Definition
The characteristic equation of the second order linear ODE d2ydx2+adydx+by=0\dfrac{d^2y}{dx^2}+a\dfrac{dy}{dx}+by=0 is given by

λ2+aλ+b=0.\lambda^2+a\lambda+b=0.

Example. Solve d2ydx2−5dydx+6y=0\dfrac{d^2y}{dx^2}-5\dfrac{dy}{dx}+6y=0.
The characteristic equation is

λ2−5λ+6=0(λ−2)(λ−3)=0,\begin{align*} \lambda^2-5\lambda+6 &= 0 \\ (\lambda-2)(\lambda-3) &= 0, \end{align*}

so λ=2,3\lambda=2,3. Hence y1=e2xy_1=e^{2x} and y2=e3xy_2=e^{3x} are solutions, and since they are linearly independent, the general solution is

y=Ae2x+Be3x,y=Ae^{2x}+Be^{3x},

where A,B∈RA,B\in\mathbb{R}.

In that example the characteristic equation had two distinct real roots. Since aa and bb are real, there are three possibilities in general: two distinct real roots, a repeated real root, or a complex conjugate pair.

For a repeated real root λ1\lambda_1, the second independent solution is y2=xeλ1xy_2=xe^{\lambda_1x}. To verify this, note a repeated root satisfies both λ12+aλ1+b=0\lambda_1^2+a\lambda_1+b=0 and 2λ1+a=02\lambda_1+a=0 (the vertex of the parabola); with y=xeλ1xy=xe^{\lambda_1x}, y′=eλ1x(1+λ1x)y'=e^{\lambda_1x}(1+\lambda_1x) and y′′=eλ1x(2λ1+λ12x)y''=e^{\lambda_1x}(2\lambda_1+\lambda_1^2x), so

y′′+ay′+by=eλ1x((2λ1+a)+x(λ12+aλ1+b))=0,y''+ay'+by=e^{\lambda_1x}\big((2\lambda_1+a)+x(\lambda_1^2+a\lambda_1+b)\big)=0,

since both brackets vanish.

For complex roots α±βi\alpha\pm\beta i (with β≠0\beta\neq0), the two exponential solutions are complex-valued, but we can extract real solutions using Euler's formula eiθ=cos⁡θ+isin⁡θe^{i\theta}=\cos\theta+i\sin\theta:

y=Ce(α+βi)x+De(α−βi)x=eαx(Ceiβx+De−iβx)=eαx(C(cos⁡βx+isin⁡βx)+D(cos⁡βx−isin⁡βx))=eαx((C+D)cos⁡βx+i(C−D)sin⁡βx)=eαx(Acos⁡βx+Bsin⁡βx),\begin{align*} y &= Ce^{(\alpha+\beta i)x}+De^{(\alpha-\beta i)x} \\ &= e^{\alpha x}\big(Ce^{i\beta x}+De^{-i\beta x}\big) \\ &= e^{\alpha x}\big(C(\cos\beta x+i\sin\beta x)+D(\cos\beta x-i\sin\beta x)\big) \\ &= e^{\alpha x}\big((C+D)\cos\beta x+i(C-D)\sin\beta x\big) \\ &= e^{\alpha x}\big(A\cos\beta x+B\sin\beta x\big), \end{align*}

where A=C+DA=C+D and B=i(C−D)B=i(C-D); choosing CC and DD to be complex conjugates of each other makes AA and BB real. We summarise all three cases:

Note

Theorem
Consider the homogeneous ODE y′′+ay′+by=0y''+ay'+by=0 and let λ1\lambda_1 and λ2\lambda_2 denote the roots of the characteristic equation λ2+aλ+b=0\lambda^2+a\lambda+b=0.
(i) If λ1\lambda_1 and λ2\lambda_2 are different real numbers, then the general solution is

y=Aeλ1x+Beλ2x,A,B∈R.y=Ae^{\lambda_1x}+Be^{\lambda_2x}, \quad A,B\in\mathbb{R}.

(ii) If λ1=λ2\lambda_1=\lambda_2, then the general solution is

y=Aeλ1x+Bxeλ1x,A,B∈R.y=Ae^{\lambda_1x}+Bxe^{\lambda_1x}, \quad A,B\in\mathbb{R}.

(iii) If λ1=α+βi\lambda_1=\alpha+\beta i and λ2=α−βi\lambda_2=\alpha-\beta i, where α,β∈R\alpha,\beta\in\mathbb{R} and β≠0\beta\neq0, then the general solution is

y=eαx(Acos⁡(βx)+Bsin⁡(βx)),A,B∈R.y=e^{\alpha x}\big(A\cos(\beta x)+B\sin(\beta x)\big), \quad A,B\in\mathbb{R}.

Example. Solve the following differential equations:
(a) y′′−6y′+25y=0y''-6y'+25y=0,
(b) y′′+4y′+4y=0y''+4y'+4y=0, with initial conditions y(0)=1y(0)=1 and y′(0)=0y'(0)=0.

(a) The characteristic equation λ2−6λ+25=0\lambda^2-6\lambda+25=0 has roots

λ=6±36−1002=3±4i,\lambda=\frac{6\pm\sqrt{36-100}}{2}=3\pm4i,

so by case (iii) the general solution is

y=e3x(Acos⁡4x+Bsin⁡4x),y=e^{3x}(A\cos4x+B\sin4x),

where A,B∈RA,B\in\mathbb{R}.

(b) The characteristic equation factorises as (λ+2)2=0(\lambda+2)^2=0, so −2-2 is a repeated root and

y=Ae−2x+Bxe−2x.y=Ae^{-2x}+Bxe^{-2x}.

Differentiating (for the second initial condition),

y′=−2Ae−2x+Be−2x−2Bxe−2x.y'=-2Ae^{-2x}+Be^{-2x}-2Bxe^{-2x}.

Now y(0)=1y(0)=1 gives A=1A=1, and y′(0)=0y'(0)=0 gives −2A+B=0-2A+B=0, so B=2B=2. Therefore the solution to the IVP is

y=e−2x+2xe−2x.y=e^{-2x}+2xe^{-2x}.

The non-homogeneous case#

Now suppose ff is not identically zero. The main idea is illustrated by an example.

Example. Solve the equation

y′′−5y′+6y=12x−4.y''-5y'+6y=12x-4.

Since derivatives of polynomials are polynomials, it seems likely some particular solution is a polynomial, and a little thought shows its degree can be at most one. So we look for a particular solution of the form yP=ax+by_P=ax+b. Then yP′=ay_P'=a and yP′′=0y_P''=0, and substituting,

0−5a+6(ax+b)=12x−46ax+(6b−5a)=12x−4.\begin{align*} 0-5a+6(ax+b) &= 12x-4 \\ 6ax+(6b-5a) &= 12x-4. \end{align*}

Equating coefficients: 6a=126a=12 gives a=2a=2, and then 6b−10=−46b-10=-4 gives b=1b=1. Hence yP=2x+1y_P=2x+1.
Are there other solutions? Yes. The associated homogeneous equation y′′−5y′+6y=0y''-5y'+6y=0 has solution yH=Ae2x+Be3xy_H=Ae^{2x}+Be^{3x} (from the earlier example), and y=yH+yPy=y_H+y_P is also a solution:

y′′−5y′+6y=(yH+yP)′′−5(yH+yP)′+6(yH+yP)=(yH′′−5yH′+6yH)+(yP′′−5yP′+6yP)(by linearity of differentiation)=0+(12x−4)=12x−4.\begin{align*} y''-5y'+6y &= (y_H+y_P)''-5(y_H+y_P)'+6(y_H+y_P) \\ &= (y_H''-5y_H'+6y_H)+(y_P''-5y_P'+6y_P) \quad (\text{by linearity of differentiation}) \\ &= 0+(12x-4) \\ &= 12x-4. \end{align*}

Therefore the general solution is

y=Ae2x+Be3x+2x+1,y=Ae^{2x}+Be^{3x}+2x+1,

where A,B∈RA,B\in\mathbb{R} (that this really is all the solutions is explained in the linear algebra subsection below).

The general algorithm for y′′+ay′+by=f(x)y''+ay'+by=f(x):

  1. Find the solution yHy_H to the corresponding homogeneous equation (via the characteristic equation).
  2. Find a particular solution yPy_P (by guessing its form and determining the unknown coefficients — the method of undetermined coefficients).
  3. The general solution is

y=yH+yP.\boxed{y=y_H+y_P.}

Always perform Step 1 before Step 2; without knowing yHy_H you cannot tell whether your guess for yPy_P secretly solves the homogeneous equation (the reason will become obvious shortly).

Example. Solve the ODE

y′′−4y′+5y=20e−x.y''-4y'+5y=20e^{-x}.

First, the characteristic equation λ2−4λ+5=0\lambda^2-4\lambda+5=0 has roots 2±i2\pm i, so

yH=e2x(Acos⁡x+Bsin⁡x).y_H=e^{2x}(A\cos x+B\sin x).

Second, since the right-hand side is an exponential, try yP=ae−xy_P=ae^{-x}; then yP′=−ae−xy_P'=-ae^{-x} and yP′′=ae−xy_P''=ae^{-x}, so substituting,

ae−x+4ae−x+5ae−x=20e−x10a=20a=2.\begin{align*} ae^{-x}+4ae^{-x}+5ae^{-x} &= 20e^{-x} \\ 10a &= 20 \\ a &= 2. \end{align*}

Therefore the general solution is

y=e2x(Acos⁡x+Bsin⁡x)+2e−x,y=e^{2x}(A\cos x+B\sin x)+2e^{-x},

where A,B∈RA,B\in\mathbb{R}.

Given a forcing term ff, the correct form to guess for yPy_P is:

f(x)f(x) Guess for particular solution yPy_P
P(x)P(x) (polynomial of degree nn) Q(x)Q(x) (polynomial of degree nn)
P(x)esxP(x)e^{sx} Q(x)esxQ(x)e^{sx}
P(x)cos⁡(sx)P(x)\cos(sx) or P(x)sin⁡(sx)P(x)\sin(sx) Q1(x)cos⁡(sx)+Q2(x)sin⁡(sx)Q_1(x)\cos(sx)+Q_2(x)\sin(sx)
P(x)esxcos⁡(tx)P(x)e^{sx}\cos(tx) or P(x)esxsin⁡(tx)P(x)e^{sx}\sin(tx) Q1(x)esxcos⁡(tx)+Q2(x)esxsin⁡(tx)Q_1(x)e^{sx}\cos(tx)+Q_2(x)e^{sx}\sin(tx)

If any term of the guess for yPy_P is a solution to the homogeneous ODE, then multiply the guess by xx; if any term of the new guess is still a solution to the homogeneous ODE, multiply by xx again.

Example. Solve the ODE

y′′−3y′+2y=5e2x.y''-3y'+2y=5e^{2x}.

The characteristic equation λ2−3λ+2=0\lambda^2-3\lambda+2=0 has roots λ=1,2\lambda=1,2, so

yH=Ae2x+Bex.y_H=Ae^{2x}+Be^x.

Since the right-hand side is a multiple of e2xe^{2x}, the natural guess is yP=ae2xy_P=ae^{2x} — but this is a homogeneous solution (set A=aA=a, B=0B=0 in yHy_H), so substituting it produces 00 on the left-hand side and the guess fails. Following the rule, multiply by xx and try yP=axe2xy_P=axe^{2x} instead. Then

yP′=ae2x(2x+1),yP′′=ae2x(4x+4),\begin{align*} y_P' &= ae^{2x}(2x+1), \\ y_P'' &= ae^{2x}(4x+4), \end{align*}

and substituting,

ae2x(4x+4)−3ae2x(2x+1)+2axe2x=5e2xae2x((4x−6x+2x)+(4−3))=5e2xae2x=5e2xa=5.\begin{align*} ae^{2x}(4x+4)-3ae^{2x}(2x+1)+2axe^{2x} &= 5e^{2x} \\ ae^{2x}\big((4x-6x+2x)+(4-3)\big) &= 5e^{2x} \\ ae^{2x} &= 5e^{2x} \\ a &= 5. \end{align*}

Therefore the general solution is

y=Ae2x+Bex+5xe2x,y=Ae^{2x}+Be^x+5xe^{2x},

where A,B∈RA,B\in\mathbb{R}.

Example. Solve the ODE

y′′−6y′+9y=8e3x.y''-6y'+9y=8e^{3x}.

The characteristic equation factorises as (λ−3)2=0(\lambda-3)^2=0, giving the repeated root 33, so

yH=Ae3x+Bxe3x.y_H=Ae^{3x}+Bxe^{3x}.

The first guess yP=ae3xy_P=ae^{3x} solves the homogeneous equation; multiplying by xx gives axe3xaxe^{3x}, which also solves it (set A=0A=0, B=aB=a). So multiply by xx once more: yP=ax2e3xy_P=ax^2e^{3x}, which is finally not a homogeneous solution. Then

yP′=ae3x(3x2+2x),yP′′=ae3x(9x2+12x+2),\begin{align*} y_P' &= ae^{3x}(3x^2+2x), \\ y_P'' &= ae^{3x}(9x^2+12x+2), \end{align*}

and substituting,

ae3x((9x2+12x+2)−6(3x2+2x)+9x2)=8e3x2ae3x=8e3xa=4.\begin{align*} ae^{3x}\big((9x^2+12x+2)-6(3x^2+2x)+9x^2\big) &= 8e^{3x} \\ 2ae^{3x} &= 8e^{3x} \\ a &= 4. \end{align*}

Therefore the general solution is

y=Ae3x+Bxe3x+4x2e3x,y=Ae^{3x}+Bxe^{3x}+4x^2e^{3x},

where A,B∈RA,B\in\mathbb{R}.

Example. Write down the form of a particular solution to

d2ydt2−6dydt+13y=5e3tcos⁡(2t)\frac{d^2y}{dt^2}-6\frac{dy}{dt}+13y=5e^{3t}\cos(2t)

(without evaluating the coefficients).
The characteristic equation λ2−6λ+13=0\lambda^2-6\lambda+13=0 has roots

λ=6±36−522=3±2i,\lambda=\frac{6\pm\sqrt{36-52}}{2}=3\pm2i,

so yH=e3t(Acos⁡2t+Bsin⁡2t)y_H=e^{3t}(A\cos2t+B\sin2t). The table suggests the guess yP=ae3tcos⁡2t+be3tsin⁡2ty_P=ae^{3t}\cos2t+be^{3t}\sin2t — but every term of this solves the homogeneous equation. Multiplying by tt,

yP=ate3tcos⁡2t+bte3tsin⁡2t,y_P=ate^{3t}\cos2t+bte^{3t}\sin2t,

which no longer lies in the homogeneous solution space; this is the form we seek. Notice how this collision was invisible until yHy_H was computed — this is exactly why Step 1 comes first.

Example. Find a particular solution to

y′′−6y′+9y=x2e3x.y''-6y'+9y=x^2e^{3x}.

From before, yH=Ae3x+Bxe3xy_H=Ae^{3x}+Bxe^{3x}. The table suggests yP=(Cx2+Dx+E)e3xy_P=(Cx^2+Dx+E)e^{3x}; now x2e3xx^2e^{3x} itself is not a homogeneous solution, but the Dxe3xDxe^{3x} and Ee3xEe^{3x} terms are, so the whole guess must be multiplied by xx twice:

yP=(Cx4+Dx3+Ex2)e3x.y_P=(Cx^4+Dx^3+Ex^2)e^{3x}.

When the forcing term contains a polynomial, you must multiply the entire polynomial guess by xx (or x2x^2), not just the offending terms.
There is a slick way to find the coefficients here: writing y=ue3xy=ue^{3x}, direct computation gives

y′′−6y′+9y=(u′′+6u′+9u−6u′−18u+9u)e3x=u′′e3x,y''-6y'+9y=(u''+6u'+9u-6u'-18u+9u)e^{3x}=u''e^{3x},

so the ODE reduces to u′′=x2u''=x^2. Integrating twice, u=x412+c1x+c2u=\dfrac{x^4}{12}+c_1x+c_2, and the c1xe3xc_1xe^{3x} and c2e3xc_2e^{3x} pieces are exactly yHy_H. Hence C=112C=\dfrac{1}{12}, D=E=0D=E=0, and

yP=x412e3x.y_P=\frac{x^4}{12}e^{3x}.

Example. Solve the ODE

y′′+4y=sin⁡2x.y''+4y=\sin2x.

The characteristic equation λ2+4=0\lambda^2+4=0 has roots ±2i\pm2i, so

yH=Acos⁡2x+Bsin⁡2x.y_H=A\cos2x+B\sin2x.

The naive guess acos⁡2x+bsin⁡2xa\cos2x+b\sin2x collides with yHy_H completely, so we try

yP=axcos⁡2x+bxsin⁡2x.y_P=ax\cos2x+bx\sin2x.

Differentiating twice,

yP′=acos⁡2x−2axsin⁡2x+bsin⁡2x+2bxcos⁡2x,yP′′=−4asin⁡2x+4bcos⁡2x−4axcos⁡2x−4bxsin⁡2x,\begin{align*} y_P' &= a\cos2x-2ax\sin2x+b\sin2x+2bx\cos2x, \\ y_P'' &= -4a\sin2x+4b\cos2x-4ax\cos2x-4bx\sin2x, \end{align*}

so substituting (the xx-terms cancel against 4yP4y_P),

yP′′+4yP=−4asin⁡2x+4bcos⁡2x=sin⁡2x.\begin{align*} y_P''+4y_P &= -4a\sin2x+4b\cos2x \\ &= \sin2x. \end{align*}

Hence a=−14a=-\dfrac{1}{4} and b=0b=0, and the general solution is

y=Acos⁡2x+Bsin⁡2x−x4cos⁡2x,y=A\cos2x+B\sin2x-\frac{x}{4}\cos2x,

where A,B∈RA,B\in\mathbb{R}. Notice the xcos⁡2xx\cos2x term: the forcing frequency matches the natural frequency of the system, so the oscillations grow linearly without bound. This is resonance, which we study properly in the next subsection.

Example. Solve the IVP

y′′−5y′+4y=2e2x,y(0)=1,y′(0)=3.y''-5y'+4y=2e^{2x}, \qquad y(0)=1, \quad y'(0)=3.

The characteristic equation λ2−5λ+4=(λ−1)(λ−4)=0\lambda^2-5\lambda+4=(\lambda-1)(\lambda-4)=0 gives λ=1,4\lambda=1,4, so

yH=Aex+Be4x.y_H=Ae^x+Be^{4x}.

Since e2xe^{2x} is not a homogeneous solution, try yP=ae2xy_P=ae^{2x}:

4ae2x−10ae2x+4ae2x=2e2x−2a=2a=−1,\begin{align*} 4ae^{2x}-10ae^{2x}+4ae^{2x} &= 2e^{2x} \\ -2a &= 2 \\ a &= -1, \end{align*}

so yP=−e2xy_P=-e^{2x} and the general solution is y=Aex+Be4x−e2xy=Ae^x+Be^{4x}-e^{2x}.
Impose the initial conditions on the full general solution y=yH+yPy=y_H+y_P; imposing them on yHy_H alone and adding yPy_P afterwards gives the wrong constants. Now y′=Aex+4Be4x−2e2xy'=Ae^x+4Be^{4x}-2e^{2x}, so the conditions give

{A+B−1=1A+4B−2=3,\begin{cases} A+B-1=1 \\ A+4B-2=3, \end{cases}

i.e. A+B=2A+B=2 and A+4B=5A+4B=5. Subtracting, 3B=33B=3, so B=1B=1 and A=1A=1. Therefore the solution to the IVP is

y=ex+e4x−e2x.y=e^x+e^{4x}-e^{2x}.

An application: vibrations and resonance#

Many structures have a natural frequency of vibration. If an external agent forces them to vibrate at or near this frequency, large oscillations build up and resonance occurs; this can collapse bridges, and it is the 'trick' singers use to shatter wine glasses.

Example. A spring is mounted to a fixed point PP with an object of mass mm suspended from it. Let xx denote the vertical displacement from the equilibrium position (positive above it). Newton's second law and Hooke's law give

d2xdt2+ω2x=0,\frac{d^2x}{dt^2}+\omega^2x=0,

where ω>0\omega>0 depends only on the mass and the stiffness of the spring. The object is pulled down 4 units from equilibrium and released from rest; find x(t)x(t) for t≥0t\geq0.
The initial conditions are x(0)=−4x(0)=-4 and x′(0)=0x'(0)=0. The characteristic equation λ2+ω2=0\lambda^2+\omega^2=0 has roots ±ωi\pm\omega i (so α=0\alpha=0, β=ω\beta=\omega), and by the three-case theorem,

x(t)=Acos⁡ωt+Bsin⁡ωt.x(t)=A\cos\omega t+B\sin\omega t.

Differentiating,

x′(t)=−Aωsin⁡ωt+Bωcos⁡ωt.x'(t)=-A\omega\sin\omega t+B\omega\cos\omega t.

Now x′(0)=0x'(0)=0 gives Bω=0B\omega=0, so B=0B=0 (since ω>0\omega>0), and x(0)=−4x(0)=-4 gives A=−4A=-4. Therefore

x(t)=−4cos⁡ωt.x(t)=-4\cos\omega t.

The object oscillates between ±4\pm4 forever with period 2πω\dfrac{2\pi}{\omega}; this is simple harmonic motion.

Example. Same scenario, except the point PP now vibrates up and down with vertical displacement y=2sin⁡Ωty=2\sin\Omega t; a simple physical argument then gives

d2xdt2+ω2x=2sin⁡Ωt.\frac{d^2x}{dt^2}+\omega^2x=2\sin\Omega t.

Describe the motion, given x(0)=−4x(0)=-4 and x′(0)=0x'(0)=0.
We already have xH=Acos⁡ωt+Bsin⁡ωtx_H=A\cos\omega t+B\sin\omega t; the behaviour of xPx_P splits into two cases depending on whether the forcing frequency matches the natural frequency.

Case 1: Ω≠ω\Omega\neq\omega. Try xP=Ccos⁡Ωt+Dsin⁡Ωtx_P=C\cos\Omega t+D\sin\Omega t. Since xP′′=−Ω2xPx_P''=-\Omega^2x_P,

xP′′+ω2xP=(ω2−Ω2)(Ccos⁡Ωt+Dsin⁡Ωt)=2sin⁡Ωt,\begin{align*} x_P''+\omega^2x_P &= (\omega^2-\Omega^2)(C\cos\Omega t+D\sin\Omega t) \\ &= 2\sin\Omega t, \end{align*}

so C=0C=0 and D=2ω2−Ω2D=\dfrac{2}{\omega^2-\Omega^2}. Then x=xH+xPx=x_H+x_P, and imposing x(0)=−4x(0)=-4 gives A=−4A=-4, while x′(0)=Bω+2Ωω2−Ω2=0x'(0)=B\omega+\dfrac{2\Omega}{\omega^2-\Omega^2}=0 gives B=−2Ωω(ω2−Ω2)B=-\dfrac{2\Omega}{\omega(\omega^2-\Omega^2)}. Hence

x(t)=−4cos⁡ωt−Ωω⋅2ω2−Ω2sin⁡ωt+2ω2−Ω2sin⁡Ωt.x(t)=-4\cos\omega t-\frac{\Omega}{\omega}\cdot\frac{2}{\omega^2-\Omega^2}\sin\omega t+\frac{2}{\omega^2-\Omega^2}\sin\Omega t.

This is just another stable, bounded oscillation.

Case 2: Ω=ω\Omega=\omega. The guess from Case 1 now collides with xHx_H, so multiply by tt: try xP=Ctcos⁡ωt+Dtsin⁡ωtx_P=Ct\cos\omega t+Dt\sin\omega t. Substituting (the tt-terms cancel just like in the y′′+4y=sin⁡2xy''+4y=\sin2x example),

xP′′+ω2xP=−2Cωsin⁡ωt+2Dωcos⁡ωt=2sin⁡ωt,x_P''+\omega^2x_P=-2C\omega\sin\omega t+2D\omega\cos\omega t=2\sin\omega t,

so D=0D=0 and C=−1ωC=-\dfrac{1}{\omega}, giving xP=−tωcos⁡ωtx_P=-\dfrac{t}{\omega}\cos\omega t. Imposing the initial conditions on x=xH+xPx=x_H+x_P: x(0)=A=−4x(0)=A=-4, and

x′(t)=−Aωsin⁡ωt+Bωcos⁡ωt−1ωcos⁡ωt+tsin⁡ωt,x'(t)=-A\omega\sin\omega t+B\omega\cos\omega t-\frac{1}{\omega}\cos\omega t+t\sin\omega t,

so x′(0)=Bω−1ω=0x'(0)=B\omega-\dfrac{1}{\omega}=0 gives B=1ω2B=\dfrac{1}{\omega^2}. Hence

x(t)=−4cos⁡ωt+1ω2sin⁡ωt−tωcos⁡ωt.x(t)=-4\cos\omega t+\frac{1}{\omega^2}\sin\omega t-\frac{t}{\omega}\cos\omega t.

As tt increases, the amplitude of the tωcos⁡ωt\dfrac{t}{\omega}\cos\omega t term grows without bound and the system becomes unstable; this is resonance. Basically: force a system at its own natural frequency and every push arrives at exactly the right moment, so energy keeps accumulating.

A connection with linear algebra#

Two claims made earlier are still unproved: (A) a second order homogeneous ODE has at most two linearly independent solutions, and (B) every solution to the non-homogeneous equation has the form yH+yPy_H+y_P. Claim (A) is proved in MATH2501; claim (B) we can prove now using linear algebra (Chapter 7 of the algebra notes).

Consider y′′+ay′+by=fy''+ay'+by=f, let VV be the vector space of all infinitely differentiable functions y:R→Ry:\mathbb{R}\to\mathbb{R}, and define the linear transformation T:V→VT:V\to V by

T(y)=y′′+ay′+by.T(y)=y''+ay'+by.

Observe that

yH solves the homogeneous equation  ⟺  T(yH)=0  ⟺  yH∈ker⁡(T).y_H \text{ solves the homogeneous equation} \iff T(y_H)=0 \iff y_H\in\ker(T).

So the general solution to the homogeneous equation is exactly the kernel of TT — a subspace of VV. This is why the superposition Lemma from earlier works: kernels are closed under linear combinations, so of course Ay1+By2Ay_1+By_2 is again a solution. Similarly,

yP is a particular solution  ⟺  T(yP)=f,y_P \text{ is a particular solution} \iff T(y_P)=f,

so the non-homogeneous ODE has a solution if and only if f∈im(T)f\in\text{im}(T); and T(yH+yP)=T(yH)+T(yP)=0+f=fT(y_H+y_P)=T(y_H)+T(y_P)=0+f=f confirms yH+yPy_H+y_P is always a solution.

Proof. (of claim (B)). Suppose yy is any solution and yPy_P is some particular solution, so T(y)=fT(y)=f and T(yP)=fT(y_P)=f. Then

T(y−yP)=T(y)−T(yP)(by linearity of T)=f−f=0,\begin{align*} T(y-y_P) &= T(y)-T(y_P) \quad (\text{by linearity of } T) \\ &= f-f \\ &= 0, \end{align*}

so y−yP∈ker⁡(T)y-y_P\in\ker(T). But every function in the kernel is a homogeneous solution, so y−yP=yHy-y_P=y_H for some yHy_H, i.e. y=yH+yPy=y_H+y_P. ■\blacksquare

Basically, the solution set of the non-homogeneous equation is the shifted kernel yP+ker⁡(T)y_P+\ker(T); this is the same picture as the solution set of Ax=bA\mathbf{x}=\mathbf{b} being one particular solution plus the kernel of AA.