# Second Order Differential Equations

Here we learn how to solve equations of this type:

\frac{d^{2}y}{dx^{2}} + p\frac{dy}{dx} + qy = 0

## Differential Equation

A Differential Equation is an equation with a function and one or more of its derivatives:

Example: an equation with the function **y** and its
derivative** \frac{dy}{dx} **

## Order

The Order is the **highest derivative** (is it a first derivative? a second derivative? etc):

### Example:

\frac{dy}{dx} + y^{2} = 5x

It has only the first derivative \frac{dy}{dx} , so is "First Order"

### Example:

\frac{d^{2}y}{dx^{2}} + xy = sin(x)

This has a second derivative \frac{d^{2}y}{dx^{2}} , so is "Second Order" or "Order 2"

### Example:

\frac{d^{3}y}{dx^{3}} + x\frac{dy}{dx} + y = e^{x}

This has a third derivative \frac{d^{3}y}{dx^{3}} which outranks the \frac{dy}{dx} , so is "Third Order" or "Order 3"

### Before tackling second order differential equations, make sure you are familiar with the various methods for solving first order differential equations.

## Second Order Differential Equations

We can solve a second order differential equation of the type:

\frac{d^{2}y}{dx^{2}} + P(x)\frac{dy}{dx} + Q(x)y = f(x)

where P(x), Q(x) and f(x) are functions of x, by using:

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

Undetermined Coefficients which is a little messier but works on a wider range of functions.

But here we begin by learning the case where **f(x) = 0** (this makes it "homogeneous"):

\frac{d^{2}y}{dx^{2}} + P(x)\frac{dy}{dx} + Q(x)y = 0

and also where the functions P(X) and Q(x) are constants **p** and **q**:

\frac{d^{2}y}{dx^{2}} + p\frac{dy}{dx} + qy = 0

Let's learn to solve them!

*e* to the rescue

*e*

We are going to use a special property of the derivative of the exponential function:

At any point the slope (derivative) of **e**^{x} equals the value of **e**^{x} :

And when we introduce a value "r" like this:

f(x) = e^{rx}

We find:

- the first derivative is f'(x) = re
^{rx} - the second derivative is f''(x) = r
^{2}e^{rx}

In other words, the first and second derivatives of f(x) are both **multiples** of f(x)

This is going to help us a lot!

### Example 1: Solve

\frac{d^{2}y}{dx^{2}} + \frac{dy}{dx} − 6y = 0

Let y = e^{rx} so we get:

- \frac{dy}{dx} = re
^{rx} - \frac{d^{2}y}{dx^{2}} = r
^{2}e^{rx}

Substitute these into the equation above:

r^{2}e^{rx} + re^{rx} − 6e^{rx} = 0

Simplify:

e^{rx}(r^{2} + r − 6) = 0

r^{2} + r − 6 = 0

We have reduced the differential equation to an ordinary quadratic equation!

This quadratic equation is given the special name of **characteristic equation**.

We can factor this one to:

(r − 2)(r + 3) = 0

So **r = 2 or −3**

And so we have two solutions:

y = e^{2x}

y = e^{−3x}

But that’s not the final answer because we can combine different **multiples** of these two answers to get a more general solution:

y = Ae^{2x} + Be^{−3x}

### Check

Let us check that answer. First take derivatives:

y = Ae^{2x} + Be^{−3x}

\frac{dy}{dx} = 2Ae^{2x} − 3Be^{−3x}

\frac{d^{2}y}{dx^{2}} = 4Ae^{2x} + 9Be^{−3x}

Now substitute into the original equation:

\frac{d^{2}y}{dx^{2}} + \frac{dy}{dx} − 6y = 0

(4Ae^{2x} + 9Be^{−3x}) + (2Ae^{2x} − 3Be^{−3x}) − 6(Ae^{2x} + Be^{−3x}) = 0

4Ae^{2x} + 9Be^{−3x} + 2Ae^{2x} − 3Be^{−3x} − 6Ae^{2x} − 6Be^{−3x} = 0

4Ae^{2x} + 2Ae^{2x} − 6Ae^{2x}+ 9Be^{−3x}− 3Be^{−3x} − 6Be^{−3x} = 0

0 = 0

It worked!

## So, does this method work generally?

Well, yes and no. The answer to this question depends on the constants **p** and **q**.

With **y = e ^{rx}** as a solution of the differential equation:

\frac{d^{2}y}{dx^{2}} + p\frac{dy}{dx} + qy = 0

we get:

r^{2}e^{rx} + pre^{rx} + qe^{rx} = 0

e^{rx}(r^{2} + pr + q) = 0

r^{2} + pr + q = 0

This is a quadratic equation, and there can be three types of answer:

- two real roots
- one real root (i.e. both real roots are the same)
- two complex roots

How we solve it depends which type!

We can easily find which type by calculating the discriminant **p ^{2} − 4q**. When it is

