Notes
1P4 Mathematics · Topic 7

Linear ordinary differential equations

Lecture 9 · Fri 6 Nov

3.1 Introduction

3.1.1 What is an ordinary differential equation?

Definition Ordinary differential equation (ODE)

An equation relating a dependent variable (usually ), one independent variable (usually or ), and derivatives of the dependent variable:

Ordinary means one independent variable. A partial differential equation (PDE) has more than one.

Definition Order of an ODE

The order is that of the highest derivative present.

  • 1st order: involves , and , with no higher derivatives.
  • 2nd order: involves , , and , with no higher derivatives.

3.1.2 What is a linear ordinary differential equation?

Linear ODEs are the key class for engineers. They contain no terms such as , or .

Definition Linear ODE

An ODE that can be written in the form:

  • 1st order:
  • 2nd order:
Definition Homogeneous ODE

A linear ODE is homogeneous if no function of the independent variable appears on its own, i.e. .

Result Principle of superposition (1st order) memorise

Let solve the homogeneous case, . Let be a particular solution for , so . Then for any constant the overall solution is

The particular part is .

Show derivation

Substitute into the left-hand side and collect terms, using the linearity of differentiation:

  • Order = highest derivative. Ordinary = one independent variable.
  • Linear: and its derivatives appear only to the first power and are never multiplied together.
  • Homogeneous: .
  • General solution of a linear ODE = (constant) × homogeneous solution + one particular solution.
Explanation Does linear mean the coefficients must be linear in x?

No. Linearity is about only. is linear even though it contains , and is also linear. But is not, even though it looks simpler.

Superposition depends on this. A term like breaks it, because .

Explanation Why is the CF scaled by α but the PI is not?

The homogeneous equation has on the right, so any multiple of a solution still gives . Scaling by would give on the right, which is the wrong forcing.

The PI is also not unique: plus any multiple of is another valid PI. This does not matter, because absorbs the difference.

3.2 First order linear ordinary differential equations

3.2.1 Solution of the homogeneous linear 1st order ordinary differential equation

The 1st order linear ODE is , with and functions of . First take the homogeneous case .

Equation Homogeneous 1st order solution memorise

is an arbitrary constant, found from a boundary condition.

Show derivation

Separate the variables, so terms are on one side and terms on the other:

Integrate both sides ( by the Chain rule):
Take exponentials, with :

  • always separates: .
  • There is one arbitrary constant, so one boundary condition is needed.
Explanation A = e^c is always positive, so can y be negative?

Strictly, , so and . The solution also works. Together these allow to be any real number, so in practice just treat as an arbitrary constant.

3.2.2 Example

Example y’ + 3x²y = 0 with y = 1 when x = 0

Separate and integrate:

Letting :
The boundary condition when gives , so

3.2.3 Solution of the non-homogeneous 1st order linear ordinary differential equation

Now take . The solution has two named parts.

Definition Complementary function (CF)

The solution of the homogeneous ODE, i.e. with set to zero.

Definition Particular integral (PI)

A particular solution of the ODE with the actual . It can often be found by an educated guess.

Definition General solution

The sum of the two parts, by Principle of superposition (1st order):

Apply boundary conditions to this whole expression, never to the CF alone.

Example y’ + 3x²y = x² with y(0) = 1: CF + PI

CF. From the previous example (3.2.2) the homogeneous solution is .

PI. With , guess , a constant. Then , so the ODE becomes , which gives

General solution.

Boundary condition. gives , so :

Interactive figure

The grey dashes show the slope at each point. Move : the boundary condition picks one curve from the family, and the green curve follows the slopes everywhere. The CF (blue) dies away for , leaving the PI (red dashed).

Figure Solutions of y’ + 3x²y = x²: CF + PI
  • CF: solve with . PI: find any one solution with the actual .
  • General solution = .
  • Apply the boundary condition last, to the whole general solution.

3.2.4 Separation of variables to solve the non-homogeneous linear 1st order ODE

