Chapter 5 Linear ODEs
The general form of linear ODEs of order k is αk(x)dkydxk+αk−1(x)dk−1ydxk−1+...+α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+(x2−n2)y=0.
- Legendre’s equation (1−x2)d2ydx2−2xdydx+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.
Proof We prove this by contradiction; If we assume W(x)≠0 but {yi(x)}ki=1 are linearly dependent:
∃i∈{1,⋯,k},ci≠0,k∑i=1ciyi(x)=0.
By taking derivatives repeatedly with respect to x from the above equation we obtain:
k∑i=1cidyidx=0⋮k∑i=1cidk−1yidxk−1=0,
which can be written as W.→c=0, with →c defined as →c=[c1⋮ck], since →c≠0 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.
W2×2=[sin(x)cos(x)cos(x)sin(x)], then W(x)=detW=−sin2(x)−cos2(x)=−1≠0, 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:
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)=k∑i=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).
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.
Find yCF=yHGS(x;c1,⋯,ck) such that L[yCF]=0.
Find any solution to L1PI[y]=f1(x).
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]=k∑i=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α1x∫eα0α1xf(x)α1dx.Using the general solution above, and by integration by parts, we obtain: yGS=c1e−α0α1x+[xα0−α1α20].
Alternative method
- 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.
- 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 x∈R, so we equate the coefficients of the powers of x: x2:α0A=0⇒A=0;x1:2α1A+α0B=1⇒B=1α0;x0:α1B+α0C=0⇒C=−α1α20, which gives us the same general solution obtained using the first method: yGS=yCF+yPI=c1e−α0α1x+[xα0−α1α20].
The ODE is the following:
L[y]=α1dydx+α0y=ebx.
Using the two step method, we have as before:
yCF=yHGS(x;c1)=c1e−α0α1x.
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=c′e−α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±√α21−4α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=0⇒A(x)=B1x+B2⇒y2=(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λ1x≠0. 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±√α21−4α0α24α22. α21−4α0α2>0⟹λ1,2∈R
- λ1,2 can be both positive, both negative or one positive/one negative.
- If λ1>0 and λ1>λ2 asx→∞,yCF→eλ1x→∞.
- If λ2<λ1<0 asx→∞,yCF→eλ1x→0.
- α21−4α0α2<0⟹λ1,2∈C

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.
First step: The characteristic equation is λ2−3λ+2=0, so we have λ1=2 and λ2=1, so yCF=c1e2x+c2ex.
Second step: we try ansatz yPI=Ae8x. L[yPI]=Ae8x[64−24+2]=e8x⇒A=142, So, we have: yGS=yCF+yPI=c1e2x+c2ex+142e8x.
First step: This case has a charecteristic equation with repeated root λ=−2, so we have yCF=c1e−2x+c2xe−2x.
Second step: Finding a particular integral L[yPI]=f(x). 1st try ansatz yPI=Ae−2x, which does not work. 2nd try ansatz yPI=Axe−2x, which also does not work. Let’s try ansatz: yPI=A(x)e−2x using the method of variation of parameters. By plugging into the ODE we obtain: d2Adx2=1⇒A=x22+B1x+B2. So, we obtain the general solution: yGS=yCF+yPI=c1e−2x+c2xe−2x+x22e−2x. Instead of using the method of variation of parameters, we could have guessed the ansatz yPI=Bx2e−2x directly and obtaining value of B using the method of undetermined coefficients.
- First step: Solving the Homogeneous problem L[yH]=0. In this case roots are complex, so we have: yCF=c1e(1+i)x+c2e(1−i)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)x2i−e(1−i)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(1−i)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]=k∑i=0αiDi[y]=f(x);αi∈R 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λxk∑i=0αiλi=0⇒k∑i=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λ2x⋯eλkxλ1eλ1xλ2eλ2x⋯λkeλkx⋮⋮⋮λk−11eλ1xλk−12eλ2x⋯λk−1keλkx]
W(x)=detW(x)=e∑ki=1λix|11⋯1λ1λ2⋯λk⋮⋮⋮λk−11λk−12⋯λk−1k|=
e∑ki=1λix∏1≤i<j≤k(λ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=k∑i=1cieλix.
- Case 2: Not all of the k roots are distinct. Below, we consider the particular case of having d repeated roots and k−d distinct roots.
B={eλ1x,eλ2x,⋯,eλrx,xeλrx,⋯,xd−1eλrx,eλr+1x,⋯,eλk−d+1x}⇒ yCF=c1eλ1x,c2eλ2x,⋯,creλrx,cr+1xeλrx,⋯,cr+d−1xd−1eλrx,cr+deλr+1x,⋯,ckeλk−d+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 i≠r 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+βk−1xk−1dk−1ydxk−1+⋯+β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.
Using the change of variable x=ez we have z=lnx and so: dydx=dydzdzdx=1xdydz⇒xdydx=dydz,
d2ydx2=ddx(dydx)=ddz(dydx)dzdx=1x2[d2ydz2−dydz].
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=c1e−z+c2ze−z+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.
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.