Chapter 5 Linear ODEs

The general form of linear ODEs of order k is αk(x)dkydxk+αk1(x)dk1ydxk1+...+α1(x)dydx+α0(x)y=f(x), where αk(x),.., α0(x) and f(x) are functions of only the independent variable x. The ODE is called homogeneous if f(x)=0 and inhomogeneous otherwise.

Some examples of linear ODEs:

  • First order ODE dydx+p(x)y=q(x).
  • Bessel’s equation x2d2ydx2+xdydx+(x2n2)y=0.
  • Legendre’s equation (1x2)d2ydx22xdydx+n(n+1)y=0.

Linear Operators

We define the differential operator as D[f]ddx[f].

Differential operator is a linear operator since we have: D[λ1f1+λ2f2]=λ1D[f1]+λ2D[f2]. Defining differential operator of order k as Dk[f]dkdxk[f], which is also a linear operator as we have: Dk[λ1f1+λ2f2]=λ1Dk[f1]+λ2Dk[f2]. Linear ODEs are associated with a linear operator defined using the differential operators: L[y]ki=0αi(x)Di[y] since: L[λ1f1+λ2f2]=λ1L[f1]+λ2L[f2]. A linear ODE can thus be simply written as L[y]=f(x) and a homogenous ODE as L[y]=0. Linearity of L has an important consequence. If we have two solutions y1 and y2 of a homogenous linear ODE L[y]=0, then any linear combinations of these solutions are also solutions for this ODE, since: L[λ1f1+λ2f2]=λ1L[f1]+λ2L[f2]=0.

Linear independence

A set of functions {fi(x)}ki=1 is said to be linearly independent if fi’s satisfy the following condition: c1f1(x)+c2f2(x)++ckfk(x)=0, if and only if c1=c2==ck=0.

Linear ODEs are easier to solve because of the following important property of their solutions. This is a basic consequence of linearity of differential operators.

Proposition 5.1 The solutions of the homogeneous linear ODE L[y]=0 form a vector space (see MATH40003: Linear Algebra and Groups) of dimension k, where k is the order of the ODE. Therefore, the general solution of a linear homogeneous ODE can be written as yHGS(x;c1,...,ck)=c1y1+c2y2+...+ckyk, where B={yi(x)}ki=1 is a set of linearly independent solutions forming a basis for the linear homogeneous ODE’s solution vector space.
Proposition 5.2 To test the linear independence of a set of functions {yi(x)}ki=1, we calculate the Wronskian, which is the determinant of the Wronskian matrix (Wk×k): W[{yi(x)}ki=1]=detW=det[y1(x)y2(x)yk(x)dy1dx(x)dy2dx(x)dykdx(x)dk1y1dxk1(x)dk1y2dxk1(x)dk1ykdxk1(x)] The set {yi(x)}ki=1 is linearly independent if W[{yi(x)}ki=1]0.

Proof We prove this by contradiction; If we assume W(x)0 but {yi(x)}ki=1 are linearly dependent:

i{1,,k},ci0,ki=1ciyi(x)=0.

By taking derivatives repeatedly with respect to x from the above equation we obtain:

ki=1cidyidx=0ki=1cidk1yidxk1=0,

which can be written as W.c=0, with c defined as c=[c1ck], since c0 then W.c=0 implies W[{yi(x)}ki=1]=detW=0, which is a contradiction. So, if W(x)0 then {yi(x)}ki=1 are linearly independent, as required.

Example 5.1 Show that sin(x) and cos(x) are linearly independent.

W2×2=[sin(x)cos(x)cos(x)sin(x)], then W(x)=detW=sin2(x)cos2(x)=10, therefore sin(x) and cos(x) are linearly independent.

Note There exists examples in which the Wronskian vanishes without the functions being linearly dependent. An example is given in a quiz in the lectures.

5.1 General solution of the non-homogeneous linear ODE

To obtain the general solution of the non-homogeneous linear ODE L[y]=f(x), we split the problem into two simpler steps:

  1. We consider the corresponding homogeneous linear ODE L[y]=0. We obtain the general solution, which is also known as complementary function (yCF): yCF=yHGS(x;c1,,ck)=ki=1ciyi(x), where, {yi}ki=1 are the basis of the solution vector space (a set of linearly independent solutions of the homogeneous linear ODE).

  2. We obtain any/one solution of the full non-homogeneous ODE, which is also known as particular integral (yPI): L[yPI]=f(x). Then for the solution to the full problem by combining the results above and due to linearity, we have:

L[yGS(x;c1,,ck)]=L[yCF+yPI]=L[yHGS]+L[yPI]=f(x). So the general solution of the non-homogeneous linear ODE is the sum of the complementary function and a particular integral. As seen in a quiz in the lectures different choices of particular integrals results in the same family of general solutions.