Some 1st order ODEs can be solved directly by separation of variables.

Result Separation of variables memorise

If the ODE can be written with the right-hand side as a product,

Show derivation

Divide by and integrate with respect to :

By the Chain rule (substitution), the left side is .

Example y’ + 3x²y = x² with y(0) = 1: separation of variables

Re-write the ODE and separate:

Integrate both sides:
So with , and hence
The boundary condition gives , so . The final solution matches the CF + PI result:

Watch out

Keep the modulus in . Here makes , which is negative, so would not even be real at the boundary point.

  • Use when the right-hand side factorises as .
  • : remember the factor and the modulus.
Explanation When does separation fail but the ODE is still linear?

Separation needs a product . The example only separates because the coefficient of and the right-hand side share the factor . Change the right-hand side to : does not separate. The integrating factor method below still applies, though the resulting integral need not be elementary.

3.2.5 The integrating factor method to solve the non-homogeneous linear 1st order ODE

The integrating factor method is more general than separating variables or finding the CF and PI separately. It combines into the derivative of a product.

Equation Integrating factor method databook p.8

For , the integrating factor is , and

Integrate both sides, then divide by the integrating factor.

Show derivation

If were zero, Homogeneous 1st order solution gives . Rearranging, .

This suggests differentiating that product. By the product rule, the Chain rule and the Fundamental theorem of calculus:

So the left-hand side of the ODE can be written as
Multiplying through by gives the result.

  • The ODE must first be in standard form, with coefficient of equal to 1.
  • Integrating factor , while the CF has .
  • Add the constant when integrating the right-hand side, then divide everything by the integrating factor, including the constant.
Explanation Why is there no constant in the integrating factor?

Any integrating factor will do, so take the simplest. Including a constant in multiplies both sides of the equation by , which cancels. The one constant that matters appears when you integrate the right-hand side.

Watch out

If the ODE is , divide by first. Then and .

3.2.6 Example revisited

Example y’ + 3x²y = x² with y(0) = 1: integrating factor

Here , so the integrating factor is . Multiplying through:

Integrating both sides:
The boundary condition gives , so . The final solution is

Explanation Where did the CF and PI go?

They are still there. Dividing by the integrating factor gives . The constant of integration carries the CF, and the integral of the right-hand side gives the PI. The method finds both at once.

3.2.7 Engineering example: time and frequency domain response of a low pass filter

A resistor and capacitor form, in essence, a potential divider. We want for a given input .

vin(t) vout(t) R C i(t)

The ideal voltmeter across draws no current, so the same current flows through and . This is the circuit of The RC circuit (resistor in series, output across the capacitor).

Figure RC low pass filter
Equation ODE of the RC filter memorise

A non-homogeneous 1st order linear ODE, with .

Show derivation

