9. Differential equations

Introduction


Differential equation is an equation containing an unknown function, e.g.   y = y(x)  , and its derivatives  y'(x), y''(x), \ldots, y^{(n)}(x) . This kind of equation where the unknown function depends on a single variable, is called an ordinary differential equation (ODE) or simply a differential equation. If the unknown function contains several variables, it is called partial differential equation, but they are not covered in this course.

A typical application leading to a differential equation is radioactive decay. If  y=y(t) is the number of radioactive nuclei present at time  t , then during a short time interval  \Delta t the change in this number is approximately  \Delta y \approx -k y(t)\cdot \Delta t, where  k is a positive constant depending on the radioactive substance. The approximation becomes better as  \Delta t \to 0, so that  y'(t) \approx \Delta y/\Delta t \approx -ky(t) . It follows that the differential equation  y'(t)=-ky(t) is a mathematical model for the radioactive decay. In reality, the number of nuclei is an integer, so the function  y(t) is not differentiable (or the derivative is mostly zero!). Therefore, the model describes the properties of some idealized smooth version of  y(t). This is a typical phenomenon in most models.

Order

The order of a differential equation is the highest order of the derivatives appearing in the equation.

For example, the order of the differential equation  y' + 3y = \sin(x) is 1. The order of the differential equation  y'' + 5y' -6y = e^x is 2.

Here the variable of the function y is not visible; the equation is considered to determine y implicitly.

Solutions of a differential equation

A differential equation of order n is of the form 

 \begin{equation} \label{dydef}