One useful consequence of the linearity is that if the RHS of the ODE is sum of two functions: L[y]=f1(x)+f2(x). We can break the second step of finding particular integral into additional steps.

  1. Find yCF=yHGS(x;c1,,ck) such that L[yCF]=0.

  2. Find any solution to L1PI[y]=f1(x).

  3. Find any solution to L2PI[y]=f2(x).

Then, we have yGS=yCF+y1PI+y2PI.

Linear ODEs with constant coefficients

The general linear ODE is not always analytically solvable. Next year, you will see approximative and numerical methods to solve this kind of ODEs. In the rest of this course, we will focus on the case of linear ODEs with constant coefficients (αis not depending on independent variable x): L[y]=ki=0αiDi[y]=f(x)

5.2 First order linear ODEs with constant coefficients

The general form of the first order linear ODEs with constant coefficients is: L[y]=α1dydx+α0y=f(x). As seen in chapter 4, rewriting this ODE as dydx+α0α1y=f(x)α1,

we can obtain the general solution using the integrating factor I(x)=eα0α1x. We obtain

yGS=c1eα0α1x+eα0α1xeα0α1xf(x)α1dx.
Example 5.2 Solve f(x)=x.

Using the general solution above, and by integration by parts, we obtain: yGS=c1eα0α1x+[xα0α1α20].

Alternative method

  1. Solve the corresponding homogeneous ODE: L[yCF]=α1dydx+α0y=0. This is a separable ODE and by integration we obtain: yCF=yHGS(x;c1)=c1eα0α1x.
  2. Find a particular integral for the full ODE: L[yPI]=f(x)=x.

This is done by using ansatz, which is an educated guess using the method of undetermined coefficients. In this case as f(x) is polynomial, we could try a polynomial ansatz: yPI=Ax2+Bx+C, where, A, B and C are constants to be determined. By plugging this ansatz in to the ODE, we check if here are suitable values for these constants that makes our ansatz a particlular solution for the ODE: L[yPI]=α1(2Ax+B)+α0(Ax2+Bx+C)=x. This equation should be satisfied for all xR, so we equate the coefficients of the powers of x: x2:α0A=0A=0;x1:2α1A+α0B=1B=1α0;x0:α1B+α0C=0C=α1α20, which gives us the same general solution obtained using the first method: yGS=yCF+yPI=c1eα0α1x+[xα0α1α20].

Example 5.3 Solve f(x)=ebx;bα0α1.

The ODE is the following:
L[y]=α1dydx+α0y=ebx. Using the two step method, we have as before:

  1. yCF=yHGS(x;c1)=c1eα0α1x.

  2. We try ansatz yPI=Aebx, plugging this into the ODE, we obtain: α1Abebx+α0Aebx=ebx. Solving this we obtain A=1α1b+α0. So we obtain: yGS=yCF+yPI=c1eα0α1x+1α1b+α0ebx. What about the case b=α0α1? Naive ansatz yPI=Aebx does not work, since L[yPI]=0. A more general ansatz is: yPI=A(x)ebx. Here we are looking for an unknown function A(x), so we will obtain an ODE. This is called the method of variation of parameters, developed by Euler and Lagrange. Plugging this ansatz into the ODE we obtain the following simple ODE: α1dAdx=1, which has the following general solution: A(x)=xα1+c2. So, we obtain for the general solution: yGS=yCF+yPI=c1eα0α1x+(xα1+c2)ebx=ceα0α1x+xα1ebx, where in the last step we have renamed c1+c2 as c a new constant of integration.

5.3 Second order linear ODEs with constant coefficients

L[y]=α2d2ydx2+α1dydx+α0y=f(x), yGS(x;c1,c2)=yCF(x;c1,c2)+yPI=yHGS(x;c1,c2)+yPI. If B={y1(x),y2(x)} is a basis for the solution vector space of the homogeneous ODE: L[yH]=0. Then, we have: yHGS(x;c1,c2)=c1y1(x)+c2y2(x).

Solving the homogeneous second order linear ODE

We need to obtain two linearly independent solutions to the following ODE:

L[y]=α2d2ydx2+α1dydx+α0y=0.

We can try the ansatz: yH=eλx,

L[yH]=α2λ2eλx+α1λeλx+α0eλx=0α2λ2+α1λ+α0=0. This quadratic equation is called the characteristic equation of the linear ODE, which has the following solutions: λ1,λ2=α1±α214α0α22α2. So, we have the following two candidate solutions yH1=eλ1x and yH2=eλ2x. For these solutions to form a basis for the solution space of the homogeneous linear ODE, they should be linear independence. We evaluate the Wronskian: W(x)=det[eλ1xeλ2xλ1eλ1xλ2eλ2x]=e(λ1+λ2)x(λ2λ1). So, if the roots of the characteristics equation are distinct (λ1λ2), then W(x)0 and the solutions form a linearly independent set. So we have: yCF=yHGS(x;c1,c2)=c1eλ1x+c2eλ2x. For the case of λ1=λ2=α12α2, we have y1=eλ1x, what about the second solution y2? We can try the ansatz y2=A(x)y1(x)=A(x)eλ1x. This is similar to the method of variation of parameters. In the context of 2nd order linear ODEs, when we have one of the solutions and looking for the second solution, this method is called the method of reduction of order. Plugging this ansatz into the ODE we obtain:

α0[Ay1]+α1[dAdxy1+Ady1dx]+α2[d2Adx2y1+2dAdxdy1dx+Ad2y1dx2]=0.

This result in the following simple ODE and solution for A(x): d2Adx2=0A(x)=B1x+B2y2=(B1x+B2)eλ1x. We note that y2 we have obtained here contains y1, so we can choose y2=xeλ1x. Testing the linear independence of these solutions, we should evaluate the Wronskian: W(x)=det[eλ1xxeλ1xλ1eλ1xeλ1x+λ1xeλ1x]=e2λ1x0. So y1 and y2 are linearly independent and can span the solution space. So we have the following general solution for the case characteristic equation has the repeated root λ1: yCF=yHGS(x;c1,c2)=c1eλ1x+c2xeλ1x. Possible behaviours of the 2nd order linear homogeneous ODE

If λ1λ2 then yCF=c1eλ1x+c2eλ2x.

λ1,2=α12α2±α214α0α24α22. α214α0α2>0λ1,2R

  1. λ1,2 can be both positive, both negative or one positive/one negative.
  • If λ1>0 and λ1>λ2 asx,yCFeλ1x.
  • If λ2<λ1<0 asx,yCFeλ1x0.
  1. α214α0α2<0λ1,2C
|α214α0α24α22|=ω2λ1,2=α12α2±iω So, we have for the general solution: yCF=eα12α2x[c1eiωx+c2eiωx]=eα12α2x[(c1+c2)cosωx+i(c1c2)sinωx]. If the ODE has real coefficients the solution yCFR. Therefore, choosing c1 and c2 to be complex conjugate, we obtain c1=c1+c2R and c2=i(c1c2)R. So the we can write the general solution of the homogeneous ODE with complex roots in following forms: yCF=eα12α2x[c1cosωx+c2sinωx]=eα12α2xAcos(ωxϕ), where in the later, we have used the following change of constants of integrations c1=Acosϕ and c2=Asinϕ. Figure 5.1 shows possible behaviors of yCF depending on the value of the parameter d=α12α2.
$y_{CF}$ for $d > 0$ (red), $d < 0$ (green) and $d = 0$ (blue); all three solutions have the same phase but for clarity of visualisation different amplitudes ($A$) are used in each case.

Figure 5.1: yCF for d>0 (red), d<0 (green) and d=0 (blue); all three solutions have the same phase but for clarity of visualisation different amplitudes (A) are used in each case.

Example 5.4 Find the general solution of L[y]=d2ydx23dydx+2y=e8x.
  • First step: The characteristic equation is λ23λ+2=0, so we have λ1=2 and λ2=1, so yCF=c1e2x+c2ex.

  • Second step: we try ansatz yPI=Ae8x. L[yPI]=Ae8x[6424+2]=e8xA=142, So, we have: yGS=yCF+yPI=c1e2x+c2ex+142e8x.

Example 5.5 Find the general solution of L[y]=d2ydx2+4dydx+4y=e2x.
  • First step: This case has a charecteristic equation with repeated root λ=2, so we have yCF=c1e2x+c2xe2x.

  • Second step: Finding a particular integral L[yPI]=f(x). 1st try ansatz yPI=Ae2x, which does not work. 2nd try ansatz yPI=Axe2x, which also does not work. Let’s try ansatz: yPI=A(x)e2x using the method of variation of parameters. By plugging into the ODE we obtain: d2Adx2=1A=x22+B1x+B2. So, we obtain the general solution: yGS=yCF+yPI=c1e2x+c2xe2x+x22e2x. Instead of using the method of variation of parameters, we could have guessed the ansatz yPI=Bx2e2x directly and obtaining value of B using the method of undetermined coefficients.

Example 5.6 Find the general solution of L[y]=d2ydx22dydx+2y=exsin(x)
  • First step: Solving the Homogeneous problem L[yH]=0. In this case roots are complex, so we have: yCF=c1e(1+i)x+c2e(1i)x.
  • Second step: Finding a particular integral L[yPI]=f(x).

Here f(x) can be written as the sum of two functions f(x)=exsinx=e(1+i)x2ie(1i)x2i. So, we can use the following two ansatz to find particular integrals using the method of undetermined coefficients: y1PI=Axe(1+i)x and y2PI=Axe(1i)x. By plugging into the ODE using the first and second part of f(x), one finds values for A and B respectively (left as an exercise for you)  Then the general solution is: yGS=yCF+y1PI+y2PI.