The current through the resistor is its voltage drop divided by its resistance (Ohm's law):

The capacitor charge is (Capacitance). The current is the rate of change of charge (Electric current):
With an ideal voltmeter , so
Divide by and rearrange.

Equation General solution for any input memorise

is the constant of integration.

Show derivation

Apply the Integrating factor method method with , so the integrating factor is :

Integrate:
Divide by .

The solution has two parts:

  • Complementary function: solves the homogeneous equation ().
  • Particular integral: the second term is a solution for the specified right-hand side.

The general solution is the linear combination of the two. This form gives the output for any input (it is a convolution).

1st case: time domain response to a voltage step

Equation Step response memorise
Show derivation

For , substitute in General solution for any input:

The integral gives , so
Applying :

Interactive figure

Change . The output (purple) is the sum of the decaying CF (blue, ) and the constant PI (red). The grey tangent at reaches at exactly , the time constant.

Figure Step response = CF + PI
Measured step response

A F capacitor charged through a k resistor with a 5 V step, with the theoretical curve for s. The slight offset arises because was defined by the voltage exceeding a 1 V threshold.

Figure Measured step response

2nd case: frequency response to a sinusoid

Take for . Requiring for all forces .

Equation Frequency response memorise

The amplitude falls as rises, and the output lags the input by .

Show derivation

In General solution for any input the CF term grows without limit as , so :

Write (Euler's formula):
The exponents add, so the integral is immediate:
Convert from Cartesian to polar form (Modulus and argument):

The gain is expressed in decibels, which is a ratio of voltages squared since (Power dissipated in a resistor (DC)).

Equation Gain in decibels memorise

denotes the time average.

Show derivation

The average value of is (from , databook maths p4). For the input:

For the output, from Frequency response with :
The ratio is . Take .

Equation High-frequency roll-off memorise

For :

Every time increases by a decade (factor of 10), the gain falls by 20 dB.

Show derivation

For , , so from Gain in decibels:

Replacing by adds dB.

Interactive figure

Sweep the slider. At low frequency the output follows the input; at high frequency it is small and lags by nearly . This is why the circuit is a low pass filter. The dashed line is the dB per decade asymptote.

Figure Output waveform and Bode plot of the RC filter
Measured Bode plot

Measured gain and phase of a low pass filter built from a F capacitor and a k resistor, with the theory for s. The frequency axis is in Hz, where . The dB per decade slope is visible in the data.

Figure Measured Bode plot
  • Ideal voltmeter: , with . Then use the integrating factor .
  • Step: final value , time constant ; is fixed by .
  • Sinusoid on : , since the CF would blow up as .
  • Use to do the integral.
  • For , gain falls 20 dB per decade.
Explanation Why is c non-zero for the step but zero for the sine?

It depends on when the input starts. The step starts at with a known state, so the CF is needed to match . It is the transient, and it dies away after a few .

The sine has been running forever, so any transient has long since decayed. Mathematically, the CF would be infinite at , so . Only the steady-state PI remains.

Explanation Is this the same answer as the impedance method?

Yes. Treat the circuit as a potential divider with :

This is the same complex factor as in the derivation above, and matches RC circuit: output/input ratio. The ODE route explains why the method works: a sinusoid in gives a sinusoid out once the CF has gone.

Explanation What happens at ωRC = 1?

Gain dB and phase . This is the corner of the Bode plot, where the two straight-line asymptotes (0 dB, and dB per decade) meet. For s it is at Hz, which you can check against the measured plot.

Try now

3.3 Second order linear ordinary differential equations:

3.3.1 The operator

This section covers homogeneous 2nd order ODEs only.

Definition The D operator

As is an operator, powers mean repeated application:

The homogeneous 2nd order ODE becomes .

Result Superposition (2nd order homogeneous) memorise

If and both solve , then so does

Show derivation

We are given and . Substituting and using the linearity of :

Equation Integrating factor in D notation databook p.8

For constant , this gives the case used repeatedly below:

Show derivation

The first line is Integrating factor method written with . For the second, put , so .

3.3.2 A useful property of the operator

can be treated like an algebraic term. If is a quadratic, then . (Here denotes a polynomial, not the coefficient function in the ODE.)

Equation D acting on an exponential memorise
Show derivation

and . So

Definition Eigenfunction and eigenvalue of D

changes only by a scale factor. So is an eigenfunction of , satisfying , with eigenvalue . This matches matrices, where an eigenvector satisfies .

  • ; polynomials in behave like ordinary polynomials.
  • is an eigenfunction of : replace by when acting on it.

3.3.3 Homogeneous second-order ODEs with constant coefficients

Equation Auxiliary equation memorise

can be written as , where are the roots of the auxiliary equation ( replaced by ):

Show derivation

Expand the factors. The middle coefficient is :

Comparing with needs and . These are the sum and product of the roots of .

To solve formally, use the method of reduction of order: split the 2nd order ODE into two 1st order ODEs.

Equation Reduction of order: common first step memorise

Defining turns the ODE into , and leads to

is a constant of integration.

Show derivation

With the ODE is . By Integrating factor in D notation:

Put this into the second 1st order ODE:
The integrating factor method again gives

There are three cases, set by the sign of .

Equation Case 1: repeated root, b² = 4ac memorise

:

Show derivation

Reduction of order: common first step with gives

Integrating, with constant :

Equation Case 2: distinct real roots, b² > 4ac memorise

The last term is .

Show derivation

Integrate Reduction of order: common first step, with constant :

Multiply by and define and .

Equation Case 3: complex roots, b² < 4ac memorise

:

Show derivation

Take and , so . Then Reduction of order: common first step becomes

Integrating:
So
Using Euler’s formula :
Define and .

  • Replace by to get the auxiliary equation; its roots decide the case.
  • Reduction of order: gives two 1st order ODEs in turn.
  • A 2nd order ODE has two arbitrary constants, so it needs two conditions.
Explanation Why can the D polynomial be factorised like a normal quadratic?

Because and are constants, , so and commute and the brackets multiply out as usual. This fails for variable coefficients: . That is why this section is restricted to constant coefficients.

Explanation Is there a quicker way to see the auxiliary equation?

Try . By D acting on an exponential, . Since , this vanishes exactly when is a root.

This finds both solutions in the distinct-root case. For a repeated root it finds only one, and the reduction of order shows that the missing one is .

Explanation A and B contain j in the derivation. Isn’t y meant to be real?

and are just arbitrary constants. If is real for all , then and turn out real, which requires and to be complex conjugates. You then fix real and directly from two real conditions, and never need to look at and .

For real , complex roots always come in a conjugate pair (Real polynomials: roots are real or come in conjugate pairs), so is the only complex case.

3.3.4 Simple example problem – repeated roots

Example (D² + 2D + 1)y = 0

The auxiliary equation is , a repeated root . The general solution is

3.3.5 Simple example problem – distinct real roots

Example (D² + 3D + 2)y = 0

The auxiliary equation is , with roots and . The general solution is

3.3.6 Simple example problem – distinct complex roots

Example (D² + 2D + 2)y = 0

The auxiliary equation has roots

So the general solution is
Using and :
where and .

3.3.7 Summary of solutions to ODE of the form

Result Solutions of ay’’ + by’ + cy = 0 memorise

are the roots of the auxiliary equation . Here label the roots (in case 3, their real and imaginary parts), not constants of integration.

Case Condition Roots General solution
1. Repeated
2. Distinct real
3. Complex conjugate
Show derivation
Interactive figure

Solutions of with , (). Start with , and raise : the complex pair slides left and meets on the real axis at (try , ), then splits along it. The real part of the root sets the decay and the imaginary part sets the oscillation frequency. Set for pure oscillation.

Figure Where the roots sit decides the shape of y
  • real: exponentials. complex: decaying or growing oscillation, times a sinusoid at .
  • Repeated root: remember the extra factor .

3.4 Second order linear ordinary differential equations:

3.4.1 Introduction

The discussion is restricted to constant coefficient ODEs, .

Result General solution: 2nd order memorise

For , there are two homogeneous solutions and , and

Show derivation

Write , which is linear. By Superposition (2nd order homogeneous), . Since :

Conversely, if is any solution then , so solves the homogeneous ODE. Every solution therefore has this form.

3.4.2 Method of reduction of order (integral based - general but time consuming)

Equation Reduction of order with q(x) ≠ 0 memorise

The integrals are indefinite. and are found from the boundary conditions.

Show derivation

Re-write the ODE using the roots of (Auxiliary equation):

Define , so . By Integrating factor in D notation:
Hence
The integrating factor method again gives
Integrate and multiply both sides by .

The factor inside the integral is throughout.

  • Reduction of order: always works, but needs two nested integrals. Use the trial method in an exam unless told otherwise.
  • Steps: factorise, set , solve for , then solve for .

3.4.3 Example problem: find the general solution of

Example (D² − 5D + 4)y = e⁶ˣ by reduction of order

The auxiliary equation is .

Define , which satisfies . The integrating factor method gives

Therefore
Applying the integrating factor method to :
And hence
where and .

3.4.4 Example problem: find the general solution of

Example (D² − 4D + 4)x = t² by reduction of order

Factorise: . Define , which satisfies .

The integrating factor method gives , and so

Integrating by parts twice (Integration by parts):
Hence
Now apply the integrating factor method to :
So
The constant in is , and the sign before the first by-parts integral is .

Both the PI and are quadratic. Exploiting this similarity avoids doing all these integrals, and leads to the method to use in timed exams.

3.4.5 Undetermined coefficients with trial solution method (much better for Tripos!)

The PI has a similar form to . So try a function similar to , known as a trial PI. The table is in the maths databook.

Result Trial particular integrals databook p.8
Right-hand side Trial PI
constant
( integer)

The constants (and possibly etc.) are to be determined.

Show derivation

Each trial is a family of functions closed under : differentiating a member gives another member. For example, turns into a combination of the same two functions.

So applied to a trial stays in the family. Matching coefficients with then gives linear equations for the constants, which have a solution unless part of the family is annihilated by . That exception is the case in Trial PI when q(x) is similar to the CF.

Method:

  1. Solve the auxiliary equation to get the CF.
  2. Choose the trial PI from the table, checking it against the CF.
  3. Substitute into the ODE and compare coefficients.
  4. Write , then apply any boundary conditions.
  • Find the CF first: you need it to check the trial.
  • or on the right always needs both and in the trial.
  • A polynomial trial needs all the lower powers, down to the constant.
  • Table on databook maths p8.

3.4.6 Example problem: find the general solution of

Example (D² − 4D + 4)x = t² by undetermined coefficients

Factorise: .

The root is repeated, so the complementary function is .

Trial PI:

With and :
Comparing coefficients:

  • : , so
  • : , so
  • : , so

So , and

This matches the reduction of order result with far less work.

Try now

3.4.7 Undetermined coefficients method when is similar to the CF

The method needs care when the driving term is similar to either part of the complementary function. A slightly different trial PI is then needed.

Result Trial PI when q(x) is similar to the CF databook p.8
Complementary function Right-hand side Trial PI
, or
, or

The constants (and possibly etc.) are to be determined.

Show derivation

Let and suppose is in the CF, so . By D acting on an exponential, the ordinary trial gives , which can never equal .

Instead, using and :

This is a non-zero multiple of when is a simple root, so the trial works. The sine and cosine rows follow in the same way with complex exponent (or in the row).

Equation Resonance of a driven pendulum memorise

A physically significant example is resonance: a system excited at its natural frequency. For driven at :

The factor makes the amplitude grow without limit.

Show derivation

Divide by . With :

The CF is , the same frequency as the forcing. By Trial PI when q(x) is similar to the CF try with .

Since , we get . So

Comparing coefficients: and .

Interactive figure

Pendulum starting from rest, with and . Away from the response is a bounded beat. Move towards 1: the beats stretch out, and at exactly 1 the envelope becomes the straight dashed lines, the term.

Figure Approaching resonance
  • Compare with the CF before choosing a trial. If similar, multiply the trial by .
  • Symptom of a missed clash: the trial substitutes to give on the left.
  • Resonance: forcing at the natural frequency gives a term.
Explanation What if the CF has a repeated root, so both e^{kx} and xe^{kx} are in it?

Then fails too. In the derivation above, for a repeated root. Multiply by again and try .

With : and , so and for . The rule is: keep multiplying by until no term of the trial is in the CF.

Explanation What if q(x) has several terms?

The ODE is linear, so treat each term separately. If and , then . Find a PI for each term, checking each one against the CF, and add them.

Explanation In the x^n row, why is there a redundant constant?

The trial ends in a constant multiple of , which is already in the CF. That term gives zero on substitution, so you can drop it or leave its coefficient arbitrary. It would simply merge with the CF constant.