F(x, y(x), y'(x),\ldots , y^{(n)}(x)) = 0
\end{equation}

The solution to an ODE is an n times differentiable function y(x) satisfying the above equation for all  x \in I, where I is an open interval in the real axis.

Typically the solution is not unique and there can be an infinite number of solutions. Consider the equation  xy^2 + y' = 0. The equation has the solutions

  •  y_0(x) = 0,\enspace x \in \mathbb{R}
  •  y_1(x) = 2/x^2,\enspace x>0
  •  y_2(x) = 2/x^2,\enspace x
  •  y_3(x) = 2/(x^2 + 3),\enspace x \in \mathbb{R}

Here  y_1,  y_2 and  y_3  are called particular solutions. The general solution is  y(x) = 2/(x^2 + C),\> C \in \mathbb{R}. Particular solutions can be derived from the general solution by assigning the parameter c to some value. Solutions that cannot be derived from the general solution are called special solutions.

Differential equations do not necessarily have any solutions at all. For example, the first order differential equation  \sin(y' + y) = 2 does not have any solutions. If a first order equation can be written in normal form  y' = f(x,y) , where f is continuous, then a solution exists.

Initial condition

Constants in the general solution can be assigned to some values if the solution is required to satisfy additional properties. We may for example demand that the solution equals  y_0 at  x_0 by setting an initial condition  y(x_0) = y_0. With first order equations, only one condition is (usually) needed to make the solution unique. With second order equations, we need two conditions, respectively. In this case, the initial condition is of the form

 \left\{ \begin{array} 
yy(x_0) = y_0 \\ y'(x_0) = y_1 \end{array} \right.

In general, for an equation of order n, we need n extra conditions to make the solution unique. A differential equation and its set initial conditions are jointly referred as an initial value problem.

Example 1.

We saw above that the the general solution to the differential equation  xy^2 + y' = 0 is  y(x) = 2/(x^2 + C). Therefore the solution to the initial value problem

 \left\{\begin{align} xy^2 + y' = 0 \\ y(0) = 1 \end{align} \right.

is  y(x) = 2/(x^2 + 2).

Interactive. In the figure above, some of the solutions to the equation 

 xy^2 + y' = 0 are drawn. Try out and see how the initial condition alters the solution. The initial values can be changed by dragging the points. Is it possible to make the solution curves intersect?

Direction field

The differential equation  y' = f(x,y) can be interpreted geometrically: if the solution curve (i.e. graph of a solution) goes through the point  (x_0, y_0) , then it holds that  y'(x_0) = f(x_0, y_0) , i.e. we can find the slopes of the tangents of the curve even if we do not know the solution itself. Direction field or slope field is a vector field  \vec{i} + f(x_k, y_k)\vec{j} drawn through the points  (x_k, y_k). The direction field provides a fairly accurate image of the behavior of the solution curves.

Interactive. In the picture above we have drawn the direction field corresponding to the differential equation  y' = \sin(xy) . As shown here, an initial value often determines the solution also in the negative direction.

1st Order Ordinary Differential Equations


A manifesting problem in the theory of differential equations is that there is only a relatively small amount of methods for finding solutions that are generally applicable. Even for a fairly simple differential equation a generalized formula does not usually exist, and especially for higher order differential equations it is rare to be able to find an analytic solution. For some equations it is possible, however, and here some of the most common cases are introduced.

Linear 1st order ODE

If a differential equation is of the form

 p_n(x)y^{(n)} + p_{n-1}(x)y^{(n-1)} + \cdots + p_1(x)y' + p_0(x)y = r(x),

then it is called a linear differential equation. The left side of the equation is a linear combination of the derivatives with multipliers  p_k(x) . Thus a first order linear ODE is of the form

 p_1(x)y' + p_0(x)y = r(x). 

If  r(x) = 0 for all x, then the equation is called homogeneous. Otherwise the equation is nonhomogeneous.

Theorem 1.

Consider a normal form initial value problem 

 \left\{\begin{align}y^{(n)} + p_{n-1}(x)y^{(n-1)} + \cdots + p_1(x)y' + p_0(x)y = r(x) \\ y(x_0) = y_0, \: y'(x_0) = y_1, \: \ldots, \: y^{n-1}(x_0) = y_{n-1}. \end{align} \right.  

If the functions  p_k and  r are continuous in the interval  (a,b) containing the initial point x_0, then the initial value problem has a unique solution.

The condition concerning the normality of the equation is crucial. For example, the equation x^2y'' - 4xy' + 6y = 0 may have either zero or an infinite number of solutions depending on the initial condition: substituting  x=0 to the equation automatically forces the initial condition  y(0)=0.

Solving a 1st order linear ODE

A first order linear ODE can be solved by using an integrating factor method. The idea of the method is to multiply both sides of the equation  y' + p(x)y = r(x) by the integrating factor \displaystyle e^{\int p(x) dx} =e^{P(x)}, which allows the equation to be written in the form

 \displaystyle y'(x)e^{P(x)} + p(x)e^{P(x)}y(x) = r(x)e^{P(x)} \Leftrightarrow \frac{d}{dx}\left( y(x)e^{P(x)}\right) = r(x)e^{P(x)}.

Integrating both sides of the equation, we get

\displaystyle y(x)e^{P(x)} = \int r(x)e^{P(x)}\, \mathrm{d}x + C 
\Leftrightarrow y(x)= Ce^{-P(x)} + e^{-P(x)}\int r(x) e^{P(x)}\, \mathrm{d}x. 

It is not advisable to try to remember the formula as it is, but rather keep in mind the idea of how the equation should be modified in order to proceed.

Example 1.

Let us solve the differential equation \displaystyle y'-y = e^x+1. The integrating factor is \displaystyle e^{\int (-1)\, \mathrm{d}x} = e^{-x} so we multiply both sides by this expression:

\displaystyle e^{-x}y'-e^{-x}y = 1+e^{-x}

\displaystyle \frac{d}{dx}(y(x)e^{-x}) = 1+e^{-x}

\displaystyle y(x)e^{-x} = \int 1+e^{-x}\, \mathrm{d}x + C = x - e^{-x} + C

\displaystyle y(x)= e^xx - 1 + Ce^x.

Example 2.

Let us solve the initial value problem

 \left\{\begin{align}xy' = x^2 + 3y \\ y(0) = 1 \end{align} \right.

First, we want to express the problem in normal form:

 \displaystyle y' - \frac{3}{x}y = x.

Now the integrating factor is \displaystyle e^{ \int \frac{3}{x} dx } =\displaystyle e^{ -3 \ln \vert x \vert } =\displaystyle e^{ \ln x^{-3} } =\displaystyle \frac{1}{x^3},\> x>0. Hence, we get

\displaystyle \frac{y'}{x^3} - \frac{3}{x^4}y = \frac{1}{x^2}

\displaystyle \frac{d}{dx}(\frac{y}{x^3}) = \frac{1}{x^2}

\displaystyle \frac{y}{x^3} = \int \frac{1}{x^2}\, 
	\mathrm{d}x + C = - \frac{1}{x} + C

y = Cx^3 - x^2

We have found the general solution. Because  y(0) = C\cdot 0 - 0 = 0, that is, the value of the function does not equal the given initial value, the problem does not have a solution. The main reason for this is that the initial condition is given at  x_0=0, where the normal form of the equation is not defined. Any other choice for  x_0 will lead to a unique solution.

Example 3.

Let us solve the ODE xy'-2y=2 given the initial conditions

  1. y(1)=0
  2. y(0)=0.

From the form y'-(2/x)y=2/x we see that the equation in question is a linear ODE. The integrating factor is


e^{-\int (2/x)\, \mathrm{d}x} = e^{-2\ln |x|} = e^{\ln (1/x^2)} = \frac{1}{x^2}.

Multiplying by the integrating factor, we get


(1/x^2)y'(x)-(2/x^3)y(x) =\frac{2}{x^3} 
\Leftrightarrow 
\frac{d}{dx}\left( \frac{y(x)}{x^2}\right) = \frac{2}{x^3},

so the general solution to the ODE is y(x)=x^2 (-1/x^2+C)=Cx^2-1. From the initial value y(1)=0 it follows that C=1, but the other condition y(0)=0 leads to a contradiction -1=0. Therefore, the solution in the (a) part is y(x)=x^2-1, but a solution satisfying the initial condition of part b) does not exist: by substituting  x=0 , the equation forces  y(0)=-1.

Separable equation

A first order differential equation is separable, if it can be written in the form  y' = f(x)g(y),  where f and g are integrable functions in the domain of interest. Treating formally  y'(x)=dy/dx as a fraction, multiplying by  dx and dividing by  g(y), we obtain  \frac{dy}{g(y)}=f(x)\, dx. Integrating the left hand side with respect to  y and the right hand side with respect to  x, we get

\displaystyle \int \frac{\mathrm{d}y}{g(y)} = \int f(x)\, \mathrm{d}x + C

This method gives the solution to the differential equation in implicit form, which we may further be able to solve explicitly for y =y(x). The justification for this formal treatment can be made by using change of variables in integrals.

Example 4.

Let us solve the differential equation \displaystyle y'+\frac{2}{5}x = 0 by separating the variables. (We could also solve the equation by using the method of integrating factors.)

 \displaystyle y'+\frac{2}{5}y = 0

 \displaystyle \frac{dy}{dx} = -\frac{2}{5}y   

 \displaystyle \int \frac{1}{y}\, \mathrm{d}y = -\frac{2}{5} \int \, \mathrm{d}x   

\displaystyle \ln |y| = -\frac{2}{5}x + C_1

 \displaystyle y =\pm e^{-\frac{2}{5}x+C_1} = \pm e^{-\frac{2}{5}x}e^{C_1} = Ce^{-\frac{2}{5}x}, \: C\neq 0.

In the last step, we wrote C =\pm e^{C_1} for simplicity. The case  C=0 is also allowed, since it leads to the trivial solution y(x)\equiv 0, see below.

Example 5.

Let us solve the initial value problem

 \left\{\begin{align}y' = \frac{x}{y} \\ y(0) = 1 \end{align} \right.

Because the general solution is not required, we may take a little shortcut by applying integrals in the following way:

\displaystyle \frac{dy}{dx} = \frac{x}{y}

\displaystyle \int_1^y y \, \mathrm{d}y =\int_0^x x \, \mathrm{d}x

\displaystyle \frac{1}{2}y^2 - \frac{1}{2} =\frac{1}{2}x^2

The solution is  y=y(x)=\sqrt{x^2+1}.

The trivial solutions of a separable ODE

General solution achieved by applying the method for separable functions typically lacks information about solutions related to the zeros of the function g(y). The reason for this is that in the separation method we need to assume that g(y(x)) \neq 0 in order to be able to divide the expression by g(y(x)). We notice that for each zero \alpha of the function g there exists a corresponding constant solution y(x)\equiv \alpha of the ODE y'=f(x)g(y), since y'(x)\equiv 0=g(\alpha)\equiv g(y(x)). These solutions are called trivial solutions (in contrast to the general solution).

If the conditions of the following theorem hold, then all the solutions to a separable differential equation can be derived from either the general solution or the trivial solutions.

Theorem 2.

Let us consider the initial value problem y'=f(x,y),\ y(x_0)=y_0.

  1. If f is continuous (as a function of two variables), then there exists at least one solution in some interval containing the point x_0.
  2. Also, if f is continuously differentiable with respect to y, then the solution satisfying the initial condition is unique.
  3. The uniqueness also holds, when in addition to (i) the function f is continuously differentiable with respect to x and f(x_0,y_0)\neq 0.

The proof of the theorem is based on a technique known as Picard-Lindelöf iteration, which was invented by Emile Picard and further developed by the Finnish mathematician Ernst Lindelöf (1870-1946), and others.

Applying the previous theorem, we can formulate the following result for separable equations.

Theorem 3.

Let us consider a separable differential equation y'=f(x)g(y), where f is continuous and g is continuously differentiable.

  1. For each zero \alpha of the function g there exists a trivial solution y(x)\equiv \alpha = constant.
  2. All other solutions (= the general solution) can be obtained by applying the previously described method, i.e. separating the variables and calculating the integrals.

The solution curves at each point (x_0,y_0) of the domain of the equation are always unique. In particular, the curves cannot intersect and it is not possible for a single curve to split into two or several parts.

∴ The other solution curves of the ODE cannot intersect the curves y=\alpha corresponding to the trivial solutions. That is, for all the other solutions the condition g(y(x))\neq 0 automatically holds!

Example 6.

Let us solve the linear homogeneous differential equation y'+p(x)y=0 by applying the method of separation.

The equation has the trivial solution y_0(x)\equiv 0. Since the other solutions do not get the value 0 anywhere, it holds that

\begin{aligned}
		\frac{dy}{dx} &= y'= -p(x)y \\
		&\Leftrightarrow \int\frac{\mathrm{d}y}{y}  =  -\int p(x)\, \mathrm{d}x +C_1 \\
		&\Leftrightarrow \ln|y| = -P(x)+C_1 \\
		&\Leftrightarrow |y| =e^{C_1-P(x)} \\
		&\Leftrightarrow y=y(x)=\pm e^{C_1} e^{-P(x)} =Ce^{-P(x)}.\end{aligned}

Here, the expression \pm e^{C_1} has been replaced by a simpler constant C\in\mathbb{R}.

\star Equations expressible as separable

Some differential equations can made separable by using a suitable substitution.

i) ODEs of the form  y'(x)= f\Big(\frac{y(x)}{x}\Big).
Example 7.

Let us solve the differential equation  y'= \frac{x+y}{x-y}. The equation is not separable in this form, but we can make if separable by substituting  u = \frac{y}{x}, resulting to  y' = u + xu'. We get

  u + xu'= \displaystyle \frac{1+u}{1-u}.  

Separating the variables and integrating both sides, we get

  \displaystyle \int \frac{1-u}{1+u^2} \, \mathrm{d}u= \int \frac{1}{x} \, \mathrm{d}x

   \arctan{u} 
	- \displaystyle \frac{1}{2} \ln(u^2 +1)= \ln{x} + C.

Substituting   u = \frac{y}{x} and simplifying yields

   \displaystyle \arctan{\frac{y}{x}} = \ln{C\sqrt{x^2 + y^2}}.

Here, it is not possible to derive an expression for y so we have to make do with just the implicit solution. The solutions can be visualized graphically: 

As we can see, the solutions are spirals expanding in the positive direction that are suitably cut for demonstration purposes. This is clear from the solutions' polar coordinate representation which we obtain by using the substitution

\theta = \displaystyle \arctan{\frac{y}{x}}, r = \sqrt{x^2 + y^2}.

Hence, the solution is

\theta = \ln(Cr) \Leftrightarrow r = Ce^{\theta}.

ii) ODEs of the form \displaystyle y' = f(ax+by+c) 

Another type of differential equation that can be made separable are equations of the form 

\displaystyle y' = f(ax+by+c).

To rewrite the equation as separable, we use the substitution  \displaystyle u = ax+by+c.

Example 8.

Let us find the solution to the differential equation

\displaystyle y' =(x-y)^2 +1.

Here, a natural substitution is \displaystyle u = x-y \Leftrightarrow y = x-u \Rightarrow y' = 1-u'. Substitution yields

 \displaystyle 1-u' =u^2 +1

 \displaystyle \int -\frac{1}{u^2} \, \mathrm{d}u = \int \, \mathrm{d}x

 \displaystyle \frac{1}{u} = x +C

 \displaystyle y = x -  \frac{1}{x +C}.

\star Euler's method

In practice, it is usually not feasible to find analytical solutions to differential equations. In these cases, the only choice for us is to resort to numerical methods. A prominent example of this kind of technique is called Euler's method. The idea behind the method is the observation made earlier with direction fields: even if we do not know the solution itself, we are still able to determine the tangents of the solution curve. In other words, we are seeking solutions for the initial value problem

 \left\{\begin{align}y' = f(x,y) \\ y(x_0) = y_0. \end{align} \right.

In Euler's method, we begin the solving process by choosing the step length  h and using the iteration formula

 \displaystyle y_{k+1} = y_k +  hf(x_k, y_k).

The iteration starts from the index  \displaystyle k=0 by substituting the given initial value to the right side of the iteration formula. Since f(x_k, y_k) = y'(x_k) is the slope of the tangent of the solution at x_k , on each step we move the distance expressed by the step length in the direction of the tangent. Because of this, an error occurs, which grows as the step length is increased.

Example 9.

Use the gadget on the right to examine the solution to the initial value problem

 \left\{\begin{align}y' = \sin(xy) \\ y(x_{0}) = y_{0} \end{align} \right.

obtained by using Euler's method and compare the result to the precise solution.

Interactive. The equation y'=\sin(xy) with the initial condition y(x_{0})=y_{0}. The precise solution is drawn blue while the solution obtained using Euler's method with N number of steps is drawn purple.

2nd and higher order ODEs


For higher order differential equations it is often impossible to find analytical solutions. In this section, we introduce some special cases for which analytical solutions can be found. Most of these cases are linear differential equations. Our focus is on second order differential equations, as they are more common in practical applications and for them it is more likely for an analytical solution to be found, compared to third or higher order differential equations.

Solving a homogeneous ODE

For second order linear equations, there is no easy way to find a general solution. We begin by examining a homogeneous equation

 y’’ + p(x)y’ + q(x)y = 0,

where p and q are continuous functions on their domains. Then, it holds that

1) the equation has linearly independent solutions y_1 and y_2, called fundamental solutions. Roughly speaking, linear independence means that the ratio y_2(x)/y_1(x) is not constant, so that the solutions are essentially different from each other.

2) the general solution can expressed by means of any linearly independent pair of solutions in the form y(x) = C_1y_1(x) + C_2y_2(x) , where  C_1 and  C_2 are constants.

3) if the initial values y(x_0) = a, y'(x_0) = b are fixed, then the solution is unique.

A general method for finding explicitly the fundamental solutions y_1(x) and y_2(x) does not exist. To find the solution, a typical approach is to try to make an educated guess about the solution's form and check the details by substituting this into the equation.

The above results can be generalized to higher order homogeneous equations as well, but then the number of required fundamental solutions and initial conditions increases with respect to the order of the equation.

Example 1.

The equation  y’’-y= 0 has solutions  y = e^x and  y = e^{-x}. These solutions are linearly independent, so the general solution is of the form  y(x) = C_1e^x + C_2e^{-x}.

Equations with constant coefficients

As a relatively simple special case, let us consider the 2nd order equation

 y’’ + py’ + qy = 0.

In order to solve the equation, we use the guess  y(x) = e^{\lambda x}, where  \lambda is an unknown constant. Substituting the guess into the equation yields

 \lambda^2 e^{\lambda x} + p\lambda e^{\lambda x} + qe^{\lambda x} = 0.

 \lambda^2 + p\lambda + q = 0.

The last equation is called the characteristic equation of the ODE. Solving the characteristic equation allows us to find the solutions for the actual ODE. The roots of the characteristic equation can be divided into three cases:

1) The characteristic equation has two distinct real roots. Then, the ODE has the solutions y_1(x) = e^{\lambda_1x} and y_2(x) = e^{\lambda_2x}.

2) The characteristic equation has a double root. Then, the ODE has the solutions y_1(x) = e^{\lambda x} and y_2(x) = xe^{\lambda x}.

3) The roots of the characteristic equation are of the form \lambda = a \pm bi. Then, the ODE has the solutions y_1(x) = e^{ax}\cos(bx) and y_2(x) = e^{ax}\sin(bx).

The second case can be justified by substitution into the original ODE, and the third case by using the Euler formula  e^{ix}=\cos x+i\sin x. With minor changes, these results can also be generalized to higher order differential equations.

Since the characteristic equation has exactly the same coefficients as the original ODE, it is not necessary to derive it again in concrete examples: just write it down by looking at the ODE!

Example 2.

Let us solve the initial value problem

 \left\{\begin{align}y'' -y' +2y=0 \\ y(0) = 1, y(1)=0 \end{align} \right.

The characteristic equation is \lambda^2 -\lambda -2 = 0, which has the roots  \lambda_1 = 2 and  \lambda_2 = -1. Thus, the general solution is  y(x) = C_1e^{2x} + C_2e^{-x}. The constants can be determined by using the initial conditions:

 \left\{\begin{align}C_1 + C_2=1 \\ e^2C_1 + e^{-1}C_2 = 0 \end{align} \right.

 \left\{\begin{align}C_1 = -\frac{1}{e^3-1} \\ C_2 = \frac{e^3}{e^3-1} \end{align} \right.

Hence, the general solution is  y(x) = \frac{1}{e^3-1} (-e^{2x} + e^{3-x}).

Example 3.

Let us have a look at how the above results hold in higher order equations by solving

 y^{(4)} - 4y''' +14y'' -20y' +25y = 0.

Now, the characteristic equation is  \lambda^4 - 4\lambda^3 +14\lambda^2 -20\lambda +25 = 0, which has the roots  \lambda_1 = \lambda_2 = 1 + 2i and  \lambda_3 = \lambda_4 = 1 - 2i. Thus, the fundamental solutions to the ODE are e^x\sin(2x)e^x\cos(2x)xe^x\sin(2x) and xe^x\cos(2x). The general solution is

 y = C_1e^x\sin(2x) + C_2e^x\cos(2x) + C_3xe^x\sin(2x) + C_4xe^x\cos(2x).

Example 4.

Let  \omega >0 be a constant. The characteristic equation of the ODE 
	y''+\omega^2y=0
	is  \lambda^2+\omega^2=0 with roots  \lambda=\pm i \omega. So  \alpha =0 and  \beta =\omega in Case 3). Since this ODE is a model for harmonic oscillation, we use time  t as variable, and obtain the general solution 
	y(t)=A\cos (\omega t) +B\sin (\omega t),
	with  A,B constants. They will be uniquely determined if we know the initial location y(0) and the initial velocity y'(0). All solutions are periodic and their period is T=2\pi/\omega. In the animation to the right we have  y'(0)=0 and you can choose  \omega and the initial displacement  y(0)=y_0.

Interactive. Harmonic oscillator y(t) = y_{0}\cos(\omega t),
where t is the elapsed time in seconds

Euler's differential equation

Another relatively common type of 2nd order differential equation is Euler's differential equation

 x^2y'' + axy' + by = 0,

where a and b are constants. An equation of this form is solved by using the guess y(x)= x^r. Substituting the guess in the equation yields

 r^2 + (a-1)r + b = 0.

Using the roots of this equation, we obtain the solutions for the ODE in the following way:

1) If the roots are distinct and real, then  y_1(x)= |x|^{r_1} and  y_2(x)= |x|^{r_2}.

2) If the equation has a double root, then  y_1(x)= |x|^{r} and  y_2(x)= |x|^{r}\ln |x|.

3) If the equation has roots of the form r = a \pm bi, then  y_1(x)= |x|^{a}\cos(b\ln |x|) and  y_2(x)= |x|^{a}\sin(b\ln |x|).

Example 5.

Let us solve the equation  x^2y'' - 3xy' + y = 0. Noticing that the equation is Euler's differential equation, we proceed by using the guess y= x^r. Substituting the guess into the equation, we get  r(r-1)x^r - 3rx^r + x^r = 0 \Rightarrow r^2 - 4r + 1 = 0, which yields  r = 2 \pm \sqrt{3}. Therefore, the general solution to the ODE is

y = C_1 x^{2+\sqrt{3}} + C_2x^{2-\sqrt{3}}.

Nonhomogeneous linear differential equations

The general solution to a nonhomogeneous equation

y'' + p(x)y' + q(x)y = r(x)

is the general solution to the corresponding homogeneous equation + particular solution to the nonhomogeneous equation, i.e.

y(x) = C_1y_1(x) + C_2y_2(x) + y_0(x).

The particular solution y_0 is usually found by using a guess that is of the same form as r(x) with general coefficients. Substituting the guess into the ODE, we can solve these coefficients, but only if the guess is of the correct form.

In the table below, we have created a list of possible guesses for second order differential equations with constant coefficients. The form of the guess depends on what kind of elementary functions r(x) consists of. If r(x) is a combination of several different elementary functions, then we need to include corresponding elements for all of these functions in our guess. The characteristic equation of the corresponding homogeneous differential equation is P(\lambda)=\lambda^2+p\lambda+q=0.

r(x) contains
the guess consists of
nth degree polynomial
A_0+A_1x+\dots +A_nx^n ( +A_{n+1}x^{n+1}, if q=P(0)=0)
\sin kx,\ \cos kx
A\cos kx+B\sin kx, if P(ik)\neq 0
\sin kx,\ \cos kx Ax\cos kx+Bx\sin kx, if P(ik)=0
e^{cx}\sin kx,\ e^{cx}\cos kx Ae^{cx}\cos kx+Be^{cx}\sin kx, if P(c+ik)\neq 0
e^{kx} Ae^{kx}, if P(k)\neq 0
e^{kx} Axe^{kx}, if P(k)=0 and P'(k)\neq 0
e^{kx} Ax^2e^{kx}, if P(k)=P'(k)=0

Note. For roots of a second degree polynomial we have to keep in mind that

  • P(k)=0 and P'(k)\neq 0 \Leftrightarrow k\in\mathbb{R} is a simple root of P.

  • P(k)=P'(k)= 0 \Leftrightarrow k\in\mathbb{R} is a double root of P.

  • P(ik)\neq 0 \Leftrightarrow ik\in\mathbb{C} is not a root of P; i.e. \sin kx and \cos kx are not solutions to the homogeneous equation.

Example 6.

Let us find the general solution to the ODE y''+y'-6y=r(x), when

a) r(x)=12e^{-x}

b) r(x)=20e^{2x}.

The solutions are of the form y(x)=C_1e^{-3x}+C_2e^{2x}+y_0(x).

a) Substituting the guess y_0(x)=Ae^{-x}, we get (A -A -6A)e^{-x} =12e^{-x}, which solves for A=-2.

b) In this case a guess of the form Be^{2x} is useless, as it is part of the general solution to the corresponding homogeneous equation and yields just zero when substituted to the left side of the ODE. Here, a right guess is of the form y_0(x)=Bxe^{2x}. Substitution yields


(4B+2B-6B)xe^{2x}+(4B+B)e^{2x} = 20e^{2x},

which solves for B=4.

Using these values for A and B, we can write the general solutions to the given differential equations.

Example 7.

Let us find the solution to the ODE y''+y'-6y=12e^{-x} with the initial conditions y(0)=0, y'(0)=6.

Based on the previous example, the general solution is of the form y(x)=C_1e^{-3x}+C_2e^{2x}-2e^{-x}. Differentiation yields y'(x)=-3C_1e^{-3x}+2C_2e^{2x}+2e^{-x}. From the initial conditions, we get the following pair of equations:


\begin{cases}
0=y(0)=C_1+C_2-2 &\\
6=y'(0)=-3C_1+2C_2+2, &\\
\end{cases}

which solves for C_1=0 and C_2=2. Therefore, the solution to the initial value problem is y(x)=2e^{2x}-2e^{-x}.

Example 8.

A typical application of a second order nonhomogeneous ODE is an RLC circuit containing a resistor (with resistance  R), an inductor (with inductance  L ), a capacitor (with capacitance  C ), and a time-dependent electromotive force  E(t). The electric current  y(t) in the circuit satisfies the ODE  Ly''+Ry'+\frac{1}{C}y=E'(t). Let us solve this ODE with artificially chosen numerical values in the form  y''+10y'+61y=370\sin t.

The homogeneous part has characteristic equation of the form  \lambda^2+10\lambda +61=0 with solutions  \lambda = -5\pm 6i. This gives the solutions  y_1(t)=e^{-5t}\cos(6t) and  y_2(t)=e^{-5t}\sin(6t) for the homogeneous equation. For a particular solution we try y_0(t)=A\cos t +B\sin t. Substituting this into the nonhomogeneous ODE and collecting similar terms yields to  (60A+10B)\cos t +(60B-10A)\sin t = 370\sin t. This equation will be satisfied for all  t (only) if


\begin{cases}
60A+10B=0 &\\
-10A+60B=370. &\\
\end{cases}

which solves for  A=-1 and  B=6. Therefore, the general solution is   y(t)=e^{-5t}(C_1\cos(6t)+C_2\sin(6t)) -\cos t+6\sin t . Note. The exponential terms go to zero very fast and eventually, the current oscillates in the form  y(t)\approx -\cos t+6\sin t.

'); }],{ anchor : p1, anchorY : 'auto', fixed : true, parse : false, fontSize : 16, useMathJax : true }); var x0 = board.getBoundingBox()[0]; var x1 = board.getBoundingBox()[2]; var y0 = board.getBoundingBox()[3]; var y1 = board.getBoundingBox()[1]; var dy = function(x,y) { return Math.sin(x*y); } var f = function(x,yy) { return [dy(x,yy[0])]; } var ode = function() { var data = JXG.Math.Numerics.rungeKutta('euler', [p1.Y()], [p1.X(), x0], 201*(p1.X()-x0)/(x1-x0), f); data = data.reverse(); data = data.slice(0, -1); data = data.concat(JXG.Math.Numerics.rungeKutta('euler', [p1.Y()], [p1.X(), x1], 201*(x1-p1.X())/(x1-x0), f)); return data; } var graph = board.create('curve', [[0],[0]], { strokeColor : '#bd3fe0', strokeWidth : 2 }); graph.updateDataArray = function() { var data = ode(); var h = (x1-x0)/data.length; for(var i=0; i < data.length; i++) { graph.dataX[i] = x0+i*h; graph.dataY[i] = data[i][0]; } }; var slopes = []; var slopefield = function() { for(var x=x0; x<=x1; x=x+0.4){ for(var y=y0; y<=y1; y=y+0.4){ var k = dy(x,y); var length = 3*(2*Math.sqrt(1+k*k)); slopes.push(board.create('arrow', [ [x-1/length,y-k/length], [x+1/length, y+k/length] ],{ fixed : true, highlight : false, strokeOpacity : 0.55, strokeWidth : 1, strokeColor : '#2659f0' })); var yy = slopes[slopes.length-1].point1.Y() if(yy == 0){ slopes[slopes.length-1].setAttribute( { strokeColor : '#18d3af' }); } } } } slopefield(); board.fullUpdate(); })();
'); }],{ anchor : point, anchorY : 'auto', fixed : true, parse : false, fontSize : 16 })); board.create('functiongraph',[function(x) { return g(point,x); },x0,x1],{ strokeWidth : 3, strokeColor : color }); } for(var i=0;i
'); }],{ anchor : p1, anchorY : 'auto', fixed : true, parse : false, fontSize : 16 })); var stepNum = board.create('slider', [[1, 4],[4, 4],[1, 5, 25]],{ name : ' N', snapWidth : 1, precision : 0, fillColor : '#bd59ff', size : 8, withTicks : false, baseline : { strokeWidth : 2 }, highline : { strokeWidth : 4 }, label : { fontSize : 14 } }); /*var numTicks = board.create('ticks', [stepNum.baseline], { ticksDistance : 3/5, minorTicks : 0, majorHeight : 1 });*/ var x0 = board.getBoundingBox()[0]; var x1 = board.getBoundingBox()[2]; var y0 = board.getBoundingBox()[3]; var y1 = board.getBoundingBox()[1]; var dy = function(x,y) { return Math.sin(x*y); } var f = function(x,yy) { return [dy(x,yy[0])]; } var ode = function(interval, steps) { data = JXG.Math.Numerics.rungeKutta('euler', [p1.Y()], [p1.X(), interval], steps, f); return data; } var graph = board.create('curve', [[0],[0]], { strokeColor : '#4287f5', strokeWidth : 3, strokeOpacity : 0.5, dash : 2 }); graph.updateDataArray = function() { var data = ode(x0, 201*(p1.X()-x0)/(x1-x0)); data = data.reverse(); data = data.slice(0, -1); data = data.concat(ode(x1, 201*(x1-p1.X())/(x1-x0))); var h = (x1-x0)/data.length; graph.dataX = []; graph.dataY = []; for(var i=0; i < data.length; i++) { graph.dataX[i] = x0+i*h; graph.dataY[i] = data[i][0]; } }; var approx = board.create('curve', [[0],[0]], { strokeColor : '#bd59ff', strokeWidth : 3 }); approx.updateDataArray = function() { var n = stepNum.Value()+1; var h = a/(n-1); var data = ode(p1.X()+a, n); approx.dataX = []; approx.dataY = []; for(var i=0; i < n; i++) { approx.dataX[i] = p1.X()+i*h; approx.dataY[i] = data[i][0]; } p2.moveTo([approx.dataX[n-1],approx.dataY[n-1]]); }; coords.push(board.create('text',[0,0, function(){ return ('
~(x_{' + stepNum.Value() + '}, y_{' + stepNum.Value() + '})~
'); }],{ anchor : p2, anchorY : 'auto', fixed : true, parse : false, fontSize : 16 })); board.create('line',[[function(){ return p1.X(); },0],[function(){ return p1.X(); },function(){ return p1.Y(); }]],{ dash : 4, StrokeOpacity : 0.5, strokeColor : '#000000' }); board.create('line',[[function(){ return p1.X()+a; },0],[function(){ return p1.X()+a; },function(){ return p1.Y(); }]],{ dash : 4, StrokeOpacity : 0.5, strokeColor : '#000000' }); /*flunky. MathJax needs to be called last */ for(var i=0; i