Second order ODEs

Linear ODEs

Recall that in general a linear ODE of order \(n\) can be written in the form

\[ a_n(x)\frac{\mathrm{d}^ny}{\mathrm{d}x^n}+a_{n-1}(x)\frac{\mathrm{d}^{n-1}y}{\mathrm{d}x^{n-1}}+\ldots+a_1(x)\frac{\mathrm{d}y}{\mathrm{d}x}+a_0(x)y+q_0(x)=0. \]

Any linear ODE has general solution in the form

\[ y(x)=\text{Complementary function} + \text{Particular Integral}, \]

where the complementary function is the general solution to the homogeneous equation

\[ a_n(x)\frac{\mathrm{d}^ny}{\mathrm{d}x^n}+a_{n-1}(x)\frac{\mathrm{d}^{n-1}y}{\mathrm{d}x^{n-1}}+\ldots+a_1(x)\frac{\mathrm{d}y}{\mathrm{d}x}+a_0(x)y=0, \]

while the particular integral is any solution of the original equation.

Second order linear homogeneous ODEs with constant coefficients

Second order linear homogeneous ODEs with constant coefficients (i.e. the functions \(a_j(x)\) are constants) can be written as

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

where \(a,b\) are constants.

Such ODEs are solved by considering the so-called auxiliary equation \(m^2+am+b=0\). We can solve this quadratic (by factorising, completing the square or using the quadratic formula) to find the two roots \(m_1\) and \(m_2\). Then

  • If \(m_1,m_2\) are both real, the general solution is of the form

    \[ y=Ae^{m_1x}+Be^{m_2x}. \]
  • If \(m_1=m_2\) (i.e. a repeated root), the general solution is of the form

    \[ y=(A+Bx)e^{m_1x}. \]
  • If \(m_1,m_2\) are complex conjugates, i.e. \(m_1=\alpha+i\beta\) and \(m_2=\alpha-i\beta\), then the general solution is of the form

    \[ y=e^{\alpha x}\left(C\cos\beta x+D\sin\beta x\right). \]

Second order linear inhomogeneous ODEs with constant coefficients

We now consider equations of the form

\[ \frac{\mathrm{d}^2y}{\mathrm{d}x^2}+a\frac{\mathrm{d}y}{\mathrm{d}x}+by=f(x). \]

Recall that the right hand side function \(f(x)\) is usually called the forcing term and that solutions of linear inhomogeneous ODEs are of the form

\[ y=\text{Complementary function + Particular integral}. \]

The complementary function is the solution to the homogeneous ODE

\[ \frac{\mathrm{d}^2y}{\mathrm{d}x^2}+a\frac{\mathrm{d}y}{\mathrm{d}x}+by=0, \]

so can be found by our method for solving homogeneous second order ODEs (i.e. by considering the auxiliary equation).

To find the particular integral, we use the method of undetermined coefficients. This involves making an educated guess of the form of the particular integral (which will contain some unknown constants), before substituting this form into the ODE and comparing coefficients of various terms to obtain the particular solution.

How to choose the form of the particular integral

The choice of which form of particular integral \(y_p\) to try depends on the forcing term \(f(x)\).

  • If \(f(x)=\alpha x^n\), try

    \[ y_p=a_0+a_1x+\ldots+a_{n-1}x^{n-1}+a_nx^n. \]
  • If \(f(x)=\alpha \sin(\beta x)\) or \(f(x)=\alpha\cos(\beta x)\), try

    \[ y_p=a_1\sin(\beta x)+a_2\cos(\beta x). \]
  • If \(f(x)=\alpha e^{\beta x}\), try

    \[ y_p=ae^{\beta x}. \]

Then substitute into the differential equation and compare coefficients to determine the values of any arbitrary constants.

Below are a couple of examples to illustrate how.

Example

Consider

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

This has auxiliary equation \(m^2-2m-3=0,\) which has roots \(m_1=3\) and \(m_2=-1\), so the complementary function is

\[ y_c=Ae^{3x}+Be^{-x}. \]

Now suppose the particular integral is of the form \(y_p=ae^{2 x}\). Substitution of this into the ODE gives

\[ 4ae^{2x}-4ae^{2x}-3ae^{2x}=\exp{2x}. \]

For this to be satisfied, we see that \(a=-\frac{1}{3}\), and so the particular integral is \(y=-\frac{1}{3}e^{2x}\). Consequently the general solution of the ODE is

\[ y=Ae^{3x}+Be^{-x}-\frac{1}{3}e^{2x}. \]

Example

Consider

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

This has the same auxiliary equation and so the same complementary function as the previous example. Now suppose the particular integral is of the form \(y_p=a_1\sin(3x)+a_2\cos(3x)\). Substitution of this into the ODE gives

\[ -9a_1\sin(3x)-9a_2\cos(3x)-2(3a_1\cos(3x)-3a_2\sin(3x))-3(a_1\sin(3x)+a_2\cos(3x))=2\sin(3x), \]

which can be rewritten (by collecting coefficients of \(\sin\) and \(\cos\) terms) as

\[ (6a_2-12a_1)\sin(3x)-(6a_1+12a_2)\cos(3x)=2\sin(3x). \]

Consequently we need to find constants \(a_1,a_2\) so that \(6a_1+12a_2=0\) and \(6a_2-12a_1=2\). This is a pair of simultaneous equations with solution \(a_1=-\frac{2}{15},a_2=\frac{1}{15}.\) Therefore the particular integral is

\[ y_p=\frac{1}{15}\cos(3x)-\frac{2}{15}\sin(3x). \]

Finally, \(y=y_c+y_p\), so the general solution is

\[ y=Ae^{3x}+Be^{-x}+\frac{1}{15}\cos(3x)-\frac{2}{15}\sin(3x). \]

If the forcing term is a sum of these types of function

If the forcing term is a sum of these types of function, try a sum of the suggested trial functions. For instance, if the forcing term is \(x+\sin x\), try

\[ y_p(x)=a+bx+c\sin x+d\cos x. \]

If the forcing term is a product of a polynomial with either an exponential or trigonometric function, try a product of such functions. For example, if the forcing term is \(xe^x\), try

\[ y_p(x)=(A+Bx)e^{x}. \]

IMPORTANT: cases for which the above forms do NOT work

There are some situations for which the forms of particular integral suggested above are insufficient:

When the usual form for the particular integral is the same form as the complementary function then we must modify the trial function by multiplying the usual form by \(x^k\), where \(k\) is is the number of times that a root of the auxiliary equation corresponding to the form of the trial function occurs.

Example

Consider

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

This has auxiliary equation \(m^2-2m+1=0,\) which has repeated root \(m_1=m_2=1\), so the complementary function is

\[ y_c=(A+Bx)e^{x}. \]

Our usual trial function for the particular integral would be of the form \(y_p=ae^{x}\) BUT a term of this form is already included in the complementary function. Similarly a term of the form \(axe^x\) is included in the complementary function. Therefore \(ae^x\) and \(axe^x\) are solutions of the corresponding homogeneous equation

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

so are not useful as trial functions for the particular integral.

We should therefore try

\[ y_p(x)=ax^2e^x. \]

[Note that this is the usual form multiplied by \(x^2\), because the root occurred twice.]

Example

Consider

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

This has auxiliary equation \(m^2+4=0,\) which has complex conjugate roots \(m_1=2i,m_2=-2i\), so the complementary function is

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

Since the forcing term is of this form, we should try

\[ y_p=x(a_1\sin(2x)+a_2\cos(2x)) \]

as our trial function.