This page is about second order differential equations of this type:

*d ^{2}y*

**dx**+ P(x)

^{2}*dy*

**dx**+ Q(x)y = f(x)

where P(x), Q(x) and f(x) are functions of x.

Please read Introduction to Second Order Differential Equations first, it shows how to solve the simpler "hom*ogeneous" case where f(x)=0

## Two Methods

There are two main methods to solve equations like

*d ^{2}y*

**dx**+ P(x)

^{2}*dy*

**dx**+ Q(x)y = f(x)

Undetermined Coefficients which only works when f(x) is a polynomial, exponential, sine, cosine or a linear combination of those.

**Variation of Parameters** (that we will learn here) which works on a wide range of functions but is a little messy to use.

## Variation of Parameters

To keep things simple, we are only going to look at the case:

*d ^{2}y*

**dx**+ p

^{2}*dy*

**dx**+ qy = f(x)

The **complete solution** to such an equation can be found by combining two types of solution:

- The
**general solution**of the hom*ogeneous equation*d*^{2}y**dx**+ p^{2}*dy***dx**+ qy = 0 **Particular solutions**of the non-hom*ogeneous equation*d*^{2}y**dx**+ p^{2}*dy***dx**+ qy = f(x)

Note that f(x) could be a single function or a sum of two or more functions.

Once we have found the general solution and all the particular solutions, then the final complete solution is found by adding all the solutions together.

This method relies on integration.

The problem with this method is that, although it may yield a solution, in some cases the solution has to be left as an integral.

## Start with the General Solution

On Introduction to Second Order Differential Equations we learn how to find the general solution.

Basically we take the equation

*d ^{2}y*

**dx**+ p

^{2}*dy*

**dx**+ qy = 0

and reduce it to the "characteristic equation":

r^{2} + pr + q = 0

Which is a quadratic equation that has three possible solution types depending on the discriminant **p ^{2} − 4q**.

When **p ^{2} − 4q** is:

**positive** we get two real roots, and the solution is

y = Ae^{r1x} + Be^{r2x}

**zero** we get one real root, and the solution is

y = Ae^{rx} + Bxe^{rx}

**negative** we get two complex roots **r _{1} = v + wi** and

**r**, and the solution is

_{2}= v − wiy = e^{vx} ( Ccos(wx) + iDsin(wx) )

## The Fundamental Solutions of The Equation

In all three cases above "y" is made of two parts:

**y = Ae**is made of^{r1x}+ Be^{r2x}**y**and_{1}= Ae^{r1x}**y**_{2}= Be^{r2x}**y = Ae**is made of^{rx}+ Bxe^{rx}**y**and_{1}= Ae^{rx}**y**_{2}= Bxe^{rx}**y = e**is made of^{vx}( Ccos(wx) + iDsin(wx) )**y**and_{1}= e^{vx}Ccos(wx)**y**_{2}= e^{vx}iDsin(wx)

y_{1} and y_{2} are known as the fundamental solutions of the equation

And y_{1} and y_{2} are said to be **linearly independent** because neither function is a constant multiple of the other.

## The Wronskian

When y_{1} and y_{2} are the two fundamental solutions of the hom*ogeneous equation

*d ^{2}y*

**dx**+ p

^{2}*dy*

**dx**+ qy = 0

then the Wronskian W(y_{1}, y_{2}) is the determinant of the matrix

So

W(y_{1}, y_{2}) = y_{1}y_{2}' − y_{2}y_{1}'

The **Wronskian** is named after the Polish mathematician and philosopher Józef Hoene-Wronski (1776−1853).

Since y_{1} and y_{2} are linearly independent, the value of the Wronskian cannot equal zero.

## The Particular Solution

Using the Wronskian we can now find the particular solution of the differential equation

*d ^{2}y*

**dx**+ p

^{2}*dy*

**dx**+ qy = f(x)

using the formula:

y_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})### Example 1: Solve *d*^{2}y**dx**^{2} − 3*dy***dx** + 2y = e^{3x}

^{2}y

^{2}

**1. Find the general solution of** *d ^{2}y*

**dx**− 3

^{2}*dy*

**dx**+ 2y = 0

The characteristic equation is: r^{2} − 3r + 2 = 0

Factor: (r − 1)(r − 2) = 0

r = 1 or 2

