Higher Order ODEs

Kovalevskaya pic
Sofya Kovalevskaya.

Higher order ODEs: constant-coefficient linear homogeneous 2nd order

In this section we focus on a rather specific but extremely important class of differential equations: constant-coefficient linear homogeneous 2nd order ODEs. These can be put in the form

a y'' + b y' + c y = 0

where a, b, and c are constants and a \neq 0.

Our approach to the solution of these ODEs will use a new viewpoint that begins to leverage some of the power of linear algebra. In our chapter on matrix algebra we considered homogeneous linear systems of the form Ax = b, where A is a matrix and x and b are vectors (equivalently n by 1 matrices). We can think of the above class of ODEs as similar in structure by thinking of the multiplications and differentiations as entities in their own right, which operate on functions. That is, we write the ODE as

\mathcal L y = \left ( a \frac{d}{dx^2} + b \frac{d}{dx} + c \right ) y = 0

where \mathcal L is a linear differential operator. The term "operator" in this context means that \mathcal L is a function of functions - its domain is a set of functions, and its range is another set of functions.

Because differentiation is linear and commutes with multiplication by numbers (scalars), the algebra of constant-coefficient differential operators turns out to be equivalent to the familiar algebra of scalar unknowns. One consequence of this is that we can try to factor higher-order differential operators, and in the constant-coefficient case this is the same as factoring a polynomial. Because we are more comfortable with polynomials, we replace the differentiation operator \frac{d}{dx} with an arbitrary variable; we use r.

a \frac{d}{dx^2} + b \frac{d}{dx} + c \ \ \ \leftrightarrow \ \ \ a r^2 + b r + c

This polynomial a r^2 + b r + c is called the characteristic polynomial of the ODE. Using the quadratic equation we can solve for the roots r_1, r_2 of the characteristic polynomial. This is equivalent to factoring the differential operator:

\mathcal L = a \frac{d}{dx^2} + b \frac{d}{dx} + c = a (\frac{d}{dx} - r_1) (\frac{d}{dx} - r_2)

Now if we want to find solutions to \mathcal L y = 0 we can consider the factors of \mathcal L one at a time. The first order equation

(\frac{d}{dx} - r_1) y = y' - r_1 y = 0

has the exponential solution

y = C_i e^{r_i x}

Because the ODE is linear, this gives us the two parameter solution

y = C_1 e^{r_1 x} + C_2 e^{r_2 x}

If the roots r_1 and r_2 are real and distinct (i.e. r_1 \neq r_2) then this is the complete general (real) solution to the ODE. We know this from the following theorem:

Theorem: The dimension of the solution space to a linear ODE with constant coefficients is the order of ODE.

In fact a more general theorem is true, which we will call the Linear ODE Dimension Theorem:

A linear homogeneous nth order ODE

a_n(x) \frac{d^n y}{dx^n} + a_{n-1}(x) \frac{d^{n-1} y}{dx^{n-1}} + \ldots + a_1(x) \frac{d y}{dx} + a_0(x) y = 0

with coefficient functions a_i(x) that are continuous on an interval I and with a_n(x) \neq 0 on I has an n-dimensional space of solutions.

An equivalent statement is that with those conditions on the coefficient functions, the initial value problem y^{(n-1)}(a) = b_{n-1}, y^{(n-2)}(a) = b_{n-1}, \ldots, y(a) = b_0 has a unique solution defined on some interval J \subset I with a \in J.

In the constant coefficient case, the coefficient functions are infinitely differentiable on all of \mathbb{R}, so there is always an n-dimensional space of solutions. This means that if we can find n linearly independent solutions, we have found all of them (or more precisely a basis for all of the solutions).


Example: real and distinct roots

To solve the initial value problem

2 y'' + 3 y' - 2 y = 0, \ \ \ y(0) = -1, \ \ \ y'(0)=2

we first need to factor the characteristic polynomial 2 r^2 + 3 r - 2. Using the quadratic equation we get

r_1, r_2 = -\frac{3}{4} \pm \frac{\sqrt{9 + 16}}{4} = -2, 1/2

The general solution to the ODE is then

y = C_1 e^{-2x} + C_2 e^{x/2}

Now we can substitute in the initial conditions. For the y' condition we need to first compute the derivative:

y' = -2 C_1 e^{-2x} + C_2 e^{x/2}/2

Then

y(0) = -1 = C_1 + C_2

and

y'(0) = 2 = -2 C_1 + C_2/2

This system for C_1 and C_2 can be written in the augmented coefficient matrix form

\left(\begin{array}{rrr|r} 1 & 1 & -1 \\ -2 & \frac{1}{2} & 2 \end{array}\right)

We can reduce this by adding 2 times row 1 to row 2:

\left(\begin{array}{rrr|r} 1 & 1 & -1 \\ 0 & \frac{5}{2} & 0 \end{array}\right)

and now we see that C_2 must be zero. The reduced row echelon form of the augmented coefficient matrix is

\left(\begin{array}{rrr|r} 1 & 0 & -1 \\ 0 & 1 & 0 \end{array}\right)

So C_1 = -1 and the solution to the initial value problem is