- positive we get two real roots
- zero we get one real root
- negative we get two complex roots

## Two Real Roots

When the discriminant **p ^{2} − 4q** is

**positive**we can go straight from the differential equation

\frac{d^{2}y}{dx^{2}} + p\frac{dy}{dx} + qy = 0

through the "characteristic equation":

r^{2} + pr + q = 0

to the general solution with two real roots **r _{1}** and

**r**:

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

**Example 2:** Solve

\frac{d^{2}y}{dx^{2}} − 9\frac{dy}{dx} + 20y = 0

The characteristic equation is:

r^{2} − 9r** **+ 20 = 0

Factor:

(r − 4)(r − 5) = 0

r = 4 or 5

So the general solution of our differential equation is:

y = Ae^{4x} + Be^{5x}

And here are some sample values:

**Example 3:** Solve

6\frac{d^{2}y}{dx^{2}} + 5\frac{dy}{dx} − 6y = 0

The characteristic equation is:

6r^{2} + 5r** **− 6 = 0

Factor:

(3r − 2)(2r + 3) = 0

r = \frac{2}{3} or \frac{−3}{2}

So the general solution of our differential equation is:

y = Ae^{(23x)} + Be^{(−32x)}

**Example 4:** Solve

9\frac{d^{2}y}{dx^{2}} − 6\frac{dy}{dx} − y = 0

The characteristic equation is:

9r^{2} − 6r** **− 1 = 0

This does not factor easily, so we use the quadratic equation formula:

x = \frac{−b ± √(b^{2 }− 4ac)}{2a}

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

x = \frac{−(−6) ± √((−6)^{2 }− 4×9×(−1))}{2×9}

x = \frac{6 ± √(36^{ }+ 36)}{18}

x = \frac{6 ± 6√2}{18}

x = \frac{1 ± √2}{3}

So the general solution of the differential equation is

y = Ae^{(1 + √2 3)x} + Be^{(1 − √2 3)x}

## One Real Root

When the discriminant **p ^{2} − 4q** is

**zero**we get one real root (i.e. both real roots are equal).

Here are some examples:

**Example 5:** Solve

\frac{d^{2}y}{dx^{2}} − 10\frac{dy}{dx} + 25y = 0

The characteristic equation is:

r^{2} − 10r** **+ 25 = 0

Factor:

(r − 5)(r − 5) = 0

r = 5

So we have one solution: **y = e ^{5x}**

**BUT** when **e ^{5x}** is a solution, then

**xe**is

^{5x}**also**a solution!

Why? I can show you:

y = xe^{5x}

\frac{dy}{dx} = e^{5x} + 5xe^{5x}

\frac{d^{2}y}{dx^{2}} = 5e^{5x} + 5e^{5x} + 25xe^{5x}

So

\frac{d^{2}y}{dx^{2}} − 10\frac{dy}{dx} + 25y

= 5e^{5x} + 5e^{5x} + 25xe^{5x} − 10(e^{5x} + 5xe^{5x}) + 25xe^{5x}

= (5e^{5x} + 5e^{5x} − 10e^{5x}) + (25xe^{5x} − 50xe^{5x} + 25xe^{5x}) = 0

So, in this case our solution is:

y = Ae^{5x} + Bxe^{5x}

### How does this work in the general case?

With **y = xe ^{rx}** we get the derivatives:

- \frac{dy}{dx} = e
^{rx}+ rxe^{rx} - \frac{d^{2}y}{dx^{2}} = re
^{rx}+ re^{rx}+ r^{2}xe^{rx}

So

\frac{d^{2}y}{dx^{2}} + p \frac{dy}{dx} + qy

= (re^{rx} + re^{rx} + r^{2}xe^{rx}) + p( e^{rx} + rxe^{rx} ) + q( xe^{rx} )

= e^{rx}(r + r + r^{2}x + p + prx + qx)

= e^{rx}(2r + p + x(r^{2} + pr + q))

= e^{rx}(2r + p) because we already know that r^{2} + pr + q = 0

And when **r ^{2} + pr + q** has a repeated root, then

**r =**and

*−p*2**2r + p = 0**

So if r is a repeated root of the characteristic equation, then the general solution is

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

Let's try another example to see how quickly we can get a solution:

**Example 6:** Solve

4\frac{d^{2}y}{dx^{2}} + 4\frac{dy}{dx} + y = 0

The characteristic equation is:

4r^{2} + 4r** **+ 1 = 0

Then:

(2r + 1)^{2} = 0

r = −\frac{1}{2}

So the solution of the differential equation is:

y = Ae^{(−½)x} + Bxe^{(−½)x}

## Complex roots

When the discriminant **p ^{2} − 4q** is

**negative**we get complex roots.

Let’s try an example to help us work out how to do this type:

**Example 7:** Solve

\frac{d^{2}y}{dx^{2}} − 4\frac{dy}{dx} + 13y = 0

The characteristic equation is:

r^{2} − 4r** **+ 13 = 0

