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) for the population at time t, this becomes
dtdP=kP,
where k 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:
dt2d2x=−k2x (displacement of a particle undergoing simple harmonic motion);
dtdT=k(T−20) (temperature of an object sitting in a room at 20 degrees);
dtdy−0.08y=0.05(60000+1000t) (value of an investment over time).
The whole point of this chapter is: given a differential equation for an unknown function, find an explicit formula (or formulae) for that function.
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,
dx3d3y+sinxdxdy=3x2y
is an ODE of order 3 (independent variable x, with y a function of x), while
(dt2d2x)3/2+dtdx−tx=0
is an ODE of order 2. Notice how the 3/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
dx2d2y+4xdxdy=ex,f′′(x)+4xf′(x)=ex,y′′+4xy′=ex
all represent the same ODE.
Note
Definition
A solution to an nth order ordinary differential equation is a function which is n-times differentiable and satisfies the given equation.
Example. Consider the ODE
dxdy=x2+5.
Then y(x)=3x3+5x is a solution (differentiate it and you get back x2+5). But so is y(x)=3x3+5x+6, and y(x)=3x3+5x−45; each of these is called a particular solution. Every solution to this ODE can be written in the form
y(x)=3x3+5x+C,
where C∈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, y could be written explicitly as a function of x, giving an explicit solution. This cannot always be done; sometimes we must settle for an implicit solution, where y is only defined implicitly by some equation.
Example. Show that y, given implicitly by the equation
y2=cos(x2+y2),
is a particular solution to the ODE
2xsin(x2+y2)+(2ysin(x2+y2)+2y)dxdy=0.
To verify that y solves the ODE, we first need dxdy. Implicitly differentiating both sides with respect to x (using the chain rule on the right),
which is exactly the ODE. Hence the ODE is satisfied and y 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.
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 nth order ODE together with a set of values of the solution and its first (n−1) derivatives at some fixed point x0. 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 nth order ODE needs n conditions since the general solution has n arbitrary constants.
Example. Solve the IVP
dx2d2y=6x,y′(0)=2,y(0)=−1.
Integrating the ODE once,
dxdy=3x2+C,
where C∈R. Imposing y′(0)=2 gives C=2. Integrating again,
y=x3+2x+D,
where D∈R. Imposing y(0)=−1 gives D=−1. Therefore the solution to the IVP is
y=x3+2x−1,
which is valid for all x∈R.
Not every IVP is this friendly. In general, three questions arise:
Does the IVP have a solution at all?
Is the solution unique?
If the initial values are given at a point a, how far on either side of a does the solution extend?
The next two examples show that even 'simple' looking IVPs can misbehave.
Example. Solve the IVP
dxdy=y,y(0)=0.
Assuming y=0, we can separate:
y1dy2y=dx=x+C.
The initial condition gives C=0, and rearranging,
y(x)=4x2.
However, notice that the constant function y(x)=0 is also a solution to the IVP (both sides are 0). Hence this IVP does not have a unique solution.
Example. Solve the IVP
dxdy=x1,y(1)=2.
How far does the solution extend on either side of the point 1?
The ODE says dxdy does not exist at 0, so the solution cannot cross 0. On the interval (0,∞) the general solution is y(x)=lnx+C, and y(1)=2 gives C=2. Hence
y(x)=lnx+2,x>0.
So the solution only extends over (0,∞); you could patch on ln∣x∣+D for x<0, but for practical applications the break in the domain at 0 means we would not use it there.
A separable ODE is one where the two variables (say x and y) can be separated, so that all the y's end up on one side of the equation and all the x's on the other. In general, a separable ODE is one that can be written in the form
dxdy=h(y)g(x).
To solve it, write
h(y)dy=g(x)dx,
integrate both sides to obtain an implicit solution H(y)=G(x)+C, and then (whenever possible) isolate y to get the explicit solution. If initial conditions are given, use them to determine C.
The fact that this symbolic manipulation with dy and dx 'works' traces back to the chain rule: h(y)dxdy=g(x), and integrating both sides with respect to x turns ∫h(y)dxdydx into ∫h(y)dy. Do not assume you can manipulate the symbols dy and dx in other creative ways and still get valid results.
Example. Solve the initial value problem
dxdy=y2(1+x2),y(0)=1.
Separating the variables and integrating,
y21dy∫y21dy−y1=(1+x2)dx=∫(1+x2)dx=x+3x3+C,
where C∈R; this is the implicit solution. Imposing y(0)=1,
where C∈R. In this case it is best to leave the solution in implicit form, since 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∘C. The object is initially too hot for the thermometer to measure, but after 6 minutes its temperature is 80∘C, and after 8 minutes it is 50∘C. What was the original temperature?
(a) Suppose T is the temperature of the object at time t, A is the ambient (room) temperature and k is the constant of proportionality. Then
A first order linear ODE can be written in the form
dxdy+f(x)y=g(x),
where f and g are given functions of the single variable x. The ODE is called linear because there are no non-linear terms (like y2, siny or y′) involving y or y′; note that f and g are allowed to be as ugly as they like in x.
The method for solving these is very slick:
Write the ODE in the standard form above.
Calculate h(x)=e∫f(x)dx (ignoring the constant of integration). This is called the integrating factor.
Multiply the ODE through by h(x):
h(x)dxdy+h(x)f(x)y=g(x)h(x).
By the product rule, the left-hand side always collapses to
dxd(h(x)y)=g(x)h(x).
Integrate both sides and rearrange for y. 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)y; this works because 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 dxdy+3y=e−x.
The ODE is already in standard form with f(x)=3, so the integrating factor is
h(x)=e∫3dx=e3x.
Multiplying through by e3x and contracting the left-hand side,
where C∈R. Therefore the general solution is y=21e−x+Ce−3x; notice how forgetting the +C would have lost the entire Ce−3x family.
Example. Solve the IVP
(x−1)3dxdy+4(x−1)2y=x+1,y(0)=2.
First rewrite in standard form by dividing by (x−1)3:
dxdy+x−14y=(x−1)3x+1.
The integrating factor is
h(x)=e∫x−14dx=e4ln(x−1)=eln(x−1)4=(x−1)4.
It is important to simplify h(x) like this before continuing; leaving it as e4ln(x−1) makes the next steps unusable.
Multiplying the standard form by (x−1)4,
Note the solution is valid on (−∞,1) or (1,∞) but never at x=1; in fact no real-valued solution of the original ODE can have 1 in its domain.
Example. An investor has a salary of $60,000 per year, expected to increase at $1000 per annum. An initial deposit of $1000 is invested in a program paying 8% per annum, and the investor deposits 5% of their salary each year. Find the amount invested after t years (assuming interest and deposits are calculated continuously).
Let y(t) denote the dollars invested after t years. Then
dtdy=0.08y+0.05(60000+1000t),
i.e. (rate of increase of investment) = (8% of investment) + (5% of salary). In standard form,
dtdy−0.08y=3000+50t,
which is first order linear with integrating factor h(t)=e∫−0.08dt=e−0.08t. Hence
dtd(e−0.08ty)=(3000+50t)e−0.08t.
Integrating the right-hand side by parts, with u=3000+50t and v′=e−0.08t (so v=−12.5e−0.08t),
So e−0.08ty=−(625t+45312.5)e−0.08t+C, and dividing through,
y(t)=−625t−45312.5+Ce0.08t.
Imposing y(0)=1000 gives C=46312.5, hence
y(t)=46312.5e0.08t−625t−45312.5.
Therefore after 10 years, the investment totals y(10)≈$51507.86.
Example. Some ODEs are both separable and linear; solve dxdy+2y=4 both ways and check the answers agree. Method 1 (separable). Write dxdy=4−2y and separate:
Both methods produce the same family y=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).
Here is another approach to solving (some) first order ODEs. Suppose H is a function of two variables x and y satisfying
H(x,y)=C,
where C is a real constant. If we consider y as a function of x and differentiate both sides with respect to x, then the chain rule from Chapter 1 gives
∂x∂H+∂y∂Hdxdy=0.
Denoting ∂x∂H and ∂y∂H by F and G respectively, we obtain the differential equation
F(x,y)+G(x,y)dxdy=0.
Conversely, if we want to solve an ODE of this form and there happens to exist an H with F=∂x∂H and G=∂y∂H, then the solution is simply H(x,y)=C. The difficulty is that this condition on F and G is not easy to verify directly. Fortunately, the mixed derivative theorem says that for a 'nice' H,
∂y∂x∂2H=∂x∂y∂2H,i.e.∂y∂F=∂x∂G,
and this second condition is easy to check.
Note
Definition
An ordinary differential equation of the form
F(x,y)+G(x,y)dxdy=0
is called exact if
∂y∂F=∂x∂G.
Note
Theorem Suppose that an ordinary differential equation of the above form is exact. Then its solution is given by H(x,y)=C, where C is a constant and H is a function satisfying
∂x∂H=Fand∂y∂H=G.
Basically: an exact ODE is one whose left-hand side is secretly the total derivative of some two-variable function H, and the exactness test (equality of the mixed partials) is how you detect this without knowing H. Note the ODE can equivalently be written as dxdy=−G(x,y)F(x,y) or as F(x,y)dx+G(x,y)dy=0.
Example. Show that the differential equation
dxdy=−2y+x+12x+y+1
is exact, and hence find its solution.
First rewrite the ODE as
(2x+y+1)+(2y+x+1)dxdy=0,
and write F=2x+y+1 and G=2y+x+1. Then
∂y∂F=1=∂x∂G,
so the ODE is exact. Hence there is a function H with ∂x∂H=F and ∂y∂H=G. Integrating F with respect to x (treating y as a constant), and integrating G with respect to y (treating x as a constant),
H(x,y)H(x,y)=x2+xy+x+C1(y),=y2+xy+y+C2(x),
where the 'constants of integration' C1(y) and C2(x) are functions of y and x respectively. Comparing the two expressions,
H(x,y)=x2+xy+y2+x+y,
and so the solution to the ODE is
x2+xy+y2+x+y=C,
where C∈R. (Technically H should carry its own arbitrary constant +K, but it just merges into C on the right-hand side, so it is customary to ignore it.) Since this is a quadratic in y you could use the quadratic formula to write y explicitly, but the answer is much cleaner left in implicit form.
Example. Solve the differential equation
2xsin(x2+y2)+(2ysin(x2+y2)+2y)dxdy=0.
Write F(x,y)=2xsin(x2+y2) and G(x,y)=2ysin(x2+y2)+2y. Then
∂y∂F=4xycos(x2+y2)=∂x∂G,
so the equation is exact. This time we use a slightly different approach to find H. Integrating F with respect to x,
H(x,y)=−cos(x2+y2)+C1(y).
To determine C1(y), differentiate this with respect to y and compare with G:
∂y∂H=2ysin(x2+y2)+C1′(y)=2ysin(x2+y2)+2y,
so C1′(y)=2y, whence C1(y)=y2. Hence H(x,y)=−cos(x2+y2)+y2 and the solution is
y2−cos(x2+y2)=C,
where C∈R. Notice how taking C=0 recovers y2=cos(x2+y2), which is exactly the particular solution we verified back in Section 3.1; and here it is not possible to make y explicit at all.
Example. Solve the differential equation
(ex−siny)dx+cosydy=0.
Write F(x,y)=ex−siny and G(x,y)=cosy. Since
∂y∂F=−cosybut∂x∂G=0,
the ODE is not exact. What happens if we barge ahead with the method regardless? Integrating F with respect to x gives H(x,y)=ex−xsiny+C1(y), and then
∂y∂H=−xcosy+C1′(y)=cosy
forces C1′(y)=(1+x)cosy, which contradicts C1(y) being independent of x; no such H exists.
Fortunately, not all is lost. Multiplying the whole ODE by e−x gives
(1−e−xsiny)dx+e−xcosydy=0,
and since e−x is never zero, this has the same solutions as the original. Checking the exactness test again with F=1−e−xsiny and G=e−xcosy,
∂y∂F=−e−xcosy=∂x∂G,
so the new equation is exact. Integrating F with respect to x,
H(x,y)=x+e−xsiny+C1(y),
and comparing ∂y∂H=e−xcosy+C1′(y) with G shows C1′(y)=0. Therefore the solution is
x+e−xsiny=C,
where C∈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) dxdy=xy2
(b) xdxdy+2y=x3, for x>0
(c) (2xy+1)+(x2+2y)dxdy=0
(d) dxdy=ex+y
(a) The right-hand side factors as (function of x)×(function of y), so this is separable (it is not linear because of the y2):
y21dy−y1y=xdx=2x2+C=x2+C1−2,
where C1=2C. (The constant function y=0 is also a solution; separation quietly divided it away.)
(b) Dividing by x gives dxdy+x2y=x2, which is the linear standard form (it is not separable since the x2 term stops the right side from factorising). The integrating factor is h(x)=e∫x2dx=e2lnx=x2, so
dxd(x2y)x2yy=x4=5x5+C=5x3+x2C.
(c) This is in the form F+Gdxdy=0 with F=2xy+1 and G=x2+2y; checking the exactness test, ∂y∂F=2x=∂x∂G, so it is exact. Integrating F with respect to x gives H=x2y+x+C1(y), and comparing ∂y∂H=x2+C1′(y) with G gives C1′(y)=2y, so C1(y)=y2. The solution is
x2y+x+y2=C.
(d) This looks like none of the types, but since ex+y=exey it is separable in disguise:
e−ydy−e−yy=exdx=ex+C=−ln(C1−ex),
where C1=−C (and we need ex<C1 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+Gy′=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) to solve
dxdy=x2xy−y2.
By the product rule, dxdy=v+xdxdv. Substituting (and using y=xv on the right),
using the substitution z=1/y.
The y2 term means this is not linear in y, but it will turn out linear in z. Differentiating y=z1 with respect to t gives dtdy=−z21dtdz, so the ODE becomes
−z21dtdz+z2+z2t2e2tdtdz−2zdtd(e−2tz)e−2tzz=0=t2e2t(multiplying through by −z2)=t2(integrating factor e−2t)=3t3+C0=e2t(3t3+C0).
Since y=1/z, the solution is
y=e2t(t3+C)3,
where C=3C0∈R. Notice how the substitution converted a nonlinear ODE in y into a first order linear ODE in z.
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
describe accurately the data you have,
decide exactly what information you want out of the model,
decide which variables are dependent and which are independent, and
describe how the dependent variables change as the independent ones vary (this is usually where the differential equation appears).
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 t 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) denote the volume of vermouth (in cc) at time t; we know V(0)=0. The key modelling equation for any mixing problem is
dtdV=(rate of inflow)−(rate of outflow).
The inflow of vermouth is 6 cc/sec. For the outflow, the total volume of liquid at time t is
40+2t+6t−4t=40+4t,
so the proportion (by volume) of vermouth in the container is 40+4tV(t), and since liquid leaves at 4 cc/sec, vermouth leaves at 40+4t4V(t)=10+tV(t) cc/sec. Hence we obtain the IVP
dtdV=6−10+tV,V(0)=0.
This is first order linear with integrating factor
h(t)=e∫10+t1dt=eln(10+t)=10+t,
so
dtd((10+t)V)(10+t)V=6(10+t)=60t+3t2+C.
Imposing V(0)=0 gives C=0, hence
V(t)=10+t3t2+60t.
(b) Two parts gin to three parts vermouth means three-fifths of the liquid is vermouth, so we require
where we took the positive root of the quadratic. Therefore James should insert the glass about 12.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) be the mass of salt (in grams) after t minutes; x(0)=0. The volume is not constant here: it gains 3−1=2 litres per minute, so the volume at time t is 50+2t litres. Salt flows in at 2×3=6 g/min and flows out at (concentration)×(outflow rate) =50+2tx×1 g/min. Hence
dtdx=6−50+2tx,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 t.
The ODE is linear with integrating factor
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 r:
dtdP=rP,P(0)=P0.
This is separable:
∫P1dPlnPP(t)=∫rdt=rt+C=P0ert.
(This model goes back to Thomas Malthus, 1798.) For Mathopolis, P0=3,000,000 and r=0.02, so P(t)=3000000e0.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 Pc which, when exceeded, causes the population to decrease; below it the population increases. Try
dtdP=k(Pc−P),P(0)=P0,
where k>0 (so dtdP>0 when P<Pc and dtdP<0 when P>Pc). Separating (in the case P<Pc),
where imposing P(0)=P0 gave A=Pc−P0 (the case P>Pc gives exactly the same formula). Note that P(t)→Pc as t→∞.
For Mathopolis, take Pc=7,000,000 (the maximum sustainable size). Since dtdP=0.02P0=60000 at t=0,
60000=k(7000000−3000000),
so k=0.015 and
P(t)=7000000−4000000e−0.015t.
Criticism: if P is close to 0 then dtdP≈kPc, so the model says tiny populations grow fastest, which is silly.
Example. (Model 3: the logistic model.) To fix the small-population problem, try
dtdP=kP(Pc−P),P(0)=P0,
where k>0; now dtdP is small when P is small (Verhulst, 1838). Separating and using partial fractions on the left,
and substituting in A then multiplying top and bottom by (Pc−P0)e−kPct,
P(t)=P0+(Pc−P0)e−kPctPcP0.
Once again P(t)→Pc as t→∞. The resulting S-shaped curve is called a logistic curve: growth is approximately exponential at the start, then slows and approaches Pc asymptotically.
For Mathopolis, 60000=kP0(Pc−P0)=k×3000000×4000000 gives k=5×10−9, so kPc=0.035 and
P(t)=3+4e−0.035t21000000.
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 (Pc 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
dx2d2y+adxdy+by=f(x),
where a and b are real numbers. These arise naturally in wave mechanics and predator-prey models; you have already seen dt2d2x+n2x=0 used to model simple harmonic motion.
We first look at the case when f(x)≡0 (i.e. f(x)=0 for all x).
Note
Definition
A second order linear ODE with constant coefficients is said to be homogeneous if it is of the form
dx2d2y+adxdy+by=0,
where a and b are real numbers.
It turns out we can always solve these. The first key observation:
Note
Lemma If y1 and y2 are two solutions to the homogeneous equation, then any linear combination Ay1+By2, where A and B are real numbers, is also a solution.
Proof. Let y=Ay1+By2. 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.■
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,y2, and then y=Ay1+By2 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λx (with λ constant), then y′=λeλx and y′′=λ2eλx, so substituting,
λ2eλx+aλeλx+beλxλ2+aλ+b=0=0(dividing by eλx=0).
Hence y=eλx is a solution if and only if λ is a root of this quadratic.
Note
Definition
The characteristic equation of the second order linear ODE dx2d2y+adxdy+by=0 is given by
λ2+aλ+b=0.
Example. Solve dx2d2y−5dxdy+6y=0.
The characteristic equation is
λ2−5λ+6(λ−2)(λ−3)=0=0,
so λ=2,3. Hence y1=e2x and y2=e3x are solutions, and since they are linearly independent, the general solution is
y=Ae2x+Be3x,
where A,B∈R.
In that example the characteristic equation had two distinct real roots. Since a and b 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, the second independent solution is y2=xeλ1x. To verify this, note a repeated root satisfies both λ12+aλ1+b=0 and 2λ1+a=0 (the vertex of the parabola); with y=xeλ1x, y′=eλ1x(1+λ1x) and y′′=eλ1x(2λ1+λ12x), so
y′′+ay′+by=eλ1x((2λ1+a)+x(λ12+aλ1+b))=0,
since both brackets vanish.
For complex roots α±βi (with β=0), the two exponential solutions are complex-valued, but we can extract real solutions using Euler's formula eiθ=cosθ+isinθ:
where A=C+D and B=i(C−D); choosing C and D to be complex conjugates of each other makes A and B real. We summarise all three cases:
Note
Theorem Consider the homogeneous ODE y′′+ay′+by=0 and let λ1 and λ2 denote the roots of the characteristic equation λ2+aλ+b=0. (i) If λ1 and λ2 are different real numbers, then the general solution is
y=Aeλ1x+Beλ2x,A,B∈R.
(ii) If λ1=λ2, then the general solution is
y=Aeλ1x+Bxeλ1x,A,B∈R.
(iii) If λ1=α+βi and λ2=α−βi, where α,β∈R and β=0, then the general solution is
y=eαx(Acos(βx)+Bsin(βx)),A,B∈R.
Example. Solve the following differential equations:
(a) y′′−6y′+25y=0,
(b) y′′+4y′+4y=0, with initial conditions y(0)=1 and y′(0)=0.
(a) The characteristic equation λ2−6λ+25=0 has roots
λ=26±36−100=3±4i,
so by case (iii) the general solution is
y=e3x(Acos4x+Bsin4x),
where A,B∈R.
(b) The characteristic equation factorises as (λ+2)2=0, so −2 is a repeated root and
y=Ae−2x+Bxe−2x.
Differentiating (for the second initial condition),
y′=−2Ae−2x+Be−2x−2Bxe−2x.
Now y(0)=1 gives A=1, and y′(0)=0 gives −2A+B=0, so B=2. Therefore the solution to the IVP is
Now suppose f is not identically zero. The main idea is illustrated by an example.
Example. Solve the equation
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+b. Then yP′=a and yP′′=0, and substituting,
0−5a+6(ax+b)6ax+(6b−5a)=12x−4=12x−4.
Equating coefficients: 6a=12 gives a=2, and then 6b−10=−4 gives b=1. Hence yP=2x+1.
Are there other solutions? Yes. The associated homogeneous equation y′′−5y′+6y=0 has solution yH=Ae2x+Be3x (from the earlier example), and y=yH+yP 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.
Therefore the general solution is
y=Ae2x+Be3x+2x+1,
where A,B∈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):
Find the solution yH to the corresponding homogeneous equation (via the characteristic equation).
Find a particular solution yP (by guessing its form and determining the unknown coefficients — the method of undetermined coefficients).
The general solution is
y=yH+yP.
Always perform Step 1 before Step 2; without knowing yH you cannot tell whether your guess for yP secretly solves the homogeneous equation (the reason will become obvious shortly).
Example. Solve the ODE
y′′−4y′+5y=20e−x.
First, the characteristic equation λ2−4λ+5=0 has roots 2±i, so
yH=e2x(Acosx+Bsinx).
Second, since the right-hand side is an exponential, try yP=ae−x; then yP′=−ae−x and yP′′=ae−x, so substituting,
ae−x+4ae−x+5ae−x10aa=20e−x=20=2.
Therefore the general solution is
y=e2x(Acosx+Bsinx)+2e−x,
where A,B∈R.
Given a forcing term f, the correct form to guess for yP is:
f(x)
Guess for particular solution yP
P(x) (polynomial of degree n)
Q(x) (polynomial of degree n)
P(x)esx
Q(x)esx
P(x)cos(sx) or P(x)sin(sx)
Q1(x)cos(sx)+Q2(x)sin(sx)
P(x)esxcos(tx) or P(x)esxsin(tx)
Q1(x)esxcos(tx)+Q2(x)esxsin(tx)
If any term of the guess for yP is a solution to the homogeneous ODE, then multiply the guess by x; if any term of the new guess is still a solution to the homogeneous ODE, multiply by x again.
Example. Solve the ODE
y′′−3y′+2y=5e2x.
The characteristic equation λ2−3λ+2=0 has roots λ=1,2, so
yH=Ae2x+Bex.
Since the right-hand side is a multiple of e2x, the natural guess is yP=ae2x — but this is a homogeneous solution (set A=a, B=0 in yH), so substituting it produces 0 on the left-hand side and the guess fails. Following the rule, multiply by x and try yP=axe2x instead. Then
The characteristic equation factorises as (λ−3)2=0, giving the repeated root 3, so
yH=Ae3x+Bxe3x.
The first guess yP=ae3x solves the homogeneous equation; multiplying by x gives axe3x, which also solves it (set A=0, B=a). So multiply by x once more: yP=ax2e3x, which is finally not a homogeneous solution. Then
Example. Write down the form of a particular solution to
dt2d2y−6dtdy+13y=5e3tcos(2t)
(without evaluating the coefficients).
The characteristic equation λ2−6λ+13=0 has roots
λ=26±36−52=3±2i,
so yH=e3t(Acos2t+Bsin2t). The table suggests the guess yP=ae3tcos2t+be3tsin2t — but every term of this solves the homogeneous equation. Multiplying by t,
yP=ate3tcos2t+bte3tsin2t,
which no longer lies in the homogeneous solution space; this is the form we seek. Notice how this collision was invisible until yH was computed — this is exactly why Step 1 comes first.
Example. Find a particular solution to
y′′−6y′+9y=x2e3x.
From before, yH=Ae3x+Bxe3x. The table suggests yP=(Cx2+Dx+E)e3x; now x2e3x itself is not a homogeneous solution, but the Dxe3x and Ee3xterms are, so the whole guess must be multiplied by x twice:
yP=(Cx4+Dx3+Ex2)e3x.
When the forcing term contains a polynomial, you must multiply the entire polynomial guess by x (or x2), not just the offending terms.
There is a slick way to find the coefficients here: writing y=ue3x, direct computation gives
y′′−6y′+9y=(u′′+6u′+9u−6u′−18u+9u)e3x=u′′e3x,
so the ODE reduces to u′′=x2. Integrating twice, u=12x4+c1x+c2, and the c1xe3x and c2e3x pieces are exactly yH. Hence C=121, D=E=0, and
yP=12x4e3x.
Example. Solve the ODE
y′′+4y=sin2x.
The characteristic equation λ2+4=0 has roots ±2i, so
yH=Acos2x+Bsin2x.
The naive guess acos2x+bsin2x collides with yH completely, so we try
so substituting (the x-terms cancel against 4yP),
yP′′+4yP=−4asin2x+4bcos2x=sin2x.
Hence a=−41 and b=0, and the general solution is
y=Acos2x+Bsin2x−4xcos2x,
where A,B∈R. Notice the xcos2x 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.
The characteristic equation λ2−5λ+4=(λ−1)(λ−4)=0 gives λ=1,4, so
yH=Aex+Be4x.
Since e2x is not a homogeneous solution, try yP=ae2x:
4ae2x−10ae2x+4ae2x−2aa=2e2x=2=−1,
so yP=−e2x and the general solution is y=Aex+Be4x−e2x. Impose the initial conditions on the full general solution y=yH+yP; imposing them on yH alone and adding yP afterwards gives the wrong constants. Now y′=Aex+4Be4x−2e2x, so the conditions give
{A+B−1=1A+4B−2=3,
i.e. A+B=2 and A+4B=5. Subtracting, 3B=3, so B=1 and A=1. Therefore the solution to the IVP is
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 P with an object of mass m suspended from it. Let x denote the vertical displacement from the equilibrium position (positive above it). Newton's second law and Hooke's law give
dt2d2x+ω2x=0,
where ω>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) for t≥0.
The initial conditions are x(0)=−4 and x′(0)=0. The characteristic equation λ2+ω2=0 has roots ±ωi (so α=0, β=ω), and by the three-case theorem,
x(t)=Acosωt+Bsinωt.
Differentiating,
x′(t)=−Aωsinωt+Bωcosωt.
Now x′(0)=0 gives Bω=0, so B=0 (since ω>0), and x(0)=−4 gives A=−4. Therefore
x(t)=−4cosωt.
The object oscillates between ±4 forever with period ω2π; this is simple harmonic motion.
Example. Same scenario, except the point P now vibrates up and down with vertical displacement y=2sinΩt; a simple physical argument then gives
dt2d2x+ω2x=2sinΩt.
Describe the motion, given x(0)=−4 and x′(0)=0.
We already have xH=Acosωt+Bsinωt; the behaviour of xP splits into two cases depending on whether the forcing frequency matches the natural frequency.
Case 1: Ω=ω. Try xP=CcosΩt+DsinΩt. Since xP′′=−Ω2xP,
xP′′+ω2xP=(ω2−Ω2)(CcosΩt+DsinΩt)=2sinΩt,
so C=0 and D=ω2−Ω22. Then x=xH+xP, and imposing x(0)=−4 gives A=−4, while x′(0)=Bω+ω2−Ω22Ω=0 gives B=−ω(ω2−Ω2)2Ω. Hence
x(t)=−4cosωt−ωΩ⋅ω2−Ω22sinωt+ω2−Ω22sinΩt.
This is just another stable, bounded oscillation.
Case 2: Ω=ω. The guess from Case 1 now collides with xH, so multiply by t: try xP=Ctcosωt+Dtsinωt. Substituting (the t-terms cancel just like in the y′′+4y=sin2x example),
xP′′+ω2xP=−2Cωsinωt+2Dωcosωt=2sinωt,
so D=0 and C=−ω1, giving xP=−ωtcosωt. Imposing the initial conditions on x=xH+xP: x(0)=A=−4, and
x′(t)=−Aωsinωt+Bωcosωt−ω1cosωt+tsinωt,
so x′(0)=Bω−ω1=0 gives B=ω21. Hence
x(t)=−4cosωt+ω21sinωt−ωtcosωt.
As t increases, the amplitude of the ωtcosω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.
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+yP. 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=f, let V be the vector space of all infinitely differentiable functions y:R→R, and define the linear transformation T:V→V by
T(y)=y′′+ay′+by.
Observe that
yH solves the homogeneous equation⟺T(yH)=0⟺yH∈ker(T).
So the general solution to the homogeneous equation is exactly the kernel of T — a subspace of V. This is why the superposition Lemma from earlier works: kernels are closed under linear combinations, so of course Ay1+By2 is again a solution. Similarly,
yP is a particular solution⟺T(yP)=f,
so the non-homogeneous ODE has a solution if and only if f∈im(T); and T(yH+yP)=T(yH)+T(yP)=0+f=f confirms yH+yP is always a solution.
Proof. (of claim (B)). Suppose y is any solution and yP is some particular solution, so T(y)=f and T(yP)=f. Then
T(y−yP)=T(y)−T(yP)(by linearity of T)=f−f=0,
so y−yP∈ker(T). But every function in the kernel is a homogeneous solution, so y−yP=yH for some yH, i.e. y=yH+yP. ■
Basically, the solution set of the non-homogeneous equation is the shifted kernel yP+ker(T); this is the same picture as the solution set of Ax=b being one particular solution plus the kernel of A.