y = - e^{-2x}

Exercises

  1. Find the general solution to y'' - y' - 20y = 0.

  2. Use the general solution to solve the initial value problem y(0) = 1, y'(0) = 1.

  3. Find a differential equation ay'' + b y' + c y = 0, where a, b, and c are constants, such that y = C_1 + C_2 e^x is the general solution.

Repeated and complex roots.

If the characteristic equation a r^2 + b r + c = 0 does not have distinct real roots we need to solve the ODE in a different way. There are two cases: there is a real double root, or there are two complex conjugate roots. These cases require different techniques.

Repeated Roots

When we have a repeated root

a r^2 + b r + c = a(r-r_1)^2

the exponential functions C_1 e^{r_1 x} still form half of the solution space basis; we need the other half. If we think in terms of the operator, it factors in the same way:

\mathcal{L} = a ( \frac{d}{dx} - r_1) ( \frac{d}{dx} - r_1)

A function can be annihilated by \mathcal{L} in two ways: (1) it can be immediately annihilated by the first factor, in which case it is of the form u_1(x) = C_1 e^{r_1 x}, or (2) it can be first transformed by the first factor into a function that is annihilated by the second factor. For this second type of function u_2(x), we would need

( \frac{d}{dx} - r_1) u_2 = u_1

Fortunately we know how to solve this - its a linear first order ODE. In terms of the integrating factor method, the coefficient function P(x) is -r_1, so the integrating factor R(x) = e^{\int P dx} = e^{-r_1 x}, and the general solution is

u_2 = C_1 e^{r_1 x} + e^{r_1 x} \int e^{- r_1 x} C_2 e^{r_1 x} dx = C_1 e^{r_1 x} + C_2 x e^{r_1 x}

However the first part of that solution is just u_1, which we already have. The new part is the function C_2 x e^{r_1 x}. In conclusion, when we have a repeated root r_1 for a second-order constant-coefficient linear homogeneous ODE, the general solution is

y = C_1 e^{r_1 x} + C_2 x e^{r_1 x}

Example of repeated roots

The simplest example of repeated roots is the ODE

y'' = 0

which has characteristic equation

r^2 = 0

This has a double root of r_1 = r_2 = 0. The solution is

y = C_1 e^{0 x} + C_2 e^{0 x} x = C_1 + C_2 x

In terms of the differential operator \frac{d^2}{d x^2}=\frac{d}{d x}\frac{d}{d x}, the solution C_1 is annihilated by just the first factor, while C_2 x is not - it is transformed into a constant, which is then annihilated by the second differentiation.


Complex Roots

If the characteristic equation a r^2 + b r + c = 0 has a negative discriminant b^2 - 4 a c, then the roots are two complex conjugate numbers:

r_1, r_2 = \frac{-b}{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a} = A \pm iB

where A = \frac{-b}{2a} is the real part of both roots and B = \frac{\sqrt{4ac - b^2}}{2a} is the imaginary part (plus or minus). Recall that the real and imaginary parts of a complex number are both real - the imaginary part is multiplied by \sqrt{-1} = i in the complete complex number.

The solution to the ODE we obtained before, C_1 e^{r_1 x} + C_2 e^{r_2 x}, does solve the ODE, but for complex roots r_1 and r_2 it is now a complex-valued function. If we are willing to use complex functions, then we could use complex scalars as well, so the general complex solution would be

y = Z_1 e^{r_1 x} + Z_2 e^{r_2 x}

where Z_1 and Z_2 are arbitrary complex constants.

Usually we do not want a complex solution to a real ODE, so we need to extract the real solutions that are contained inside the complex solution. We can do that by forming the real and imaginary parts of the complex solution. For any complex quantity Q, the real part is

Re(Q) = \frac{Q + \bar{Q}}{2}

and the imaginary part is

Im(Q) = \frac{Q - \bar{Q}}{2i}

From Euler's formula e^{i\theta} = \cos(\theta) + i \sin(\theta) we can split the part of the exponential with a purely imaginary argument into sines and cosines. If we choose Z_1 = C_1/2 - i C_2/2 and Z_2 = C_1/2 + iC_2/2, and our roots are r_1 = A + iB and r_2 = A - iB, then

y = C_1 e^{A x} \cos(B x) + C_2 e^{A x} \sin(B x)

Example: complex roots of the characteristic equation

We will solve the initial value problem

y'' + y' + y = 0, \ \ \ y(0) = 0, \ \ y'(0) = 1

First we compute the roots of the characteristic equation, r^2 + r + 1 = 0. Using the quadratic formula we find that

r_1, r_2 = -\frac{1}{2} \pm i \frac{\sqrt{3}}{2}

From this we can see that in our formula for the solution, A = -\frac{1}{2} and B = \frac{\sqrt{3}}{2}. We could choose the negative version of B, but this is more likely to lead to an error later on; we can always choose B \ge 0, and this is recommended. So the general solution is

y = C_1 e^{-x/2} \cos \left (\frac{\sqrt{3} x}{2} \right ) + C_2 e^{-x/2} \sin \left ( \frac{\sqrt{3} x}{2} \right )