5.4 kth order Linear ODEs with constant coefficients

L[y]=ki=0αiDi[y]=f(x);αiR yGS(x;c1,,ck)=yCF+yPI=yHGS(x;c1,,ck)+yPI(x) First step: Solving the Homogeneous problem L[yH]=0

We can try the ansatz yH=eλx: L[eλx]=eλxki=0αiλi=0ki=0αiλi=0. This is the characterstic equation of the kth order linear ODE. It has k roots that can be always obtained numerically (in the absence of an analytical solution).

  • Case 1: k roots of the characteristic polynomial are distinct:

The solutions B={eλix}ki=1 can be shown to be linearly independent using the Wronskian:

W(x)=[eλ1xeλ2xeλkxλ1eλ1xλ2eλ2xλkeλkxλk11eλ1xλk12eλ2xλk1keλkx]

W(x)=detW(x)=eki=1λix|111λ1λ2λkλk11λk12λk1k|=

eki=1λix1i<jk(λiλj)0;(Vandermonde determinant) The determinant of the Vandermonde matrix (the matrix obtained above) is a well known result in linear algebra and can be proven using induction. B={eλ1x,eλ2x,,eλkx}yCF=ki=1cieλix.

  • Case 2: Not all of the k roots are distinct. Below, we consider the particular case of having d repeated roots and kd distinct roots.
    B={eλ1x,eλ2x,,eλrx,xeλrx,,xd1eλrx,eλr+1x,,eλkd+1x} yCF=c1eλ1x,c2eλ2x,,creλrx,cr+1xeλrx,,cr+d1xd1eλrx,cr+deλr+1x,,ckeλkd+1x.

Second step: Finding a particular integral for example for: L[yPI]=ebx, for the case 2 above, we use the following ansatz, using the method of undetermined coefficients:

  • if bλi for i then yPI=Aebx.

  • if b=λi for ir then yPI=Axebx.

  • if b=λr then yPI=Axdebx.

5.5 Euler-Cauchy equation

A (rare) example of a linear ODE with non-constant coefficients that we can solve analytically is the Euler-Cauchy ODE: L[y]=βkxkdkydxk+βk1xk1dk1ydxk1++β1xdydx+β0y=f(x). Using the change of variable x=ez, the Euler-Cauchy equation can be transformed into a linear ODE with constant coefficients.

Example 5.7 Solve the following ODE: x2d2ydx2+3xdydx+y=x3.

Using the change of variable x=ez we have z=lnx and so: dydx=dydzdzdx=1xdydzxdydx=dydz,

d2ydx2=ddx(dydx)=ddz(dydx)dzdx=1x2[d2ydz2dydz]. So, in terms of the new independent variable we have the following linear ODE with constant coefficients.
d2ydz2+2dydz+y=e3z. By obtaining the complementary function and particular integral, we have the following general solution: yGS(z;c1,c2)=yCF+yPI=c1ez+c2zez+116e3z. So, in the general solution in terms of x is: yGS(x;c1,c2)=c1x+c2lnxx+116x3.

5.6 Using Fourier Transforms to solve linear ODEs

As Fourier transform is a linear operation, and given the properties we had for Fourier transforms of derivatives of a function seen in Section 2.1, one can use Fourier transforms to solve linear ODEs or find particular integrals. This is particularly relevant for solving partial differential equations as discussed in the second year. Here we discuss an example.

Example 5.8 Find a solution for the following ODE, known as the Airy equation or the Stokes equation, which arises in different areas of physics. Assume lim. \frac{d^2y}{dx^2} - x y = 0.

This is a linear 2nd order ODE with non-constant coefficients and so far we have not seen a method of solving it. Note that this ODE is not also one of the types that are discussed in Section 4.2. Our strategy is to take Fourier transform from this ODE and see if we can solve for the Fourier transform. Using the properties in Section 2.1, we obtain: -\omega^2 \hat{y}(\omega) -i\frac{d\hat{y}(\omega)}{d\omega} = 0
This is a first order ODE for \hat{y}(\omega), by solving it we obtain: \hat{y}(\omega) = c e^{\frac{i\omega^3}{3}}, where c is an arbitrary constant of integration. Using the inverse transform we obtain: y(x) = \frac{c}{2\pi} \int^\infty_{-\infty} e^{i(\omega x + \omega^3/3)} \,d\omega = \frac{c}{\pi}\int^\infty_{0} \cos(\omega x + \frac{\omega^3}{3})\,d\omega, where, in the last step we have used the evenness of cosine and oddness of the sine function. For c = 1 the function y(x) is known as the Airy function (of the first kind) and is denoted by Ai(x). It is defined as the above integral and cannot be reduced further and is a solution of the Airy ODE.