Simple second-order ordinary differential equations

(this worksheet is also available as a Microsoft Word document)

Many differential equations we find in nature are second order equations. In this help sheet we will demonstrate how the simplest form of the second-order differential can be solved, before outlining the standard procedure for solving such an equation.

It is easy to see why second-order differential equations appear in engineering and physics as the questions are often about how objects move when forces act. As force directly relates to acceleration and acceleration is the second derivative of displacement, a second-order differential equation is needed to relate force and position. It is surprising to find that these equations have properties which make them useful in a far wider range of disciplines.

As integration is the opposite of differentiation, it would seem reasonable that we would have to integrate twice to solve this sort of equation. Every time we integrate we must add in a constant of integration. Therefore we expect there to be two arbitrary constants in our general solution to the equation. Indeed, in many physical systems we find that once we have described how the object moves under the action of the forces we are still free to choose a starting position and velocity for the object.

However, as we shall see, we manage to form a solution without ever seeming to perform an integration. Despite this, it is still necessary to maintain two arbitrary constants in the general solution to allow us to solve for the initial or boundary conditions given[1].

Solving a second-order differential equation

The simplest second-order differential equation we come across is of the form:

\[a \frac{d^2y}{dx^2} + b \frac{dy}{dx} + cy = 0\]

where $a$, $b$ and $c$ are numbers. To solve this we start by assuming that the solution is $y = e^{mx}$. At this point this is just a guess but it will turn out to be a good one. Assuming the solution is of this form, we can substitute it into the above equation and find:

\[am^2e^{mx} + bme^{mx} + ce^{mx} = 0\]

where the $m^2$ and $m$ have appeared because every time we take a derivative of $e^{mx}$ we drop down a multiple of $m$. As every term is multiplied by $e^{mx}$ we can divide everywhere by $e^{mx}$, leaving us with:

\[am^2 + bm + c = 0\]

which is known as the auxiliary equation. In a question we would be given the values of $a$, $b$ and $c$ and we could attempt to solve this quadratic by factoring it. If we can't find a simple factorisation it is always possible to use the quadratic formula to solve for values of $m$:

\[m_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2a}\]

where $m_1$ is given by calculating the formula with a plus and $m_2$ is given by calculating with a minus. Once we have solved this quadratic we will find ourselves in one of three possible positions:

1) Distinct real roots

As long as $b^2-4ac$ is a positive number the auxiliary equation will yield two real numbers $m_1$ and $m_2$. We can multiply both of these solutions by an arbitrary constant and add them together, leading to a general solution:

\[y = Ae^{m_1x} + Be^{m_2x}.\]

If we have been supplied with boundary conditions we can solve for $A$ and $B$ to give a particular solution.

2) Repeated real roots

If $b^2-4ac$ is zero then $m_1$ will be the same as $m_2$, i.e. $m_1=m_2$, so we may as well drop the subscript and call the single solution to the auxiliary equation simply $m$. However, as this is a second-order problem we will have two boundary conditions, so we still require two constants in our solution. To make the two general solutions different we multiply one by $x$ and form a solution of the form:

\[y = (A+Bx)e^{mx}.\]

3) Imaginary roots

If $b^2-4ac$ is negative then the only way to solve the quadratic is with imaginary numbers. The two roots will be complex conjugates of each other, that is, both solutions have the same numbers in their real and imaginary parts but one will have a positive imaginary part and the other a minus:

\[m_1 = \alpha + i \beta,\qquad m_2 = \alpha - i\beta.\]

Here $\alpha$ and $\beta$ are just numbers once again; we have used Greek letters to avoid confusion with the $a$and $b$ used in the differential equation. This allows us to form the solution as:

\[y = e^{\alpha x} (A\cos(\beta x) + B\sin(\beta x)).\]

It is very important to notice that the real part $\alpha$ is used only in the exponential and the imaginary part $\beta$ is used only in the $\sin$ and $\cos$ parts. Also notice that we have dropped the plus and minus.

Steps for solving

We summarize the steps to solving a simple second-order equation below:

Starting from: \[ a\frac{d^2y}{dx^2} + b\frac{dy}{dx} + cy = 0 \]

