---
title: Variation of Parameters
module: Second-Order Linear Equations
moduleNumber: 3
lessonNumber: 4
order: 304
summary: >
  Variation of parameters finds a particular solution of any nonhomogeneous
  linear equation from a fundamental set of the homogeneous one. Replacing the
  constants in the complementary solution by functions and imposing one
  convenient constraint reduces the problem to a two-by-two linear system whose
  solution is expressed through the Wronskian, giving an integral formula that
  works for forcing terms undetermined coefficients cannot touch.
topics: [Second-Order Linear Equations]
draft: false
sources:
  - book: Boyce
    ref: "Ch. 3 — §3.6 Variation of Parameters; Ch. 4 §4.4 The Method of Variation of Parameters"
  - book: Simmons
    ref: "Ch. 3 §19 The Method of Variation of Parameters; §23 Operator Methods"
---

The [undetermined-coefficients](/differential-equations/second-order-linear/nonhomogeneous-undetermined-coefficients)
method is fast but narrow: it applies only when the forcing $g(t)$ is a
polynomial, exponential, sine, cosine, or a product of these, and only when the
coefficients are constant. Forcing terms like $\tan t$, $\sec t$, or $1/t$ fall
outside it entirely, because their derivatives do not close into a finite
family, so no finite trial form exists. **Variation of parameters** removes that
restriction. Given any fundamental set of the homogeneous equation, it produces
a particular solution of the nonhomogeneous equation for an _arbitrary_
continuous $g$, as an explicit formula in two integrals. Those integrals must
still be evaluated, which is not always possible in closed form.

## Letting the constants vary

Start from the nonhomogeneous equation and its complementary solution,

$$
y'' + p(t)y' + q(t)y = g(t), \qquad y_c = c_1 y_1(t) + c_2 y_2(t),
$$

where $y_1, y_2$ are a fundamental set of the homogeneous equation. The
complementary solution has fixed constants $c_1, c_2$. The method,
originally Lagrange's, promotes those constants to functions and seeks a
particular solution of the form

$$
y = u_1(t)\, y_1(t) + u_2(t)\, y_2(t). \tag{V}
$$

This is one function $y$ but two unknowns $u_1, u_2$, so one extra condition
can be imposed. Differentiating (V),

$$
y' = u_1' y_1 + u_2' y_2 + u_1 y_1' + u_2 y_2'.
$$

To keep the second derivative free of $u_1'', u_2''$, impose one constraint,
using the extra freedom:

$$
u_1' y_1 + u_2' y_2 = 0. \tag{Constraint}
$$

With the constraint, $y' = u_1 y_1' + u_2 y_2'$, and differentiating again,

$$
y'' = u_1' y_1' + u_2' y_2' + u_1 y_1'' + u_2 y_2''.
$$

Substituting $y, y', y''$ into the equation and grouping, the terms multiplying
$u_1$ and $u_2$ are $L[y_1]$ and $L[y_2]$, both zero because $y_1, y_2$ solve the
homogeneous equation. What remains is

$$
u_1' y_1' + u_2' y_2' = g(t). \tag{Balance}
$$

$$
% caption: The derivation collapses a hard second-order problem into a linear
% two-by-two system for $u_1', u_2'$ by spending one imposed constraint.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  box/.style={draw, minimum width=44mm, minimum height=11mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2A6F97}
  \node[box] (a) at (0,0) {assume $y = u_1 y_1 + u_2 y_2$};
  \node[box] (b) at (0,-1.6) {impose $u_1' y_1 + u_2' y_2 = 0$};
  \node[box] (c) at (0,-3.2) {substitute into $L[y]=g$};
  \node[box, draw=acc, text=acc, thick] (d) at (6.6,-3.2) {$u_1' y_1' + u_2' y_2' = g$};
  \node[box, draw=acc, text=acc, thick] (e) at (6.6,-1.6) {solve the $2\times 2$ system};
  \node[box] (f) at (6.6,0) {integrate $u_1', u_2'$};
  \draw[->, acc, thick] (a) -- (b);
  \draw[->, acc, thick] (b) -- (c);
  \draw[->, acc, thick] (c) -- (d);
  \draw[->, acc, thick] (d) -- (e);
  \draw[->, acc, thick] (e) -- (f);
\end{tikzpicture}
$$

## Solving the system with the Wronskian

The constraint and the balance equation form a linear system in the unknowns
$u_1', u_2'$:

$$
\begin{aligned}
y_1\, u_1' + y_2\, u_2' &= 0, \\
y_1'\, u_1' + y_2'\, u_2' &= g.
\end{aligned}
$$

Its coefficient determinant is the **Wronskian** $W[y_1, y_2] = y_1 y_2' -
y_1' y_2$, which is nonzero because $y_1, y_2$ form a fundamental set. By
Cramer's rule,

$$
u_1'(t) = -\frac{y_2(t)\, g(t)}{W[y_1, y_2](t)}, \qquad
u_2'(t) = \frac{y_1(t)\, g(t)}{W[y_1, y_2](t)}.
$$

Division by $W$ is legitimate precisely because independence guarantees
$W \neq 0$. Integrating gives $u_1, u_2$, and (V) assembles the particular
solution.

$$
% caption: Cramer's rule on the two-by-two system delivers $u_1', u_2'$ as
% Wronskian ratios; the forcing $g$ enters each numerator, the denominator is
% always $W$.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  box/.style={draw, minimum width=40mm, minimum height=15mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2A6F97}
  \node[box] (sys) at (0,0)
    {$y_1\, u_1' + y_2\, u_2' = 0$\\[2pt] $y_1'\, u_1' + y_2'\, u_2' = g$};
  \node[box, draw=acc, text=acc, thick] (res) at (7.0,0)
    {$u_1' = -y_2\, g / W$\\[2pt] $u_2' = y_1\, g / W$};
  \draw[->, acc, thick] (sys) -- (res) node[midway, above, font=\scriptsize, text=black] {Cramer};
\end{tikzpicture}
$$

Choosing a definite lower limit of integration converts this into a closed
formula for a particular solution.

> **Theorem (Variation of parameters).** Let $p, q, g$ be continuous on an open
> interval $I$, and let $y_1, y_2$ be a fundamental set of solutions of
> $y'' + p(t)y' + q(t)y = 0$. Then a particular solution of
> $y'' + p(t)y' + q(t)y = g(t)$ is
> $$
> Y(t) = -y_1(t)\int_{t_0}^{t} \frac{y_2(s)\, g(s)}{W[y_1, y_2](s)}\, \d s
>        + y_2(t)\int_{t_0}^{t} \frac{y_1(s)\, g(s)}{W[y_1, y_2](s)}\, \d s,
> $$
> for any $t_0 \in I$. The general solution is $y = c_1 y_1 + c_2 y_2 + Y$.

The formula has two structural consequences.
It is written for an _arbitrary_ $g$, so it directly shows how the response
depends on the forcing, and with the lower limit chosen as the initial point it
produces the solution satisfying $y(t_0) = 0$, $y'(t_0) = 0$ automatically.

## Trigonometric-quotient forcing

A quotient of trigonometric functions cannot be handled by undetermined
coefficients, because its derivatives never close into a finite family.

> **Worked example (Tangent forcing).** Solve $y'' + 4y = 8\tan t$ on
> $-\tfrac{\pi}{2} < t < \tfrac{\pi}{2}$. The homogeneous equation
> $y'' + 4y = 0$ has fundamental set $y_1 = \cos 2t$, $y_2 = \sin 2t$, with
> Wronskian
> $$
> W = \cos 2t\,(2\cos 2t) - (-2\sin 2t)\sin 2t = 2.
> $$
> Then
> $$
> u_1' = -\frac{\sin 2t\,(8\tan t)}{2} = -4\sin 2t\tan t, \qquad
> u_2' = \frac{\cos 2t\,(8\tan t)}{2} = 4\cos 2t\tan t.
> $$
> Integrating (using double-angle identities to simplify) gives
> $u_1 = 4\sin t\cos t - 4t$ and $u_2 = 4\ln(\cos t) - 4\cos^2 t$, and
> assembling $Y = u_1\cos 2t + u_2\sin 2t$ reduces to
> $$
> Y = -4t\cos 2t + 4\ln(\cos t)\sin 2t
> $$
> after dropping terms that are already in $y_c$. The general solution is
> $y = c_1\cos 2t + c_2\sin 2t - 4t\cos 2t + 4\ln(\cos t)\sin 2t$.

No finite trial form could have produced the $\ln(\cos t)$ term, which is why
undetermined coefficients does not apply to $g = 8\tan t$.