Now we use the initial conditions to find C_1 and C_2. The initial condition y(0) = 0 gives us:

0 = C_1 + 0

since sin(0) = 0, so C_1 = 0. This simplifies things considerably - we now have to compute the derivative of y, but for this set of initial conditions we can ignore the first half of the function, and the remaining part of y' is

\frac{d}{dx} C_2 e^{-x/2} \sin \left ( \frac{\sqrt{3} x}{2} \right ) = C_2 e^{-x/2} \left [ - \frac{1}{2} \sin \left ( \frac{\sqrt{3} x}{2} \right ) + \frac{\sqrt{3}}{2} \cos \left ( \frac{\sqrt{3} x}{2} \right ) \right ]

so y'(0) = C_2 \frac{\sqrt{3}}{2} = 1, and C_2 = \frac{2}{\sqrt{3}}. The final answer to this problem is then:

y = \frac{2}{\sqrt{3}} e^{-x/2} \sin \left ( \frac{\sqrt{3} x}{2} \right )

This is a damped oscillation; a plot is shown below

y'' + y' + y = 0 plot
Solution to y'' + y' + y = 0.

Exercises

  1. Solve the initial value problem 4 y'' - 4 y' + 5 y = 0, y(0) = 1, y'(0) = 0.

  2. Solve the initial value problem 4 y'' + 4 y' + y = 0, y(0) = 0, y'(0) = 1.


Putting it all together

Euler's equation e^{it} = \cos(t) + i \sin(t) is surprising in showing how closely related exponential and trigonometric functions are. Another way to see some of this connection is to consider a family of differential equations that smoothly transitions from having exponential to trigonometric solutions:

y'' = k y

To examine this transition as k changes sign, let us consider two independent solutions to the ODE for each choice of k:

y_1(0) = 1, \ \ \ y_1'(0) = 0
y_2(0) = 0, \ \ \ y_2'(0) = 1

If k is positive, then the ODE has the general solution y = C_1 e^{\sqrt{k}x} + C_2 e^{-\sqrt{k}x} (the roots of the characteristic equation are real and distinct, r_1, r_2 = \pm \sqrt{k}). We can determine C_1 and C_2 for each of the two standardized solutions y_1 and y_2:

y_1 = \frac{e^{\sqrt{k} x} + e^{-\sqrt{k} x}}{2} = \cosh(\sqrt{k}x)
y_2 = \frac{e^{\sqrt{k} x} - e^{-\sqrt{k} x}}{2 \sqrt{k}} = \sinh(\sqrt{k}x)/\sqrt{k}

If k=0 we get the solution of the previous example, y = C_1 + C_2 x, and

y_1 = 1, \ \ \ y_2 = x

Finally, if k is negative the general solution is y = C_1 \cos(\sqrt{k}x) + C_2 \sin(\sqrt{k}x), and

y_1 = \cos(\sqrt{k}x)
y_2 = \sin(\sqrt{k}x)/\sqrt{k}

These are all shown below in an animation that transitions back and forth from k=-1 to k=1. The blue solution is y_1, and the red solution is y_2.

Second order ODE family
Transition from exponential to oscillatory behavior.

Nonhomogeneous linear ODEs and the method of undetermined coefficients

The constant-coefficient homogeneous ODEs from the previous section can be used to model autonomous systems that change according to their internal state. However, in most practical applications the system is affected by external forces or influences. Mathematically these external influences often appear as nonhomogeneous terms. Such second-order constant-coefficient ODEs are of the form:

y'' + b y' + c y = f(x)

in which we are using the independent variable x and the nonhomogeneous forcing term is f(x).

The linearity of these ODEs helps a great deal, because we can break our solution method into two steps:

y_h'' + b y_h' + c y_h = 0

For second-order ODEs this will be of the form y_h = C_1 y_1 + C_2 y_2.

For now we will consider a narrowly defined but extremely useful and common special class of functions f(x), which are formed from sums and products of exponential, trigonometric, and polynomial functions. These functions have the property that their derivatives are of the same form; more precisely for a particular f(x) of this form, the span of all of the derivatives \{f, f', f'', f''', f^{(4)}, \ldots \} is finite. This allows us to assume a form for the particular solution y_h to the ODE, and then determine the coefficients of the functions within that form.

Let us consider a couple of examples that illustrate this method.


Example: method of undetermined coefficients

Find the general solution to the ODE

y'' + y = 10e^{2x}

Our first step is to find the homogeneous solution y_h. We do this by finding the roots of the characteristic equation r^2 + 1 = 0. The roots are r_1, r_2 = \pm i; these purely imaginary roots correspond to a purely trigonometric solution

y_h = C_1 \cos(t) + C_2 \sin(t)

To determine the form of the particular solution it helps to notice that the span of the derivatives of f(x) = 10e^{2x} is simply multiples of e^{2x}. So if we assume that y_p = A e^{2x}, we can see if there is a constant A that solves the ODE. Substituting that into the ODE gives us:

4 A e^{2 x} + A e^{2 x} = 10e^{2x}