So the general solution of the differential equation is y = Ae^{x}+Be^{2x}

So in this case the fundamental solutions and their derivatives are:

y_{1}(x) = e^{x}

y_{1}'(x) = e^{x}

y_{2}(x) = e^{2x}

y_{2}'(x) = 2e^{2x}

**2. Find the Wronskian:**

W(y_{1}, y_{2}) = y_{1}y_{2}' − y_{2}y_{1}' = 2e^{3x} − e^{3x} = e^{3x}

**3. Find the particular solution using the formula:**

y_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})**4. First we solve the integrals:**

∫*y _{2}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{2x}e^{3x}*

**e**dx

^{3x}= ∫e^{2x}dx

= *1*2e^{2x}

So:

−y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx = −(e

_{1}, y_{2})^{x})(

*1*2e

^{2x}) =−

*1*2e

^{3x}

**And also:**

∫*y _{1}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{x}e^{3x}*

**e**dx

^{3x}= ∫e^{x}dx

= e^{x}

So:

y_{2}(x)∫*y _{1}(x)f(x)*

**W(y**dx = (e

_{1}, y_{2})^{2x})(e

^{x}) = e

^{3x}

**Finally:**

y_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})= −*1*2e^{3x} + e^{3x}

= *1*2e^{3x}

and the complete solution of the differential equation *d ^{2}y*

**dx**− 3

^{2}*dy*

**dx**+ 2y = e

^{3x}is

y = Ae^{x} + Be^{2x} + *1*2e^{3x}

Which looks like this (example values of A and B):

### Example 2: Solve *d*^{2}y**dx**^{2} − y = 2x^{2} − x − 3

^{2}y

^{2}

**1. Find the general solution of** *d ^{2}y*

**dx**− y = 0

^{2}The characteristic equation is: r^{2} − 1 = 0

Factor: (r − 1)(r + 1) = 0

r = 1 or −1

So the general solution of the differential equation is y = Ae^{x}+Be^{−x}

So in this case the fundamental solutions and their derivatives are:

y_{1}(x) = e^{x}

y_{1}'(x) = e^{x}

y_{2}(x) = e^{−x}

y_{2}'(x) = −e^{−x}

**2. Find the Wronskian:**

W(y_{1}, y_{2}) = y_{1}y_{2}' − y_{2}y_{1}' = −e^{x}e^{−x} − e^{x}e^{−x} = −2

**3. Find the particular solution using the formula:**

_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})**4. Solve the integrals:**

Each of the integrals can be obtained by using Integration by Parts twice:

∫*y _{2}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{−x }(2x^{2}−x−3)*

**−2**dx

= −*1*2 ∫(2x^{2}−x−3)e^{−x}dx

= −*1*2[ −(2x^{2}−x−3)e^{−x} + ∫(4x−1)e^{−x }dx ]

= −*1*2[ −(2x^{2}−x−3)e^{−x} − (4x − 1)e^{−x} + ∫4e^{−x}dx ]

= −*1*2[ −(2x^{2}−x−3)e^{−x} − (4x − 1)e^{−x} − 4e^{−x} ]

= *e ^{−x}*2[ 2x

^{2}− x − 3 + 4x −1 + 4 ]

= *e ^{−x}*2[ 2x

^{2}+ 3x ]

So:

−y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx = (−e

_{1}, y_{2})^{x})[

*e*2( 2x

^{−x}^{2}+ 3x )] =−

*1*2(2x

^{2}+ 3x)

**And this one:**

∫*y _{1}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{x }(2x^{2}−x−3)*

**−2**dx

= −*1*2 ∫(2x^{2}−x−3)e^{x}dx

= −*1*2[ (2x^{2}−x−3)e^{x} − ∫(4x−1)e^{x }dx ]

= −*1*2[ (2x^{2}−x−3)e^{x} − (4x − 1)e^{x} + ∫4e^{x}dx ]

= −*1*2[ (2x^{2}−x−3)e^{x} − (4x − 1)e^{x} + 4e^{x} ]

= *−e ^{x}*2[ 2x

^{2}− x − 3 − 4x + 1 + 4 ]

= *−e ^{x}*2[ 2x

^{2}− 5x + 2 ]

So:

y_{2}(x)∫*y _{1}(x)f(x)*

**W(y**dx = (e

_{1}, y_{2})^{−x})[

*−e*2( 2x

^{x}^{2}− 5x + 2 ) ]

