A *forced* second order ordinary differential equation with constant coefficients is a differential equation in the form

\[a\frac{\mathrm{d}^2y}{\mathrm{d} x^2} + b\frac{\mathrm{d} y}{\mathrm{d} x} + cy = f(x),\]

where $a$, $b$ and $c$ are real numbers and $f(x)$ is a function of $x$. The function $f(x)$ is known as the *forcing term* or *forcing function*. The right-hand side can be any function; this page covers the three most common categories: polynomials, trigonometric and exponential.

**Note:** This form of differential equation is similar to the homogeneous second order differential equation, where $0$ appears on the right-hand side:

\[a\frac{\mathrm{d}^2y}{\mathrm{d} x^2} + b\frac{\mathrm{d} y}{\mathrm{d} x} + cy = 0.\]

To solve forced differential equations it is necessary to be familiar with the method for solving homogeneous equations.

The difficulty in solving this type of problem is trying to find a function which, when put through the differential equation, correctly gives the right-hand side. This is not always straightforward and often comes down to guessing a general form of a solution, and then substituting it into the differential equation to find a solution that fits. This function is known as the *particular solution*, $y_p$. There are some general rules to follow when dealing with the three categories of function given above.

The particular solution is not enough to fully solve the problem as it will not have any arbitrary constants which would satisfy the boundary conditions. However, a general solution to the homogeneous form of the same equation can be used to satisfy the boundary conditions. Since this second solution is reduced to zero by the differential equation it will not affect the particular solution's ability to give the correct right-hand side. The function that solves the homogeneous equation is known as the *complementary function*, $y_c$. The general solution to the differential equation is given by adding the particular and homogeneous parts together:

\[y = y_c + y_p.\]

The following examples demonstrate this method for each of the types of function most commonly found on the right-hand side.

Find the solution to the equation:

\[\frac{\mathrm{d}^2y}{\mathrm{d} x^2} + \frac{\mathrm{d} y}{\mathrm{d} x} - 2y = x^2,\]

subject to boundary conditions $y(0) = 0$ and $y'(0) = 0$.

Start by finding the particular solution. As an $x^2$ appears on the right-hand side it is sensible to assume that the particular solution is a quadratic polynomial. Guess that the particular solution is of the form:

\[y_p = Ax^2 + Bx + C.\]

To find $A$, $B$ and $C$, substitute this solution into the differential equation. The first and second derivatives of $y_p$ are:

\[\begin{align} y'_p &= 2Ax + B, \\ y''_p &= 2A. \end{align}\]

Substituting these into the differential equation gives:

\[2A + 2Ax + B - 2(Ax^2 + Bx + C) = x^2.\]

Multiplying out the left-hand side and collecting powers of $x$ gives:

\[-2Ax^2 + (2A-2B)x + 2A + B - 2C = x^2.\]

Equating coefficients of the powers of $x$ on both sides of the equal sign gives a system of simultaneous equations for $A$, $B$ and $C$:

\[\begin{align} -2A &= 1, \\ 2A - 2B &= 0, \\ 2A + B - 2C &= 0. \end{align}\]

From the first equation, $A = -\frac{1}{2}$. Substituting that into the second equation gives $B = -\frac{1}{2}$. Substituting these values for $A$ and $B$ into the third equation gives $C = -\frac{3}{4}$.

The particular solution is therefore:

\[y_p = -\frac{1}{2}x^2 - \frac{1}{2}x - \frac{3}{4}.\]

This solution produces a single $x^2$ when substituted into the differential equation, however does not give a solution that satisfies the boundary conditions. To satisfy the boundary conditions it is necessary to solve the homogeneous equation:

\[\frac{\mathrm{d}^2y_c}{\mathrm{d} x^2} + \frac{\mathrm{d} y_c}{\mathrm{d} x} - 2y_c = 0,\]

where the subscript $c$ indicates that this is the complementary function. The auxiliary equation is:

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

giving $\lambda_1 = 1$ and $\lambda_2 = -2$. The complementary function is therefore:

\[y_c = \hat{A} e^x + \hat{B} e^{-2x},\]

where $\hat{A}$ and $\hat{B}$ are arbitrary constants. The hat notation has been introduced to emphasise that these are not the same $A$ and $B$ that appeared when finding the particular solution.

**Note:** To find the values of $\hat{A}$ and $\hat{B}$ that satisfy the given problem it is necessary to apply the boundary conditions to the full solution and not just the complementary function. The full general solution must be formed before solving for $\hat{A}$ and $\hat{B}$.

Recall that the full general solution is the sum of the particular solution and the complementary function:

\[y(x) = y_c + y_p.\]

The general solution for the given equation is therefore:

\[y(x)= \hat{A} e^x + \hat{B} e^{-2x} - \frac{1}{2}x^2 - \frac{1}{2}x - \frac{3}{4}.\]

To solve the second boundary condition we will also need the first derivative of $y$:

\[y'(x) = \hat{A} e^x - 2\hat{B} e^{-2x} - x - \frac{1}{2}.\]

Applying the boundary conditions gives::

\[\begin{align} y(0) &= \hat{A} + \hat{B} - \frac{3}{4} = 0, \\ y'(0) &= \hat{A} - 2\hat{B} - \frac{1}{2} = 0. \end{align}\]

Rearranging the first equation gives $\hat{A} = \frac{3}{4} - \hat{B}$. Substituting this into the second equation gives $\frac{1}{4} - 3\hat{B} = 0$, so $\hat{B} = \frac{1}{12}$ and $\hat{A} = \frac{2}{3}$.

Substituting these values of $\hat{A}$ and $\hat{B}$ into the general solution gives the solution that satisfies the given boundary conditions:

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

Newcastle University Maths-Aid solves the differential equation $\displaystyle \frac{\mathrm{d}^2y}{\mathrm{d} x^2}+\frac{\mathrm{d} y}{\mathrm{d} x}-2y=x^2$ subject to the boundary conditions $y(0)=0$ and $y'(0)=0$.

Find the general solution to:

\[\frac{\mathrm{d}^2y}{\mathrm{d} x^2} + 4y = e^{3x}.\]

Start by finding the particular solution. The only function that can differentiate to give a term containing $ e^{3x}$ is $Ae^{3x}$, so guess that the particular solution is:

\[y_p=A e^{3x}.\]

Substituting this into the differential equation gives:

\[9A e^{3x} + 4A e^{3x} = e^{3x}.\]

The terms on the left-hand side can be collected:

\[13A e^{3x} = e^{3x}.\]

Solving for $A$ gives $A = \frac{1}{13}$ and the particular solution is therefore:

\[y_p = \frac{1}{13} e^{3x}.\]

Once again, this solution does not include arbitrary constants so the complementary function is necessary for a complete solution to the equation. Recall that the complementary function is found by solving the homogeneous form of the equation:

\[\frac{d^2y_c}{dx^2} + 4y_c = 0.\]

The auxiliary equation is:

\[\lambda^2 + 4 = 0.\]

The roots of this are purely complex, $\lambda = \pm 2i$, thus the complementary function is given by:

\[y_c = B\cos(2x) + C\sin(2x).\]

Having not been given any boundary conditions, this cannot be solved for the arbitrary constants $B$ and $C$, so it is sufficient to give the full general solution:

\[\begin{align} y &= y_c + y_p \\ &= B\cos(2x) + C\sin(2x) + \frac{1}{13} e^{3x}. \end{align}\]

Newcastle University Maths-Aid finds the general solution to the differential equation $\displaystyle \frac{\mathrm{d}^2y}{\mathrm{d} x^2}+4y= e^{3x}$.

Find the general solution to:

\[\frac{\mathrm{d}^2y}{\mathrm{d} x^2} + \frac{\mathrm{d} y}{\mathrm{d} x} - 2y = \sin{x}.\]

Start by finding the particular solution. Since the function on the right-hand side is a trigonometric function, it is sensible to assume that the particular solution is also trigonometric. Guess that the particular solution is of the form:

\[y_p = A\sin{x} + B\cos{x}.\]

**Note:** A common mistake is to only include one of the trigonometric functions in the guess for the particular solution. Since the differential equation includes both the first and second derivatives of $y$, both $\sin{x}$ and $\cos{x}$ must be included in the guess for $y_p$ to ensure that terms involving $\sin{x}$ and $\cos{x}$ will also appear in the terms $y_p''$ and $y_p'$.

To find $A$ and $B$, substitute the guess for the particular solution $y_p$ into the differential equation. The first and second derivatives of $y_p$ are:

\[\begin{align} y'_p &= A\cos{x} - B\sin{x}, \\ y''_p &= -A\sin{x} - B\cos{x}. \end{align}\]

Substituting this into the differential equation gives:

\[(-A\sin{x} - B\cos{x}) + (A\cos{x} - B\sin{x}) - 2(A\sin{x} + B\cos{x}) = \sin{x}.\]

First collect the coefficients of the $\sin{x}$ and $\cos{x}$ terms:

\[(-A-B-2A)\sin{x} + (-B+A-2B)\cos{x} = \sin{x}.\]

The coefficients of each term can be equated with the coefficient of the corresponding term on the right-hand side:

\[\begin{align} -3A-B &= 1, \\ A-3B &= 0. \end{align}\]

Solving these simultaneously gives:

\[A = -\frac{3}{10}, \quad B = -\frac{1}{10}.\]

Thus the particular solution is:

\[y_p = - \frac{3}{10}\sin{x} - \frac{1}{10}\cos{x}.\]

This solution does not contain any arbitrary constants. The solution to a second order differential equation should include two arbitrary constants. The complementary function, which contains two arbitrary constants, must be found to complete the solution.

Recall that the complementary function is found by solving the homogeneous equation:

\[\frac{\mathrm{d}^2y_c}{\mathrm{d} x^2} + \frac{\mathrm{d} y_c}{\mathrm{d} x} - 2y_c = 0.\]

The auxiliary equation is:

\[\lambda^2 + \lambda - 2 = 0.\]

The solutions to the auxiliary equation are $\lambda_1 = -2$ and $\lambda_2 = 1$, giving the complementary function:

\[y_c = \hat{A} e^{-2x} + \hat{B} e^x,\]

where $\hat{A}$ and $\hat{B}$ are arbitrary constants.

Hence the full general solution is:

\[\begin{align} y(x) &= y_c +y_p, \\ y(x) &= \hat{A} e^{-2x} + \hat{B} e^x - \frac{3}{10}\sin{x} - \frac{1}{10}\cos{x}. \end{align}\]

Newcastle University Maths-Aid finds the general solution to the differential equation $\displaystyle \frac{\mathrm{d}^2y}{\mathrm{d} x^2}+\frac{\mathrm{d} y}{\mathrm{d} x}-2y=\sin{x}.$

Find the general solution to:

\[\frac{\mathrm{d}^2y}{\mathrm{d} x^2} - 4\frac{\mathrm{d} y}{\mathrm{d} x} + 3y = 4x + 3 e^{2x}.\]

Note that the right-hand side of this equation includes both an exponential and a linear term; the particular solution is therefore likely to contain both an exponential term and a linear term. Guess that the particular solution is of the form:

\[y_p = A e^{2x} + Bx + C\]

To find $A$ and $B$, substitute this solution into the differential equation. The first and second derivatives of $y_p$ are:

\[\begin{align} y_p' &= 2A e^{2x}+B, \\ y_p'' &= 4A e^{2x}. \end{align}\]

Substituting these into the differential equation gives:

\[4A e^{2x} - 4(2A e^{2x} + B) + 3(A e^{2x} + Bx + C) = 4x + 32^{2x}.\]

Expanding the brackets and collecting the $ e^{2x}$ terms, the $x$ terms and the constants gives:

\[-A e^{2x} + 3Bx - 4B + 3C = 4x + 3 e^{2x}.\]

Equating coefficients on both sides gives a set of three simultaneous equations for $A$, $B$ and $C$:

\[\begin{align} -A &= 3, \\ 3B &= 4, \\ -4B + 3C &= 0. \end{align}\]

Solving these gives $A = -3$, $B = \frac{4}{3}$ and $C = \frac{16}{9}$, so the particular solution is:

\[y_p = -3 e^{2x} + \frac{4x}{3} + \frac{16}{9}.\]

To complete the solution the complementary function $y_c$ must be found by solving the homogeneous equation:

\[\frac{\mathrm{d}^2y_c}{\mathrm{d} x^2} - 4\frac{\mathrm{d} y_c}{\mathrm{d} x} + 3y_c = 0.\]

The auxiliary equation is:

\[\lambda^2 - 4\lambda + 3 = 0.\]

The solutions to the auxiliary equation are $\lambda_1 = 1$ and $\lambda_2 = 3$, giving the complementary function:

\[y_c = \hat{A} e^x + \hat{B} e^{3x}\]

where $\hat{A}$ and $\hat{B}$ are arbitrary constants.

Hence the general solution to the differential equation is:

\[\begin{align} y(x) &= y_c+y_p \\ y(x) &= \hat{A} e^x + \hat{B} e^{3x} -3 e^{2x} + \frac{4x}{3} + \frac{16}{9}. \end{align}\]

Newcastle University Maths-Aid finds the general solution to the differential equation $\displaystyle \frac{\mathrm{d}^2y}{\mathrm{d} x^2}-4\frac{\mathrm{d} y}{\mathrm{d} x}+3y=4x+3 e^{2x}.$