Form the auxiliary equation: \[ am^2 + bm + c = 0 \]

Solve the auxiliary equation: \[ m_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2a}\]

Then form the solution according to the following possibilities:

Solutions to the auxiliary equation Form of general solution
Two real distinct roots $m_1, m_2$ $y = C_1e^{m_1x} + C_2e^{m_2x}$
Real repeated roots $m$ $y = (C_1 + C_2x)e^{mx}$
Complex roots $\alpha \pm i \beta$ $y = e^{\alpha x}(C_1 \cos(\beta x) + C_2 \sin(\beta x))$

Finally, solve for the constants $C_1$ and $C_2$ if you have been given initial conditions.

Interactive revision questions

Click here to try some interactive revision questions, with hints and worked solutions.

Worked examples:

Example 1

Find the general solution to the differential equation:

\[\frac{d^2y}{dx^2} - 2\frac{dy}{dx} - 3y = 0 \]

and also the particular solution given initial conditions $y(0) = 0$ and $y'(0) = 1$.

Solution

First we form the auxiliary equation:

\[m^2-2m-3 = 0\]

In this instance it is simple to see that this can be factorised with ease giving:

\[(m-3)(m+1) = 0\]

so we can read off the solutions $m_1 = 3$ and $m_2 = -1$. As we have two distinct real roots we can say that the general solution is simply:

\[y(x) = Ae^{3x} + Be^{-x}\]

As we have been given initial conditions we can also find the particular values of $A$ and $B$. The first initial condition tells us that $y = 0$ when $x = 0$; substituting these values into our general solution we get:

\[ 0 = Ae^{3 \cdot 0} + Be^0 = A + B = 0\]

(as $e^0 = 1$)

The second initial condition tell us that the differential of $y$ is $1$ when $x$ is $0$. The differential of the general solution is:

\[ y'(x) = 3Ae^{3x} - Be^{-x},\]

substituting in the initial conditions we get:

\[1 = 3A-B.\]

We can now solve these two equations simultaneously (see the simultaneous equation help sheet and videos) to find:

\[A = \frac{1}{4}, \qquad B = -\frac{1}{4}.\]

Thus the particular solution is:

\[y(x) = \frac{1}{4}e^{3x} - \frac{1}{4}e^{-x}.\]

Example 2

Find the general solution to the equation:

\[4y'' - 4y' + y = 0\]

and then find the particular solution that solves the boundary conditions $y(0) = 0$, $y(2) = e$.

Solution

First notice that the question has been given to us using dash notation; this question is the same as:

\[4\frac{d^2y}{dx} - 4\frac{dy}{dx} + y = 0. \]

Therefore we have the auxiliary equation:

\[ 4m^2 - 4m + 1 = 0,\]

which isn't obviously factorisable so we can use the quadratic formula:

\[ m_{1,2} = \frac{4 \pm \sqrt{(-4)^2 - 4 \cdot 4 \cdot 1}}{2 \cdot 4} \]

we can see that $(-4)^2 - 4 \cdot 4 \cdot 1 = 0$, therefore we only get one value for $m$ which is $m = \frac{1}{2}$. As we have a repeated root we can form the general solution:

\[ y(x) = (A+Bx)e^{\frac{x}{2}}. \]

Using the first boundary condition we find that:

\[ y(0) = (A + B \cdot 0) e^{\frac{0}{2}} = A = 0, \]

i.e. we have found that $A = 0$. From the second boundary condition we find:

\[ y(2) = 2Be^{\frac{2}{2}} = e. \]

Dividing both sides by $e$ we find:

\[ 2B = 1 \Rightarrow B = \frac{1}{2}. \]

Leaving us with the particular solution:

\[ y = \frac{1}{2}xe^{\frac{x}{2}}. \]

Example 3

Find the general solution to the equation:

\[ 2y'' + 6y' + 5y = 0. \]

and then find the particular solution for the initial conditions $y(0) = 1$ and $y'(0) = - \frac{1}{2}$.

Solution

We find the auxiliary equation to be:

\[2m^2 + 6m + 5 = 0 \]

and once again a simple factorisation does not seem possible, so we use the quadratic formula:

\[m_{1,2} = \frac{-6 \pm \sqrt{6^2 - 4 \cdot 2 \cdot 5}}{2 \cdot 2}. \]

The first thing to notice is that $6^2 - 4 \cdot 2 \cdot 5 = -4$, so if we type this into a calculator we will get an error. This means that the solutions are complex numbers:

\[m_{1,2} = - \frac{3}{2} \pm i\frac{1}{2}.\]

This time we have complex roots with real part $\alpha = -\frac{3}{2}$ and the imaginary part $\beta = \frac{1}{2}$. Notice that we ignore the $\pm$ sign when reading off the second part. Looking back at the table we can form the general solution:

\[y(x) = e^{-\frac{3}{2}x} \left( A\cos \left( \frac{x}{2} \right) + B\sin \left( \frac{x}{2} \right) \right). \]

To use the initial conditions to solve for the particular solution we will also need the differential of the general solution:

\[ y'(x) = -\frac{3}{2}e^{-\frac{3}{2}x} \left( A\cos \left( \frac{x}{2} \right) + B\sin \left( \frac{x}{2} \right) \right) + e^{-\frac{3}{2}x} \left( -\frac{A}{2}\sin \left( \frac{x}{2} \right) + \frac{B}{2}\cos \left( \frac{x}{2} \right) \right). \]

Note that we had to use the product rule. From the first initial condition,$y(0) = 1$, we find:

\[ y(0) = e^0 (A\cos(0) + B\sin(0)) = A = 1, \]

i.e. $A = 1$. From the second initial condition, $y'(0) = -\frac{1}{2}$, we find:

\[\begin{eqnarray} y'(0) &=& -\frac{3}{2}e^0 (1 \cdot \cos(0) + B \sin(0)) + e^0 \left( -\frac{1}{2}\sin(0) + \frac{B}{2}\cos(0) \right) \\ &=& -\frac{3}{2} + \frac{B}{2} = -\frac{1}{2}. \end{eqnarray}\]

We can now solve this, giving $B = 2$, therefore the particular solution is:

\[y(x) = e^{-\frac{3}{2}x} \left( \cos\left( \frac{x}{2} \right) + 2\sin\left(\frac{x}{2}\right) \right).\]

Example 4

Find the general solution to the equation:

\[ \frac{d^2y}{dx^2} - 3\frac{dy}{dx} = 0. \]

Solution

This equation looks a little different as it is missing a $y$ term, but we can solve it in the same way. First we form the auxiliary equation:

\[m^2 - 3m = 0, \]

which factorises to:

\[ m(m-3) = 0, \]

thus the solutions are $m_1 = 0$ and $m_2 = 3$. It is common for people to ignore or forget to include the $m_1 = 0$ in the general solution. The correct general solution is:

\[ y(x) = Ae^{0 \cdot x} + Be^{3x}, \]

or simply:

\[ y(x) = A + Be^{3x}. \]

Example 5

Find the general solution to the equation:

\[ \frac{d^2y}{dx^2} + \frac{dy}{dx} - 2y = 0, \]

with the boundary conditions $y(0) = 1$ and $y(\infty) = 0$.

Solution

Solving the differential equation should be fairly easy in this case. The auxiliary equation is:

\[ m^2 + m - 2 = 0, \]

which is factorised into:

\[ (m-1)(m+2) = 0, \]

and therefore the general solution is:

\[ y(x) = Ae^x + Be^{-2x}. \]

Now we have to think about the boundary conditions we have been given. The second condition imposes that as $x$ gets very large $y$ must approach zero. Looking at the two terms in the general solution it is clear that the first one, $Ae^x$, simply gets larger and larger as $x$ increases so we cannot include this in the particular solution. Therefore we are forced to take $A = 0$. The second term, $Be^{-2x}$, does indeed get smaller as $x$ increases, therefore we can use the first boundary term to find $B$:

\[ y(0) = Be^0 = B = 1, \]

giving the particular solution:

\[ y(x) = e^{-2x}. \]


[1] The distinction between initial conditions and boundary conditions is one of semantics; initial conditions are given when the problem is given in terms of time (t) and boundary conditions are given when the problem is given in terms of space (x).