= −

*1*2( 2x

^{2}− 5x + 2 )

^{}

**Finally:**

_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})= −*1*2( 2x^{2} + 3x ) − *1*2( 2x^{2} − 5x + 2 )

= −*1*2( 4x^{2} − 2x + 2 )

= −2x^{2} + x − 1

and the complete solution of the differential equation *d ^{2}y*

**dx**− y = 2x

^{2}^{2}− x − 3 is

**y = Ae ^{x} + Be^{−x} − 2x^{2} + x − 1 **

(This is the same answer that we got in Example 1 on the page Method of undetermined coefficients.)

### Example 3: Solve *d*^{2}y**dx**^{2} − 6*dy***dx** + 9y =*1***x**

^{2}y

^{2}

**1. Find the general solution of** *d ^{2}y*

**dx**− 6

^{2}*dy*

**dx**+ 9y = 0

The characteristic equation is: r^{2} − 6r + 9 = 0

Factor: (r − 3)(r − 3) = 0

r = 3

So the general solution of the differential equation is y = Ae^{3x} + Bxe^{3x}

And so in this case the fundamental solutions and their derivatives are:

y_{1}(x) = e^{3x}

y_{1}'(x) = 3e^{3x}

y_{2}(x) = xe^{3x}

y_{2}'(x) = (3x + 1)e^{3x}

**2. Find the Wronskian:**

W(y_{1}, y_{2}) = y_{1}y_{2}' − y_{2}y_{1}' = (3x + 1)e^{3x}e^{3x} − 3xe^{3x}e^{3x} = e^{6x}

**3. Find the particular solution using the formula:**

_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})**4. Solve the integrals:**

∫*y _{2}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*(xe ^{3x})x^{−1} *

**e**dx (Note:

^{6x}*1*

**x**= x

^{−1})

= ∫e^{−3x}dx

= −*1*3e^{−3x}

So:

−y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx = −(e

_{1}, y_{2})^{3x})(−

*1*3e

^{−3x}) =

*1*3

**And this one:**

∫*y _{1}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{3x}x^{−1}*

**e**dx

^{6x}= ∫e^{−3x}x^{−1}dx

This cannot be integrated, so this is an example where the answer has to be left as an integral.

So:

y_{2}(x)∫*y _{1}(x)f(x)*

**W(y**dx = ( xe

_{1}, y_{2})^{3x })( ∫e

^{−3x}x

^{−1}dx ) = xe

^{3x}∫e

^{−3x}x

^{−1}dx

**Finally:**

_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})= *1*3 + xe^{3x}∫e^{−3x}x^{−1}dx

So the complete solution of the differential equation *d ^{2}y*

**dx**− 6

^{2}*dy*

**dx**+ 9y =

*1*x is

**y = Ae ^{3x} + Bxe^{3x} + 13 + xe^{3x}∫e^{−3x}x^{−1}dx**

### Example 4 (Harder example): Solve *d*^{2}y**dx**^{2} − 6*dy***dx** + 13y = 195cos(4x)

^{2}y

^{2}

**This example uses the following trigonometric identities**

sin^{2}(θ) + cos^{2}(θ) = 1

sin(θ ± φ) = sin(θ)cos(φ) ± cos(θ)sin(φ)

cos(θ ± φ) = cos(θ)cos(φ) sin(θ)sin(φ)

sin(θ)cos(φ) = *1***2**[sin(θ + φ) + sin(θ − φ)]

cos(θ)cos(φ) = *1***2**[cos(θ − φ) + cos(θ + φ)]

**1. Find the general solution of** *d ^{2}y*

**dx**− 6

^{2}*dy*

**dx**+ 13y = 0

The characteristic equation is: r^{2} − 6r + 13 = 0

Use the quadratic equation formula

x = *−b ± √(b ^{2 }− 4ac)*

**2a**

with a = 1, b = −6 and c = 13

So:

r = *−(−6) ± √[(−6) ^{2 }− 4(1)(13)]*

**2(1)**

= *6 ± √[36−52]* **2**

= *6 ± √[−16]* **2**

= *6 ± 4i* **2**

= 3 ± 2i

So α = 3 and β = 2

⇒ y = e^{3x}[Acos(2x) + iBsin(2x)]

So in this case we have:

y_{1}(x) = e^{3x}cos(2x)

y_{1}'(x) = e^{3x}[3cos(2x) − 2sin(2x)]

y_{2}(x) = e^{3x}sin(2x)

y_{2}'(x) = e^{3x}[3sin(2x) + 2cos(2x)]

**2. Find the Wronskian:**

W(y_{1}, y_{2}) = y_{1}y_{2}' − y_{2}y_{1}'

= e^{6x}cos(2x)[3sin(2x) + 2cos(2x)] − e^{6x}sin(2x)[3cos(2x) − 2sin(2x)]

= e^{6x}[3cos(2x)sin(2x) +2cos^{2}(2x) − 3sin(2x)cos(2x) + 2sin^{2}(2x)]

= 2e^{6x}

**3. Find the particular solution using the formula:**

_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})**4. Solve the integrals:**

∫*y _{2}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{3x}sin(2x)[195cos(4x)] *

**2e**dx

^{6x}= *195***2**∫e^{−3x}sin(2x)cos(4x)dx

= *195***4**∫e^{−3x}[sin(6x) − sin(2x)]dx ... (1)

In this case, we won’t do the integration yet, for reasons that will become clear in a moment.

The other integral is:

∫*y _{1}(x)f(x)*

**W(y**dx

_{1}, y_{2})= ∫*e ^{3x}cos(2x)[195cos(4x)]*

**2e**dx

^{6x}= *195***2**∫e^{−3x}cos(2x)cos(4x)dx

= *195***4**∫e^{−3x}[cos(6x) + cos(2x)]dx ... (2)

From equations (1) and (2) we see that there are four very similar integrations that we need to perform:

*I*_{1} = ∫e^{−3x}sin(6x)dx*I*_{2} = ∫e^{−3x}sin(2x)dx*I*_{3} = ∫e^{−3x}cos(6x)dx*I*_{4} = ∫e^{−3x}cos(2x)dx

Each of these could be obtained by using Integration by Parts twice, but there’s an easier method:

*I*_{1} = ∫e^{−3x}sin(6x)dx = −*1***6**e^{−3x}cos(6x) − *3***6**∫e^{−3x}cos(6x)dx = − *1***6**e^{−3x}cos(6x) − *1*2*I*_{3}

⇒ **2 I_{1 }+ I_{3} = − 13e^{−3x}cos(6x) ... (3)**

*I*_{2} = ∫e^{−3x}sin(2x)dx = −*1***2**e^{−3x}cos(2x) − *3*2∫e^{−3x}cos(2x)dx = − *1*2e^{−3x}cos(2x) − *3*2*I*_{4}

⇒ **2 I_{2 }+ 3I_{4} = − e^{−3x}cos(2x) ... (4)**

*I*_{3} = ∫e^{−3x}cos(6x)dx = *1***6**e^{−3x}sin(6x) + *3***6**∫e^{−3x}sin(6x)dx = *1***6**e^{−3x}sin(6x) + *1*2*I*_{1}

⇒ **2 I_{3 }− I_{1} = 13e^{−3x}sin(6x) ... (5)**

*I*

_{4}= ∫e

^{−3x}cos(2x)dx =

*1*

**2**e

^{−3x}sin(2x) +

*3*2∫e

^{−3x}sin(2x)dx =

*1*2e

^{−3x}sin(2x) +

*3*2

*I*

_{2}

⇒ **2 I_{4 }− 3I_{2} = e^{−3x}sin(2x) ... (6)**

Solve equations (3) and (5) simultaneously:

2*I*_{1 }+ *I*_{3} = − *1*3e^{−3x}cos(6x) ... (3)

2*I*_{3 }− *I*_{1} = *1*3e^{−3x}sin(6x) ... (5)

Multiply equation (5) by 2 and add them together (term *I*_{1} will neutralize):

⇒ 5*I*_{3 }= − *1*3e^{−3x}cos(6x) + *2*3e^{−3x}sin(6x)

= *1*3e^{−3x}[2sin(6x) − cos(6x)]

⇒ *I*_{3 }= *1*15e^{−3x}[2sin(6x) − cos(6x)]

Multiply equation (3) by 2 and subtract (term *I*_{3} will neutralize):

⇒ 5*I*_{1 }= − *2*3e^{−3x}cos(6x) − *1*3e^{−3x}sin(6x)

