Linear Algebra & DE · Unit 2 · Topic 10

Variation of parameters: let the constants vary.

Short answer

For \(y'' + py' + qy = X\) with CF \(c_1y_1 + c_2y_2\) and Wronskian \(W = y_1y_2' - y_2y_1'\),

\[y_p = -y_1\int\frac{y_2X}{W}\,dx + y_2\int\frac{y_1X}{W}\,dx\]

Example: \(y'' + y = \sec x\) has \(W = 1\) and \(y_p = \cos x\log(\cos x) + x\sin x\).

Engineering MathsB Tech / BEBSc
01

When the short methods run out

Before you start: you need the complementary function from higher-order linear equations.

The \(\dfrac{1}{f(D)}\) shortcuts handle \(e^{ax}\), \(\sin ax\), \(\cos ax\), \(x^n\) and their products. They have nothing to say about right-hand sides like \(\sec x\), \(\tan 2x\) or \(\dfrac{e^x}{x}\). Variation of parameters handles any continuous right-hand side, as long as you know the complementary function.

Variation of parameters

For \(y'' + p\,y' + q\,y = X\) with CF \(c_1y_1 + c_2y_2\), the Wronskian is \[W = \begin{vmatrix} y_1 & y_2 \\ y_1' & y_2' \end{vmatrix} = y_1y_2' - y_2y_1'\]

and a particular integral is \[y_p = -y_1\int\frac{y_2X}{W}\,dx + y_2\int\frac{y_1X}{W}\,dx\]

The coefficient of \(y''\) must be 1 before you read off \(X\).

Where the formula comes from

Replace the constants by functions: try \(y = A(x)\,y_1 + B(x)\,y_2\). We have two unknown functions and one equation, so we may impose one extra condition. Choose \(A'y_1 + B'y_2 = 0\). Then \(y' = Ay_1' + By_2'\), and substituting into the equation (using that \(y_1, y_2\) solve the homogeneous one) leaves \(A'y_1' + B'y_2' = X\). Solving these two linear equations by Cramer's rule gives \[A' = -\frac{y_2X}{W}, \qquad B' = \frac{y_1X}{W}.\] \(W \ne 0\) because \(y_1\) and \(y_2\) are linearly independent.

02

The method

  1. Put the equation in standard form \(y'' + py' + qy = X\). Divide by the coefficient of \(y''\) if needed.
  2. Find the CF and name the two solutions \(y_1\) and \(y_2\).
  3. Compute \(W = y_1y_2' - y_2y_1'\) and simplify it. For \(\cos ax, \sin ax\) it is \(a\); for \(e^{mx}, xe^{mx}\) it is \(e^{2mx}\).
  4. Find \(A = -\int\dfrac{y_2X}{W}dx\) and \(B = \int\dfrac{y_1X}{W}dx\). No constants are needed here.
  5. Write \(y = c_1y_1 + c_2y_2 + Ay_1 + By_2\), and absorb any piece of \(Ay_1 + By_2\) that is already in the CF.
03

Solved examples

Example 1: A check against the short method

Easy

Solve \(y'' + y = x\) by variation of parameters.

  1. \(y_1 = \cos x\), \(y_2 = \sin x\), \(W = \cos^2 x + \sin^2 x = 1\).
  2. \(A = -\int x\sin x\,dx = x\cos x - \sin x\). \(B = \int x\cos x\,dx = x\sin x + \cos x\).
  3. \(Ay_1 + By_2 = x\cos^2 x - \sin x\cos x + x\sin^2 x + \sin x\cos x = x\).
  4. The short method gives the same PI: \(\dfrac{1}{1 + D^2}x = x\).

Answer\(y = c_1\cos x + c_2\sin x + x\)

Example 2: The classic: sec x

Easy

Solve \(y'' + y = \sec x\) on \(-\dfrac{\pi}{2} < x < \dfrac{\pi}{2}\).

  1. \(y_1 = \cos x\), \(y_2 = \sin x\), \(W = 1\).
  2. \(A = -\int \sin x\sec x\,dx = -\int\tan x\,dx = \log(\cos x)\).
  3. \(B = \int\cos x\sec x\,dx = x\).

Answer\(y = c_1\cos x + c_2\sin x + \cos x\log(\cos x) + x\sin x\)

Example 3: cosec x

Medium

Solve \(y'' + y = \operatorname{cosec} x\) on \(0 < x < \pi\).

  1. Same \(y_1, y_2, W\) as before.
  2. \(A = -\int\sin x\operatorname{cosec}x\,dx = -x\). \(B = \int\cos x\operatorname{cosec}x\,dx = \log(\sin x)\).

Answer\(y = c_1\cos x + c_2\sin x - x\cos x + \sin x\log(\sin x)\)

Example 4: tan 2x

Medium

Solve \(y'' + 4y = \tan 2x\) on \(-\dfrac{\pi}{4} < x < \dfrac{\pi}{4}\).

  1. \(y_1 = \cos 2x\), \(y_2 = \sin 2x\), \(W = 2\cos^2 2x + 2\sin^2 2x = 2\).
  2. \(B = \tfrac{1}{2}\int\cos 2x\tan 2x\,dx = \tfrac{1}{2}\int\sin 2x\,dx = -\tfrac{1}{4}\cos 2x\).
  3. For \(A\), write \(\sin 2x\tan 2x = \dfrac{1 - \cos^2 2x}{\cos 2x} = \sec 2x - \cos 2x\). Then \[A = -\tfrac{1}{2}\int(\sec 2x - \cos 2x)\,dx = -\tfrac{1}{4}\log(\sec 2x + \tan 2x) + \tfrac{1}{4}\sin 2x\]
  4. \(Ay_1 + By_2\): the \(\tfrac{1}{4}\sin 2x\cos 2x\) terms cancel.

Answer\(y = c_1\cos 2x + c_2\sin 2x - \tfrac{1}{4}\cos 2x\,\log(\sec 2x + \tan 2x)\)

Example 5: A repeated root

Medium

Solve \(y'' - 2y' + y = \dfrac{e^x}{x}\) for \(x > 0\).

  1. \(m = 1, 1\), so \(y_1 = e^x\), \(y_2 = xe^x\). \(W = e^x(e^x + xe^x) - xe^x\cdot e^x = e^{2x}\).
  2. \(A = -\int\dfrac{xe^x\cdot e^x/x}{e^{2x}}\,dx = -\int 1\,dx = -x\).
  3. \(B = \int\dfrac{e^x\cdot e^x/x}{e^{2x}}\,dx = \int\dfrac{dx}{x} = \log x\).
  4. \(Ay_1 + By_2 = -xe^x + xe^x\log x\). The \(-xe^x\) is already in the CF, so drop it.

Answer\(y = (c_1 + c_2x)\,e^x + xe^x\log x\)

Example 6: An exponential fraction

Exam level

Solve \(y'' - 3y' + 2y = \dfrac{1}{1 + e^{-x}}\).

  1. \(y_1 = e^x\), \(y_2 = e^{2x}\), \(W = 2e^{3x} - e^{3x} = e^{3x}\).
  2. \(A = -\int\dfrac{e^{-x}}{1 + e^{-x}}\,dx = \log(1 + e^{-x})\).
  3. \(B = \int\dfrac{e^{-2x}}{1 + e^{-x}}\,dx\). Put \(t = e^{-x}\), \(dx = -\dfrac{dt}{t}\): \(B = -\int\dfrac{t}{1 + t}\,dt = -t + \log(1 + t) = -e^{-x} + \log(1 + e^{-x})\).
  4. \(Ay_1 + By_2 = (e^x + e^{2x})\log(1 + e^{-x}) - e^x\). The \(-e^x\) joins the CF.

Answer\(y = c_1e^x + c_2e^{2x} + (e^x + e^{2x})\log(1 + e^{-x})\)

Example 7: Variable coefficients

Exam level

Given that \(y_1 = x\) and \(y_2 = x^2\) solve \(x^2y'' - 2xy' + 2y = 0\), solve \(x^2y'' - 2xy' + 2y = x^3\) for \(x > 0\).

  1. Standard form: divide by \(x^2\). So \(X = \dfrac{x^3}{x^2} = x\), not \(x^3\).
  2. \(W = x\cdot 2x - x^2\cdot 1 = x^2\).
  3. \(A = -\int\dfrac{x^2\cdot x}{x^2}\,dx = -\dfrac{x^2}{2}\). \(B = \int\dfrac{x\cdot x}{x^2}\,dx = x\).
  4. \(Ay_1 + By_2 = -\dfrac{x^3}{2} + x^3 = \dfrac{x^3}{2}\).

Answer\(y = c_1x + c_2x^2 + \dfrac{x^3}{2}\)

Vipul Sir's tip

Write \(W\) first and simplify it before anything else. In most exam questions it comes out as a constant or a single exponential, and the two integrals become much shorter. If your \(W\) is messy, recheck the CF.

04

Common mistakes

1. Not dividing by the coefficient of \(y''\)

In Example 7, using \(X = x^3\) gives \(y_p = \dfrac{x^5}{6}\), which does not satisfy the equation. The formula assumes the coefficient of \(y''\) is 1, so \(X = x\).

2. Putting the wrong function in each integral

The integral multiplying \(y_1\) contains \(y_2\), and it carries the minus sign: \(-y_1\int\dfrac{y_2X}{W}dx\). Swapping them in Example 2 gives \(-x\cos x - \sin x\log(\cos x)\), which does not satisfy the equation.

3. Computing \(W\) in the wrong order

\(W = y_1y_2' - y_2y_1'\). Taking \(y_2y_1' - y_1y_2'\) flips the sign of \(W\), and so the sign of the whole PI. For \(\cos 2x, \sin 2x\), \(W = +2\), not \(-2\).

05

Practice questions

Try each one on paper before you open the answer.

Q1Solve \(y'' + y = \tan x\) on \(-\dfrac{\pi}{2} < x < \dfrac{\pi}{2}\).

\(W = 1\). \(A = -\int(\sec x - \cos x)\,dx = -\log(\sec x + \tan x) + \sin x\), \(B = -\cos x\).

\(y = c_1\cos x + c_2\sin x - \cos x\log(\sec x + \tan x)\).

Q2Solve \(y'' + 4y = \sec 2x\) on \(-\dfrac{\pi}{4} < x < \dfrac{\pi}{4}\).

\(W = 2\). \(A = -\tfrac{1}{2}\int\tan 2x\,dx = \tfrac{1}{4}\log(\cos 2x)\), \(B = \tfrac{x}{2}\).

\(y = c_1\cos 2x + c_2\sin 2x + \tfrac{1}{4}\cos 2x\log(\cos 2x) + \tfrac{x}{2}\sin 2x\).

Q3Solve \(y'' + 9y = \sec 3x\) on \(-\dfrac{\pi}{6} < x < \dfrac{\pi}{6}\).

\(W = 3\). \(A = \tfrac{1}{9}\log(\cos 3x)\), \(B = \tfrac{x}{3}\).

\(y = c_1\cos 3x + c_2\sin 3x + \tfrac{1}{9}\cos 3x\log(\cos 3x) + \tfrac{x}{3}\sin 3x\).

Q4Solve \(y'' + 2y' + y = \dfrac{e^{-x}}{x^2}\) for \(x > 0\).

\(y_1 = e^{-x}\), \(y_2 = xe^{-x}\), \(W = e^{-2x}\). \(A = -\log x\), \(B = -\dfrac{1}{x}\).

\(Ay_1 + By_2 = -e^{-x}\log x - e^{-x}\); drop \(-e^{-x}\). \(y = (c_1 + c_2x)e^{-x} - e^{-x}\log x\).

Q5Solve \(y'' - y = \dfrac{2}{1 + e^x}\).

\(y_1 = e^x\), \(y_2 = e^{-x}\), \(W = -2\). \(A = \int\dfrac{e^{-x}}{1 + e^x}dx = -e^{-x} - x + \log(1 + e^x)\) (partial fractions with \(t = e^x\)), \(B = -\log(1 + e^x)\).

\(y = c_1e^x + c_2e^{-x} - 1 - xe^x + (e^x - e^{-x})\log(1 + e^x)\).

Q6Find \(W(e^{2x}, e^{3x})\), then solve \(y'' - 5y' + 6y = e^{4x}\) by variation of parameters.

\(W = e^{2x}\cdot 3e^{3x} - e^{3x}\cdot 2e^{2x} = e^{5x}\). \(A = -\int e^{2x}dx = -\tfrac{1}{2}e^{2x}\), \(B = \int e^x dx = e^x\).

\(y_p = -\tfrac{1}{2}e^{4x} + e^{4x} = \tfrac{1}{2}e^{4x}\), so \(y = c_1e^{2x} + c_2e^{3x} + \tfrac{1}{2}e^{4x}\). The short method agrees.

Stuck on a question?

Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.

06

Frequently asked questions

What is the method of variation of parameters?

A way to find a particular integral of a linear equation. You replace the constants \(c_1, c_2\) in the CF by functions \(A(x), B(x)\) and choose them so that \(Ay_1 + By_2\) satisfies the full equation.

What is the Wronskian?

For two functions, \(W = y_1y_2' - y_2y_1'\), the determinant of the functions and their derivatives. It is non-zero when \(y_1\) and \(y_2\) are linearly independent solutions, which is why we can divide by it.

When should I use variation of parameters instead of 1/f(D)?

Use the short method for \(e^{ax}\), \(\sin ax\), \(\cos ax\), \(x^n\) and their products: it is faster. Use variation of parameters for \(\sec x\), \(\tan x\), \(\operatorname{cosec}x\), \(\dfrac{e^x}{x}\), \(\log x\) and anything else, or when the question asks for it.

Does variation of parameters work for variable coefficients?

Yes, provided you already know two independent solutions of the homogeneous equation and you divide by the coefficient of \(y''\) first. Example 7 is such a case.

Related lessons

← All 12 Linear Algebra & DE topics
Vipul Sir
Written by Vipul Sir

Vipul Sir has taught mathematics for over 15 years to HSC, CBSE, ICSE, IGCSE/IB, Diploma, Engineering and BSc students at VVS Classes in Goregaon and Vile Parle, Mumbai. He teaches every class himself, concepts first and exam technique second.

Linear Algebra and Differential Equations

Get Linear Algebra & DE right, with Vipul Sir beside you.

Concept-first classes in small batches in Goregaon and Vile Parle, or online. Your first class is free.

WhatsApp↗