and since e^{2x} is never zero we can divide everything by it and ascertain that A=2.

The general solution is the sum of these:

y = y_h + y_p = C_1 \cos(t) + C_2 \sin(t) + 2 e^{2x}

The next example illustrates the fact that for a linear ODE and a nonhomogeneous term that is a sum of terms we can determine the particular solutions for each term separately.


Example: method of undetermined coefficients II

Find the general solution to the differential equation

y'' + 2y' + 2y = -2 x e^{-x} + 3 \cos(x)

First we find the homogeneous solution

y_h'' + 2 y_h' + 2 y_h = 0

by finding the roots of the characteristic equation

r^2 + 2 r + 2 = 0

Using the quadratic formula we find

r_1, r_2 = \frac{-2 \pm \sqrt{4 - 8}}{2} = -1 \pm i

so y_h = C_1 e^{-x} \cos(x) + C_2 e^{-x} \sin(x).

For the particular solution we must include the span of all derivatives of the functions x e^{-x} and \cos(x), so we try the form

y_p = A x e^{-x} + B e^{-x} + C \cos(x) + D \sin(x)

which has derivatives

y_p' = - A x e^{-x} + A e^{-x} - B e^{-x} - C \sin(x) + D \cos(x)
y_p'' = A x e^{-x} - 2 A e^{-x} + B e^{-x} - C \cos(x) - D \sin(x)