This does not factor, so we use the quadratic equation formula:

x = \frac{−b ± √(b^{2 }− 4ac)}{2a}

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

x = \frac{−(−4) ± √((−4)^{2 }− 4×1×13)}{2×1}

x = \frac{4 ± √(16^{ }− 52)}{2}

x = \frac{4 ± √(−36)}{2}

x = \frac{4 ± 6i}{2}

x = 2 ± 3i

If we follow the method used for two real roots, then we can try the solution:

y = Ae^{(2+3i)x} + Be^{(2−3i)x}

We can simplify this since e^{2x} is a common factor:

y = e^{2x}( Ae^{3ix} + Be^{−3ix} )

But we haven't finished yet ... !

Euler's formula tells us that:e^{ix} = cos(x) + i sin(x)

So now we can follow a whole new avenue to (eventually) make things simpler.

Looking just at the "A plus B" part:

Ae^{3ix} + Be^{−3ix}

A(cos(3x) + i sin(3x)) + B(cos(−3x) + i sin(−3x))

Acos(3x) + Bcos(−3x) + i(Asin(3x) + Bsin(−3x))

Now apply the Trigonometric Identities: cos(−θ)=cos(θ) and sin(−θ)=−sin(θ):

Acos(3x) + Bcos(3x) + i(Asin(3x) − Bsin(3x)

(A+B)cos(3x) + i(A−B)sin(3x)

Replace A+B by C, and A−B by D:

Ccos(3x) + iDsin(3x)

And we get the solution:

y = e^{2x}( Ccos(3x) + iDsin(3x) )

### Check

We have our answer, but maybe we should check that it does indeed satisfy the original equation:

y = e^{2x}( Ccos(3x) + iDsin(3x) )

\frac{dy}{dx} = e^{2x}( −3Csin(3x)+3iDcos(3x) ) + 2e^{2x}( Ccos(3x)+iDsin(3x) )

\frac{d^{2}y}{dx^{2}} = e^{2x}( −(6C+9iD)sin(3x) + (−9C+6iD)cos(3x)) + 2e^{2x}(2C+3iD)cos(3x) + (−3C+2iD)sin(3x) )

Substitute:

\frac{d^{2}y}{dx^{2}} − 4\frac{dy}{dx} + 13y = e^{2x}( −(6C+9iD)sin(3x) + (−9C+6iD)cos(3x)) + 2e^{2x}(2C+3iD)cos(3x) + (−3C+2iD)sin(3x) ) − 4( e^{2x}( −3Csin(3x)+3iDcos(3x) ) + 2e^{2x}( Ccos(3x)+iDsin(3x) ) ) + 13( e^{2x}(Ccos(3x) + iDsin(3x)) )

... hey, why don't YOU try adding up all the terms to see if they equal zero ... if not please let me know, OK?

### How do we generalize this?

Generally, when we solve the characteristic equation with complex roots, we will get two solutions **r _{1} = v + wi** and

**r**

_{2}= v − wiSo the general solution of the differential equation is

y = e^{vx} ( Ccos(wx) + iDsin(wx) )

**Example 8:** Solve

\frac{d^{2}y}{dx^{2}} − 6\frac{dy}{dx} + 25y = 0

The characteristic equation is:

r^{2} − 6r** **+ 25 = 0

Use the quadratic equation formula:

x = \frac{−b ± √(b^{2 }− 4ac)}{2a}

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

x = \frac{−(−6) ± √((−6)^{2 }− 4×1×25)}{2×1}

x = \frac{6 ± √(36^{ }− 100)}{2}

x = \frac{6 ± √(−64)}{2}

x = \frac{6 ± 8i}{2}

x = 3 ± 4i

And we get the solution:

y = e^{3x}(Ccos(4x) + iDsin(4x))

**Example 9:** Solve

9\frac{d^{2}y}{dx^{2}} + 12\frac{dy}{dx} + 29y = 0

The characteristic equation is:

9r^{2} + 12r** **+ 29 = 0

Use the quadratic equation formula:

x = \frac{−b ± √(b^{2 }− 4ac)}{2a}

with a = 9, b = 12 and c = 29

x = \frac{−12 ± √(12^{2 }− 4×9×29)}{2×9}

x = \frac{−12 ± √(144^{ }− 1044)}{18}

x = \frac{−12 ± √(−900)}{18}

x = \frac{−12 ± 30i}{18}

x = −\frac{2}{3} ± \frac{5}{3}i

And we get the solution:

y = e^{(−23)x}(Ccos(\frac{5}{3}x) + iDsin(\frac{5}{3}x))

## Summary

To solve a linear second order differential equation of the form

\frac{d^{2}y}{dx^{2}} + p\frac{dy}{dx} + qy = 0

where **p** and **q** are constants, we must find the roots of the characteristic equation

r^{2} + pr + q = 0

There are three cases, depending on the discriminant **p ^{2} - 4q**. When it 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) )