= − *1*3e^{−3x}[2cos(6x) + sin(6x)]

⇒ *I*_{1 }= − *1*15e^{−3x}[2cos(6x) + sin(6x)]

Solve equations (4) and (6) simultaneously:

2*I*_{2 }+ 3*I*_{4} = − e^{−3x}cos(2x) ... (4)

2*I*_{4 }− 3*I*_{2} = e^{−3x}sin(2x) ... (6)

Multiply equation (4) by 3 and equation (6) by 2 and add (term *I*_{2} will neutralize):

⇒ 13*I*_{4 }= − 3e^{−3x}cos(2x) + 2e^{−3x}sin(2x)

=e^{−3x}[2sin(2x) − 3 cos(2x)]

⇒ *I*_{4 }= *1*13e^{−3x}[2sin(2x) − 3cos(2x)]

Multiply equation (4) by 2 and equation (6) by 3 and subtract (term *I*_{4} will neutralize):

⇒ 13*I*_{2 }= − 2e^{−3x}cos(2x) − 3e^{−3x}sin(2x)

=− e^{−3x}[2cos(2x) + 3 sin(2x)]

⇒ *I*_{2 }= − *1*13e^{−3x}[2cos(2x) + 3sin(2x)]

Substitute into (1) and (2):

∫*y _{2}(x)f(x)*

**W(y**dx

_{1}, y_{2})= *195*4∫e^{−3x}[sin(6x) − sin(2x)]dx ... (1)

= *195*4[**−** *1*15e^{−3x}[2cos(6x) + sin(6x)] − [−*1*13e^{−3x}[2cos(2x) + 3sin(2x)]]]

= *e ^{−3x}*4[−13(2cos(6x)+sin(6x))+15(2 cos(2x)+3sin(2x))]

∫*y _{1}(x)f(x)*

**W(y**dx

_{1}, y_{2})= *195***4**∫e^{−3x}[cos(6x) + cos(2x)]dx ... (2)

= *195*4[*1*15e^{−3x}[2sin(6x) − cos(6x)] + *1*13e^{−3x}[2sin(2x) − 3cos(2x)]]

= *e ^{−3x}*4[13(2sin(6x) − cos(6x)) + 15(2sin(2x) − 3cos(2x))]

So y_{p}(x) = −y_{1}(x)∫*y _{2}(x)f(x)*

**W(y**dx + y

_{1}, y_{2})_{2}(x)∫

*y*

_{1}(x)f(x)**W(y**dx

_{1}, y_{2})= − e^{3x}cos(2x)*e ^{−3x}*4[−13(2cos(6x)+sin(6x)) + 15(2 cos(2x)+3sin(2x))] + e

^{3x}sin(2x)

*e*4[13(2sin(6x) − cos(6x)) + 15(2sin(2x) − 3cos(2x))]

^{−3x}= − *1*4cos(2x) [−13(2cos(6x) − sin(6x)) + 15(2 cos(2x) + 3sin(2x))] +*1*4 sin(2x)[13(2sin(6x) − cos(6x)) + 15(2 sin(2x) − 3cos(2x))]

= *1*4[26cos(2x)cos(6x) + 13cos(2x)sin(6x) − 30cos^{2}(2x) − 45cos(2x)sin(2x) + 26sin(2x)sin(6x) − 13sin(2x)cos(6x) + 30sin^{2}(2x) − 45sin(2x)cos(2x)]

= *1*4[26[cos(2x)cos(6x) + sin(2x)sin(6x)] + 13[cos(2x)sin(6x) − sin(2x)cos(6x)] − 30[cos^{2}(2x) − sin^{2}(2x)] − 45[cos(2x)sin(2x) + sin(2x)cos(2x)]]

= *1*4[26cos(4x) + 13sin(4x) − 30cos(4x) − 45sin(4x)]

= *1*4[−4cos(4x) − 32sin(4x)]

= −cos(4x) − 8 sin(4x)

So the complete solution of the differential equation *d ^{2}y*

**dx**− 6

^{2}*dy*

**dx**+ 13y = 195cos(4x) is

** y = e ^{3x}(Acos(2x) + iBsin(2x)) − cos(4x) − 8sin(4x)**

9529, 9530, 9531, 9532, 9533, 9534, 9535, 9536, 9537, 9538

Differential Equations Solution Guide Calculus Index