$$
% caption: The tangent-forced solution lives only on the open interval
% $(a,b) = (-\pi/2, \pi/2)$ where $\tan t$ is continuous; the logarithmic term
% drives it to large negative values as $t$ nears either endpoint.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{2A6F97}
  \draw[->, thick] (-3.0,0) -- (3.0,0) node[right] {$t$};
  \draw[->, thick] (0,-2.4) -- (0,1.4) node[above] {$y$};
  \draw[black, dashed, thick] (-2.5,-2.4) -- (-2.5,1.2);
  \draw[black, dashed, thick] (2.5,-2.4) -- (2.5,1.2);
  \node[black, anchor=south, font=\scriptsize] at (2.5,1.2) {$t = b$};
  \node[black, anchor=south, font=\scriptsize] at (-2.5,1.2) {$t = a$};
  \node[anchor=north east, font=\scriptsize] at (-0.05,-0.05) {$0$};
  \draw[acc, very thick]
    (-2.42,-2.3) .. controls (-2.2,-0.9) and (-1.9,0.1) .. (-1.4,0.55)
    .. controls (-0.9,0.85) and (-0.4,0.9) .. (0,0.85)
    .. controls (0.4,0.9) and (0.9,0.85) .. (1.4,0.55)
    .. controls (1.9,0.1) and (2.2,-0.9) .. (2.42,-2.3);
\end{tikzpicture}
$$

$$
% caption: The variation-of-parameters pipeline for the worked example, from
% the fundamental set to the assembled particular solution.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  box/.style={draw, minimum width=34mm, minimum height=10mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2A6F97}
  \node[box] (a) at (0,0) {$y_1 = \cos 2t,\ y_2 = \sin 2t$};
  \node[box] (b) at (4.4,0) {$W = 2$};
  \node[box] (c) at (8.8,0) {$u_1', u_2'$ from $g = 8\tan t$};
  \node[box] (d) at (8.8,-1.7) {integrate: $u_1, u_2$};
  \node[box, draw=acc, text=acc, thick] (e) at (2.6,-1.7) {$Y = u_1 y_1 + u_2 y_2$};
  \draw[->, acc, thick] (a) -- (b);
  \draw[->, acc, thick] (b) -- (c);
  \draw[->, acc, thick] (c) -- (d);
  \draw[->, acc, thick] (d) -- (e);
\end{tikzpicture}
$$

A cosecant forcing is handled the same way, and the same fundamental set carries
it through.

> **Worked example (Cosecant forcing).** Solve $y'' + 4y = 3\csc t$ on
> $0 < t < \pi$. The fundamental set is again $y_1 = \cos 2t$, $y_2 = \sin 2t$
> with $W = 2$. Then
> $$
> u_1' = -\frac{\sin 2t\,(3\csc t)}{2} = -\frac{3(2\sin t\cos t)}{2\sin t}
>   = -3\cos t, \qquad
> u_2' = \frac{\cos 2t\,(3\csc t)}{2} = \tfrac{3}{2}\csc t - 3\sin t,
> $$
> using $\cos 2t = 1 - 2\sin^2 t$. Integrating,
> $$
> u_1 = -3\sin t, \qquad
> u_2 = \tfrac{3}{2}\ln(\csc t - \cot t) + 3\cos t.
> $$
> Assembling $Y = u_1\cos 2t + u_2\sin 2t$ and using
> $\sin 2t\cos t - \cos 2t\sin t = \sin t$,
> $$
> Y = 3\sin t + \tfrac{3}{2}\sin 2t\,\ln(\csc t - \cot t),
> $$
> so $y = c_1\cos 2t + c_2\sin 2t + 3\sin t +
> \tfrac{3}{2}\sin 2t\,\ln(\csc t - \cot t)$.

## The response kernel

Choosing the lower limit of integration as the initial point $t_0$ turns the
formula into the unique solution of the equation with zero initial data,
$y(t_0) = 0$, $y'(t_0) = 0$. Combining the two integrals under one sign,

$$
Y(t) = \int_{t_0}^{t}
  \frac{y_1(s)\, y_2(t) - y_1(t)\, y_2(s)}{W[y_1, y_2](s)}\, g(s)\, \d s
  = \int_{t_0}^{t} K(t, s)\, g(s)\, \d s.
$$

The kernel $K(t, s)$ depends only on the homogeneous solutions, not on the
forcing. For constant-coefficient equations it depends on $t$ and $s$ only
through the difference $t - s$, so $K = K(t - s)$ and the response is a
**convolution** of the kernel with the input,