Substituting these into the left-hand side of the ODE (y_p'' + 2y_p' + 2y_p) we get

A x e^{-x} + B e^{-x} + (C+2D)\cos(x) + (-2C+D)\sin(x)

which must equal the right-hand side -2 x e^{-x} + 3 \cos(x). This gives us constraints

A = -2, \ \ B = 0, \ \ C + 2 D = 3, \ \ -2 C + D = 0

Notice that these are two separate systems of linear equations; we could determine the particular solution for -2 x e^{-x} and that for 3 \cos(x) and then add them together. The second system can be solved by substitution or by row-reduction:

\left ( \begin{array}{rr|r} 1 & 2 & 3 \\ -2 & 1 & 0 \end{array} \right ) \xrightarrow{ 2 R_1 + R_2} \left ( \begin{array}{rr|r} 1 & 2 & 3 \\ 0 & 5 & 6 \end{array} \right ) \xrightarrow{ -2 R_2/5 + R_1} \left ( \begin{array}{rr|r} 1 & 0 & 3/5 \\ 0 & 5 & 6 \end{array} \right ) \xrightarrow{ R_2/5} \left ( \begin{array}{rr|r} 1 & 0 & 3/5 \\ 0 & 1 & 6/5 \end{array} \right )

so the particular solution is

y_p = -2 x e^{-x} + 3 \cos(x)/5 + 6 \sin(x)/5

and the general solution is

y = y_h + y_p = C_1 e^{-x} \cos(x) + C_2 e^{-x} \sin(x) -2 x e^{-x} + 3 \cos(x)/5 + 6 \sin(x)/5

Exercise

Resonance; overlap issues with the particular solution.

We cannot always simply use a linear combination of all of the derivatives of f(x) to solve nonhomogeneous ODEs. There can be an overlap of f(x) with the solution of the homogeneous ODE, and in this case we must adjust the form of the particular solution. In the case of oscillatory solutions this phenomena is also known as resonance.

Let us start with a relatively simple example of this issue:


Example: Resonance/overlap

y''' = 3 + e^x

For f(x) = 3 + e^x, we would normally look for a particular solution of the form A + Be^x. The second part of this works fine: the third derivative of B e^x is just B e^x again, so B = 1. But the first part has a problem: the derivative of the constant A is zero, which means we cannot get a 3 on the right-hand side of the ODE by using a constant in y. There is an overlap with the homogeneous solution

y_h = C_1 + C_2 x + C_3 x^2

In other words, the operator \frac{d^3}{dx^3} annihilates any quadratic polynomial, so in order for the operator to produce a constant we must start with a cubic term. Using

y_p = A x^3 + B e^x

we have

y_p''' = 6 A + B e^x

which we want to equal 3 + e^x, so A = \frac{1}{2}. The general solution to the ODE is

y = y_h + y_p = C_1 + C_2 x + C_3 x^2 + \frac{1}{2} x^3 + e^x

In general, to find the correct form of the particular solution any components of the span of the derivatives of the nonhomogeneous term that overlap the homogeneous solution need to be multiplied by the smallest power of x (or whatever the independent variable is) that removes that overlap.

Here is another example of resonance/overlap:


Example: Resonance/overlap II

We will find the general solution to the ODE

y''' + y'' - y' - y = x e^{-x} + e^{2x}

The characteristic polynomial is

r^3 + r^2 - r - 1 = (r+1)^2 (r-1)

with a double root r_1,r_2 = -1 and another root r_3 = 1. So

y_h = C_1 e^{-x} + C_2 x e^{-x} + C_3 e^{x}

For the particular solution we would normally use

y_p = A x e^{-x} + B e^{-x} + C e^{2x} \ \ \ \text{(doesn't work!)}

but the first two terms are the same (up to a constant multiple) as the first two terms in y_h. So we must multiply them by x^2 to remove this overlap, yielding:

y_p = A x^3 e^{-x} + B x^2 e^{-x} + C e^{2x} \ \ \ \text{(correct)}

To find A, B, and C we must compute the first three derivatives

y_p' = -A x^{3} e^{-x} + 3 \, A x^{2} e^{-x} - B x^{2} e^{-x} + 2 \, B x e^{-x} + 2 \, C e^{2 x}
y_p'' = A x^{3} e^{-x} - 6 \, A x^{2} e^{-x} + B x^{2} e^{-x} + 6 \, A x e^{-x} - 4 \, B x e^{-x} + 2 \, B e^{-x} + 4 \, C e^{2 x}
y_p''' = -A x^{3} e^{-x} + 9 \, A x^{2} e^{-x} - B x^{2} e^{-x} - 18 \, A x e^{-x} + 6 \, B x e^{-x} + 6 \, A e^{-x} - 6 \, B e^{-x} + 8 \, C e^{2 x}

and substitute them into the left-hand side of the ODE (y''' + y'' - y' - y) to get the condition

-12 \, A x e^{- x} + 6 \, A e^{- x} - 4 \, B e^{- x} + 9 \, C e^{2 x} = x e^{-x} + e^{2x}

For this condition to be true we need -12 A = 1, 6 A - 4 B = 0, and 9 C = 1, so A = -1/12, B = -1/8, and C = 1/9.

So the general solution is

$$ y = y_h + y_p = C_1 x e^{-x} + C_2 e^ {-x} + C_3 e^{x} - x^3 e^ {-x}/12 - x^2 e^ {-x}/8 + e^{2 x}/9 $$


Exercise

  1. Solve the initial value problem y'' + y' = 2x - e^x, y(0)=0, y'(0) = 1.

Applications of 2nd order ODEs

Second order ODEs arise naturally in many physical applications, particularly in mechanical and electrial systems. In a mechanical setting the scalar 2nd-order constant-coefficient ODE is often written as

m x'' + c x' + k x = f(t)

where m is the mass of an object at position x, c is a linear damping (or friction) coefficient, and k is the spring constant. The kx term does not have to represent an actual spring, it can linearly approximate any restoring force. The nonhomogeneous term f(t) represents an external, possibly time-varying force on the object.

In this setting the parameters m, c, and k are almost always non-negative.

Similarly with electrical circuits the current I at a particular point can be modeled as

L I'' + R I' + \frac{1}{C} I = E(t)

where L is the overall inductance of the circuit, R is the resistance, and C is the capacitance. The equivalent of the mechanical external force, E(t), is the time derivative of the applied voltage (in some texts, the voltage is denoted by E, and then the right hand side would be E'(t)).

These two models are mathematically equivalent, and we will henceforth use the mechanical system notation.

Undamped and unforced oscillator

In many systems the damping coefficient c is quite small, and it is helpful to consider systems with c=0. If there are no external forces this gives us the ODE

m x'' + k x = 0

or equivalently

x'' + \frac{k}{m} x = 0

This has the characteristic equation r^2 + \frac{k}{m} = 0, with complex roots (we are assuming m and k are positive)

r_{1,2} = \pm i \sqrt{\frac{k}{m}} = \pm i w_0

It is convenient to use the new parameter w_0 = \sqrt{\frac{k}{m}} as it is the frequency of oscillation:

x(t) = C_1 \cos( w_0 t) + C_2 \sin( w_0 t ) = C \cos(w_0 t - \alpha)

In the above equation we have written the solution in two equivalent ways: as the sum of cosine and sine functions, and as a single phase-shifted cosine. The overall amplitude of the single cosine is

C = \sqrt{C_1^2 + C_2^2}

and the phase can be found from the relation

\tan(\alpha) = \frac{C_2}{C_1}

or \cot(\alpha) = \frac{C_1}{C_2} if C_1=0.

Undamped periodically forced oscillator

If an applied force is periodic in time it can be decomposed into a sum of sine and cosine functions. For simplicity we will only analyze a single cosine f(t) = F \cos(w t), in the system

m x'' + k x = F \cos(w t)

We have already found the homogeneous solution x_h = C \cos(w_0 t - \alpha) in the previous section, so we only need to compute a particular solution. With the method of undetermined coefficients we can try

x_p = A_1 \cos(w t) + A_2 \sin(w t)

with derivatives

x_p' = -w A_1 \sin(w t) + w A_2 \cos(w t)
x_p'' = - w^2 A_1 \cos(w t) - w^2 A_2 \sin(w t)

Substituting these expressions for x_p and x_p'' into the ODE, after grouping the sines and cosines together we get

(-m w^2 + k) A_1 \cos(w t) + (-m w^2 + k) A_2 \sin(w t) = F \cos(w t)

so A_2 = 0 and

A_1 = \frac{F}{-m w^2 + k} = \frac{F/m}{w_0^2 - w^2}

so the general solution is

x = C \cos(w_0 t - \alpha) + \frac{F/m}{w_0^2 - w^2} \cos(w t)

as long as w_0 \neq 0.

If w_0 = w, then the applied force is perfectly resonate with the natural frequency of the system. In this case we need to shift the particular solution to

x_p = t( A_1 \cos(w t) + A_2 \sin(w t))

and then (using the fact that -m w^2 + k = 0 since w_0 = w):

x_p'' = 2 A_2 w \cos(w t) - 2 A_1 w \sin(w t)

Plugging these into the ODE gives the condition

m 2 A_2 w \cos(w t) - m 2 A_1 w \sin(w t) = F \cos(w t)

Perhaps surprisingly this means that now A_1 = 0, and

A_2 = \frac{F}{2 m w_0}

so

x_p = \frac{F}{2 m w_0} t \sin(w_0 t)

and the solution linearly grows while oscillating.

Damped periodically forced oscillator

We now consider the damped periodically forced oscillator of the form

m x'' + c x' + k x = F \cos(w t)

where m, c, and k are positive parameters.

This is similar to the undamped analysis above, but with slightly more complicated algebra.

Because of the damping (c>0), the homogeneous solution x_h will always have an exponential decay. There are three cases for the form of x_h depending on the sign of the discriminant c^2 - km. If c^2 > km, then the ODE is called overdamped, and the characteristic equation has distinct real roots:

x_h = C_1 e^{r_1 t} + C_2 e^{r_2 t}

where

r_1, r_2 = -\frac{c \pm \sqrt{c^2 - 4km}}{2m}

Note that \sqrt{c^2 - 4km} < c, so these roots will always be negative; the homogeneous solution will decay to zero, and the particular solution will dominate the behavior. The particular solution is the same as the steady-state solution, which is the solution that all solutions approach as t increases.

Similarly in the critically damped case where c^2 = km we have a double root r_1 = -\frac{c}{2m} of the characteristic equation, and

x_h = C_1 e^{r_1 t} + C_2 t e^{r_1 t}

In this case if C_2 is nonzero the homogeneous solution will have transient increase in magnitude but eventually it will also decay to zero.

Finally, the underdamped case of c^2 < km has complex roots r_1, r_2 = -\frac{c}{2m} \pm i \frac{\sqrt{4 km - c^2}}{2m}, and

x_h = e^{-\frac{c}{2m} t} \left ( C_1 \cos(w_n t) + C_2 \sin(w_n t) \right )

where w_n = \frac{\sqrt{4 k m - c^2}}{2m}. If the damping coefficient c is very small compared to km then this frequency will be close to w_0 = \sqrt{k/m}.

In all of these cases the particular (and steady-state) solution x_p will be of the form

x_p = A \cos(w t) + B \sin(w t)

If we subsitute this into the ODE and equate the coefficients of \cos(w t) and \sin(w t) we get the system

(k - mw^2) A + c w B = F , \ \ -c w A + (k - m w^2) B = 0

which we can solve to get

A = \frac{(k - mw^2) F}{(k - mw^2)^2 + c^2 w^2}, \ \ \ B = \frac{c w F}{(k - mw^2)^2 + c^2 w^2}

Often it is more convenient to write the solution as a single trigonometric function with a phase angle:

x_p = A \cos(w t) + B \sin(w t) = C \cos(w t - \alpha)

In this form, C is the overall amplitude (mean-to-peak) and it is

C = \sqrt{A^2 + B^2} = \frac{F}{\sqrt{(k - mw^2)^2 + c^2 w^2}}

In terms of the undamped natural frequency w_0 = \sqrt{k/m} this looks like

C = \frac{F/m}{\sqrt{(w^2 - w_0^2)^2 + (c/m)^2 w^2}}

The phase angle satisfies the equation \tan(\alpha) = \frac{B}{A}. In taking the arctangent, there is an ambiguity of a factor of \pi since \tan(x + \pi) = \tan(x). To get the correct signs of A and B, the angle \alpha must be chosen in the interval [0, \pi) (so you have to be careful using the arctangent function on a calculator!). This means that the steady-state solution's phase is always behind that of the forcing function (e.g. the warmest month in the Northern hemisphere is August, even though the incoming solar radiation - the forcing - is at a maximum in June).

The amplitude function C for F=1, m=1, and k=1 is shown for a few values of the damping coefficient c as a function of the forcing frequency w.

resonance plot
Amplitude response of damped harmonic oscillator.

Exercises

  1. Consider the forced mass-spring system m x'' + c x' + k x = F_0 \cos( w t), which for c > 0 has the steady-state solution x_p = C(w) \cos(wt - \alpha), where the amplitude function is

    C(w) = \frac{F_0/m}{\sqrt{(w^2-w_0^2)^2 + (c/m)^2 w^2}}

    (in terms of the natural frequency w_0 = \sqrt{k/m}).

    a. For fixed m,c,k, and F_0, find the frequency w which maximizes the amplitude C(w). Hint: this is equivalent to finding the minimum of (w^2-w_0^2)^2 + c^2 w^2.

    b. For extra credit: Again for fixed m,c,k, and F_0, find the frequency w which maximizes the amplitude of the velocity of the steady-state solution (i.e. \displaystyle \frac{d x_p}{d t}). (Note that the square of the amplitude will have the same maximizing w.)

Beyond 2nd order

Fortunately (and surprisingly) we do not really need any additional mathematical tools to handle constant-coefficient linear ODEs that are more than 2nd order. This is related to the algebraic fact that the complex numbers are algebraically closed, meaning that any polynomial

a_n z^n + a_{n-1} z^{n-1} + \ldots + a_1 z + a_0 = 0

with complex coefficient a_i has a complex root - we do not need to extend the complex numbers in order to get a solution. This result is known as the fundamental theorem of algebra, proven by Gauss in 1799.

It does become more difficult to factor the characteristic polynomial. A famous result of Evariste Galois, Niels Henrik Abel, and Paolo Ruffini is that there is no elementary formula for the roots of polynomials of degree greater than 4. There are however very good algorithms for numerically finding the roots of a univariate polynomial.

resonance plot
Galois, Abel, and Ruffini.

Example: 4th order homogeneous ODE

Find the general solution to the fourth-order differential equation

y'''' + 4y = 0

The characteristic polynomial is r^4 + 4. To find the roots, it is convenient to think of the roots in complex polar form r = A e^{i \theta}. The roots are the four fourth-roots of 4. If we include the ambiguity of the angle \theta up to multiples of 2 \pi,

4 = 4 e^{i 2 \pi m}

then the four distinct fourth roots are \sqrt{2} e^{i \pi m/4} where m is one of 0, 1, 2, and 3. Using the fact that \cos(\pi/4) = \sin(\pi/4) = \sqrt{2}/2, the roots can be simplified to r_i = \pm 1 \pm i. The general solution is then

y = C_1 e^{-x} \cos(x) + C_2 e^{-x} \sin(x) + C_3 e^{x} \cos(x) + C_4 e^{x} \sin(x)

Variation of Parameters (Optional Extra Material)

Second-order ODEs

The homogeneous linear 2nd-order ODE

x_h'' + a_1(t) x_h' + a_0(t) x_h = 0

has two linearly independent solutions x_1(t) and x_2(t) (as long as the coefficient functions a_i are well behaved), so

x_h(t) = C_1 x_1(t) + C_2 x_2(t)

If x_1(t) and x_2(t) are known, then we can solve any non-homogeneous version of the ODE up to integration.

Lagrange pic
Joseph-Louis Lagrange

The particular solution to

x'' + a_1(t) x' + a_0(t) x = f(t)

can be written as

u_1(t) x_1(t) + u_2(t) x_2(t)

where

u_1 = \int \frac{x_2(t) f(t)}{x_2(t)x_1'(t) - x_1(t)x_2'(t)} dt
u_2 = \int \frac{x_1(t) f(t)}{x_1(t)x_2'(t) - x_2(t)x_1'(t)} dt

Letting the constants C_1 and C_2 from the homogeneous solution vary with t is what gives this method the name "Variation of Parameters". It was developed largely by the great 18th century mathematician Joseph-Louis Lagrange.


Example: Variation of Parameters

We will find the general solution to the ODE

x'' - x = \frac{2}{1 + e^t}

using the variation of parameters method. First we need the homogeneous solution. The characteristic equation is

r^2 - 1 = 0

which has real distinct roots r_1, r_2 = 1,-1, so

x_h = C_1 x_1 + C_2 x_2 = C_1 e^t + C_2 e^{-t}

Now we need to compute the integrals determining the functions u_1 and u_2. For many functions f(t) these integrals will not have a solution expressible in terms of elementary functions, but in this case it is possible, largely because the denominator x_2(t)x_1'(t) - x_1(t)x_2'(t) = 2 is a constant. The first integral is a little tricky:

u_1 = \int \frac{x_2(t) f(t)}{x_2(t)x_1'(t) - x_1(t)x_2'(t)} dt = \int \frac{2 e^{-t} }{(1 + e^t) (2)} dt

and now we need to use partial fractions and a u-substitution:

= \int \frac{1}{e^t (1 + e^t)} dt = \int e^{-t} dt - \int \frac{1}{(1 + e^t)} dt = -e^{-t} - \int \frac{e^{-t}}{(1 + e^{-t})} dt
= -e^{-t} + \log\left(e^{-t} + 1\right)

Yikes! The second integral is easier, just requiring the u-substitution u=e^t:

u_2 = \int \frac{x_1(t) f(t)}{x_1(t)x_2'(t) - x_2(t)x_1'(t)} dt = \int \frac{2 e^{t}}{(1 + e^t) (-2)} dt = - \log\left(e^{t} + 1\right)

So the general solution is

x = x_h + x_p = C_1 e^t + C_2 e^{-t} + (-e^{-t} + \log\left(e^{-t} + 1\right))e^t - \log\left(e^{t} + 1\right) e^{-t}
= C_1 e^t + C_2 e^{-t} + e^t \log\left(e^{-t} + 1\right) - e^{-t} \log\left(e^{t} + 1\right) - 1

Rewriting initial value problems as systems

Most numerical methods for ODEs are based upon first-order systems, so it is very important to be able to convert an nth order ODE into a system of n first-order ODEs. This can be done by introducing n-1 new variables that correspond to the derivatives of the original dependent variable.


Example: Rewriting a higher-order ODE as a system

Consider the 4th-order initial value problem:

2 y^{(4)} - 3 y''' + x y'' - y^2 = \cos(x)
y(0) = 1 \ \ y'(0) = 3 \ \ y''(0) = -1 \ \ y'''(0) = 5

To write this as a first order system we introduce new variables w_1 = y', w_2 = y'', w_3 = y'''. For consistency of notation we could also use w_0 = y. Then the original initial value problem is equivalent to

w_0' = w_1
w_1' = w_2
w_2' = w_3
w_3' = \frac{1}{2} \left ( 3w_3 - x w_2 + w_0^2 + \cos(x) \right )
w_0 = 1 \ \ w_1 = 3 \ \ w_2 = -1 \ \ w_3 = 5

  1. Rewrite the initial value problem y(0) =1, y'(0) = 2, y''(0) = 0, y''' +y'' - xy' = x as an equivalent first-order system.

  2. Note that this problem is unrelated to the previous one. Suppose a swinging door is damped so that angle of the door (relative to the wall its in) satisfies the differential equation:

    \theta'' + 2 \theta' + \theta = 0

    for 0 \le \theta \le \pi (derivatives are with respect to time t). Initially the door is open at an angle of \theta(0) = \pi/2. (a) Find the solution \theta(t), treating the initial velocity v_0 = \theta'(0) as a parameter. (b) If it is pushed shut with an initial velocity of \theta'(0) = v_0 < 0, for what values of v_0 will the door actually close completely (\theta=0) in finite time?

Additional Exercises

  1. Solve the initial value problem y'' - 4 y = 0, y(0) = 4, y'(0) = 2 given that y_1 = e^{2x} and y_2 = e^{-2x} are both solutions to the ODE.

  2. Find the general solution to y'' + 6y' = 0.

  3. Find the general solution to 4 y'' + 4 y' + y = 0.

  4. For what second-order constant coefficient linear homogeneous ODE would y = C_1 + C_2 x be the general solution?

  5. Show that the functions 3x, 2x^2, and 5x - 8x^2 are linearly dependent by finding a linear combination of them that equals zero.

  6. Find the general solution to y'' + 10y' + 25y = 0.

  7. Solve the initial value problem y'' - 6y' + 25y = 0, y(0) = 6, y'(0) = 2.

  8. Consider the differential equation y'' + sgn(x) y = 0, where sgn(x) is the sign function:

    sgn(x) = \left \{ \begin{array}{rr} 1 & \ \text{if } \ x > 0 \\ -1 & \ \text{if } \ x < 0 \\ 0 & \ \text{if } \ x = 0 \end{array} \right.

    Compute the two linearly independent solutions y_1 and y_2 of this differential equation which satisfy the initial conditions y_1(0) = 1, y_1'(0) = 0 and y_2(0) = 0, y_2'(0) = 1. (First solve the differential equation for x<0 and x>0, and then use the initial conditions to glue them together.)

  9. Find the general solution to y^{(4)} - 6y^{(3)} + 9y'' = 0.

  10. Find the general solution of 6 y^{(4)} + 5 y^{(3)} + 18 y'' + 20 y' - 24y = 0 given that y = \cos(2x) is a solution.

  11. Find a particular solution to the ODE y'' - y' + 2y = 4x + 12.

  12. Find a particular solution to the ODE y'' - y' + y = \sin^2(x). (Hint: it may be helpful to use a trig identity.)

  13. Find the general solution to y^{(3)} - y' = e^x.

    For the following two problems (6 and 7), determine the form of the particular solution - note that you do not have to determine the values of the coefficients. You should not include terms from the homogeneous (complementary) solution.

  14. Determine the form of the particular solution to y''' = 9x^2 + 1.

  15. Determine the form of the particular solution to y^{(4)} - 16y'' = x^2 \sin(4x) + \sin(4x).

  16. Solve the initial value problem y'' + 2y' + 2y = \cos(3x), y(0) = 0, y'(0) = 2.

  17. Solve the initial value problem y^{(4)} - y = 1, y(0) = y'(0) = y''(0) = y^{(3)} = 0.

  18. How many times can an overdamped mass-spring system (m x'' + c x' + k x = 0 with c^2 > 4mk; c, m, and k are non-negative) with arbitrary initial conditions x(0) = x_0, x'(0) = v_0 pass through x=0? What if it is critically damped (c^2 = 4mk)?

  19. Find the steady-state solution of the forced, damped oscillator x'' + x'/4 + 2x = 2 \cos(w t) if x(0) = 0 and x'(0) = 4. Sketch the overall amplitude of the steady-state solution as a function of w.

  20. Rewrite the second-order differential equation x'' + 3x' + 5x = t as a system of first-order differential equations. (You do not have to find the solution.)

    Notes

Notes: (Local storage in a cookie)

License

Creative Commons License


This work (text, mathematical images, and javascript applets) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Biographical images are from Wikipedia and have their own (similar) licenses.