$$
Y(t) = \int_{t_0}^{t} K(t - s)\, g(s)\, \d s.
$$

> **Worked example (Undamped harmonic kernel).** For $y'' + y = g(t)$ the
> fundamental set is $y_1 = \cos t$, $y_2 = \sin t$ with $W = 1$, and the kernel
> simplifies to $K(t - s) = \sin(t - s)$. The zero-initial-data solution is
> $$
> y(t) = \int_{t_0}^{t} \sin(t - s)\, g(s)\, \d s,
> $$
> the running weighted accumulation of past forcing.

$$
% caption: The response weights past input by the kernel $\sin(t-s)$: the weight
% is zero at the present instant $s=t$ and oscillates back over earlier times.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{2A6F97}
  \draw[->, thick] (-0.3,0) -- (6.6,0) node[right] {$s$};
  \draw[->, thick] (0,-1.4) -- (0,1.6) node[above] {weight $K$};
  \draw[acc, very thick]
    (0.2,-0.62) .. controls (0.9,-1.15) and (1.7,-1.0) .. (2.4,-0.2)
    .. controls (3.0,0.5) and (3.6,1.05) .. (4.3,1.02)
    .. controls (4.9,0.98) and (5.4,0.55) .. (6.0,0.0);
  \draw[black, dashed] (6.0,-0.05) -- (6.0,0.9);
  \node[black, anchor=north, font=\scriptsize] at (6.0,-0.08) {$s=t$};
  \node[black, anchor=north, font=\scriptsize] at (0.2,-0.08) {$s=t_0$};
\end{tikzpicture}
$$

Reading $g$ as the input and $Y$ as the output: the output at time $t$ is a
weighted sum of the input over the entire interval up to $t$, with the kernel
supplying the weights. Once $K$ is known, every forcing $g$ is handled by a single
integral, and the same structure reappears in the
[Laplace-transform](/differential-equations/laplace/step-impulse-convolution)
treatment of convolution, where $K$ is the inverse transform of the transfer
function.

## Comparison of the two methods

Variation of parameters is universal but computational; undetermined
coefficients is restricted but algebraic. The choice is usually clear from the
forcing term and the coefficients.

| | Undetermined coefficients | Variation of parameters |
| --- | --- | --- |
| Coefficients | constant only | any (given a fundamental set) |
| Forcing $g$ | polynomial, exp, sin, cos, products | any continuous function |
| Work involved | solve linear equations for constants | evaluate two integrals |
| Resonance | handled by multiplying trial by $t$ | automatic, no special case |
| Fails when | $g$ outside the trial families | integrals have no closed form |

A practical rule: if $g$ fits the trial families and the coefficients are
constant, undetermined coefficients is less work; otherwise variation of
parameters is the method that applies. When both apply they give the same
particular solution up to a complementary piece.

## The operator viewpoint

There is also an operator formulation. Writing the equation with
the differential operator $L = D^2 + bD + c = (D - r_1)(D - r_2)$, where
$r_1, r_2$ are the characteristic roots, turns solving $L[y] = g$ into inverting
a product of first-order operators. Each factor $(D - r)y = h$ is a first-order
linear equation solved by an integrating factor, so the second-order problem
unwinds as two successive first-order integrations. This **operator method**
recovers the same integral structure as the variation-of-parameters
formula.[^simmons23]

The formula extends to $n$-th order with an $n \times n$ Wronskian, and the same
determinant construction underlies nonhomogeneous linear systems through the
fundamental matrix.[^boyce36][^boyce44]

[^boyce36]: **Boyce**, _Elementary Differential Equations_, §3.6 — Variation of Parameters: Lagrange's substitution $y = u_1 y_1 + u_2 y_2$, the constraint $u_1'y_1 + u_2'y_2 = 0$, the Wronskian formulas for $u_1', u_2'$, the general integral formula (Theorem 3.6.1), and the $y'' + 4y = 8\tan t$ example.
[^boyce44]: **Boyce**, _Elementary Differential Equations_, §4.4 — The Method of Variation of Parameters: the extension of the formula to $n$-th order linear equations using the $n \times n$ Wronskian and its cofactors.
[^simmons23]: **Simmons**, _Differential Equations with Applications and Historical Notes_, §19 The Method of Variation of Parameters; §23 Operator Methods: the variation construction and the factored-operator $(D - r_1)(D - r_2)$ approach to nonhomogeneous constant-coefficient equations.
