In mathematics, variation of parameters, also known as variation of constants, is a general method to solve inhomogeneous linear ordinary differential equations.
For first-order inhomogeneous linear differential equations it is usually possible to find solutions via integrating factors or undetermined coefficients with considerably less effort, although those methods leverage heuristics that involve guessing and do not work for all inhomogeneous linear differential equations.
Variation of parameters extends to linear partial differential equations as well, specifically to inhomogeneous problems for linear evolution equations like the heat equation, wave equation, and vibrating plate equation. In this setting, the method is more often known as Duhamel's principle, named after Jean-Marie Duhamel (1797–1872) who first applied the method to solve the inhomogeneous heat equation. Sometimes variation of parameters itself is called Duhamel's principle and vice versa.
Intuitive explanation
Consider the equation of the forced dispersionless spring, in suitable units:

Here x is the displacement of the spring from the equilibrium
, and F(t) is an external applied force that depends on time. When the external force is zero, this is the homogeneous equation (whose solutions are linear combinations of sines and cosines, corresponding to the spring oscillating with constant total energy).
We can construct the solution physically, as follows. Between times
and
, the momentum corresponding to the solution has a net change
(see: Impulse (physics)). A solution to the inhomogeneous equation, at the present time t > 0, is obtained by linearly superposing the solutions obtained in this manner, for s going between 0 and t.
The homogeneous initial-value problem, representing a small impulse
being added to the solution at time
, is

The unique solution to this problem is easily seen to be
. The linear superposition of all of these solutions is given by the integral:

To verify that this satisfies the required equation:


as required (see: Leibniz integral rule).
The general method of variation of parameters allows for solving an inhomogeneous linear equation

by means of considering the second-order linear differential operator L to be the net force, thus the total impulse imparted to a solution between time s and s+ds is F(s)ds. Denote by
the solution of the homogeneous initial value problem

Then a particular solution of the inhomogeneous equation is

the result of linearly superposing the infinitesimal homogeneous solutions. There are generalizations to higher order linear differential operators.
In practice, variation of parameters usually involves the fundamental solution of the homogeneous problem, the infinitesimal solutions
then being given in terms of explicit linear combinations of linearly independent fundamental solutions. In the case of the forced dispersionless spring, the kernel
is the associated decomposition into fundamental solutions.
Description of method (Second Order)
Consider a general second order linear nonhomogeneous differential equation whose coefficient functions
,
, and
are continuous:
The corresponding second order linear homogeneous differential equation is thus
. Suppose that we know the general solution to the corresponding second order linear homogeneous differential equation in terms of two functions
and
which form a fundamental set of solutions to the corresponding second order linear homogeneous differential equation, say
.
We will now replace the constants
and
with functions,
and
to get:
We then want to try and determine what functions
and
make
a particular solution to our original second order linear nonhomogeneous differential equation. We first differentiate
and apply the product rule where appropriate to get:
Now we will set the terms containing the derivatives of the functions
and
to equal zero, that is
. Note that this is a rather hefty assumption, however, this assumption is not rash as we're looking only for a particular solution, namely one for which this property holds. We'll see that making this assumption does not lead to any contradictions, and so:
We now differentiate again by applying the product rule where appropriate to get the second derivative of
:
We will now plug in
,
, and
into our second order linear nonhomogeneous differential equation to get that:
Now recall that we supposed that
. To solve for
and
, then all we need to do is solve the following system of equations:
Recall that a unique solution exists provided that the determinant
is nonzero. But this determinant is identically the Wronskian
, and it is assumed that this Wronskian is nonzero since
and
form the general solution of the corresponding second order linear homogeneous differential equation, and so by apply Cramer's rule, the values of
and
are:
We now integrate both sides of each equation above, and for constants
and
, we get
and
:
Therefore, a particular solution to our second order linear nonhomogeneous differential equation is:
And finally, the general solution to our differential equation will be:
Note that the method of variation of parameters is useful provided that the general solution to the corresponding second order linear homogeneous differential equation is easy to solve, and provided that the two integrals in the formula above are relatively simply to compute.
Examples
First-order equation

The general solution of the corresponding homogeneous equation (written below) is the complementary solution to our original (inhomogeneous) equation:
.
This homogeneous differential equation can be solved by different methods, for example separation of variables:






The complementary solution to our original equation is therefore:

Now we return to solving the non-homogeneous equation:

Using the method variation of parameters, the particular solution is formed by multiplying the complementary solution by an unknown function C(x):

By substituting the particular solution into the non-homogeneous equation, we can find C(x):




We only need a single particular solution, so we arbitrarily select
for simplicity. Therefore the particular solution is:

The final solution of the differential equation is:

This recreates the method of integrating factors.
Specific second-order equation
Let us solve

We want to find the general solution to the differential equation, that is, we want to find solutions to the homogeneous differential equation

The characteristic equation is:

Since
is a repeated root, we have to introduce a factor of x for one solution to ensure linear independence: u1 = e−2x and u2 = xe−2x. The Wronskian of these two functions is

Because the Wronskian is non-zero, the two functions are linearly independent, so this is in fact the general solution for the homogeneous differential equation (and not a mere subset of it).
We seek functions A(x) and B(x) so A(x)u1 + B(x)u2 is a particular solution of the non-homogeneous equation. We need only calculate the integrals

Recall that for this example

That is,


where
and
are constants of integration.
General second-order equation
We have a differential equation of the form

and we define the linear operator

where D represents the differential operator. We therefore have to solve the equation
for
, where
and
are known.
We must solve first the corresponding homogeneous equation:

by the technique of our choice. Once we've obtained two linearly independent solutions to this homogeneous differential equation (because this ODE is second-order) — call them u1 and u2 — we can proceed with variation of parameters.
Now, we seek the general solution to the differential equation
which we assume to be of the form

Here,
and
are unknown and
and
are the solutions to the homogeneous equation. (Observe that if
and
are constants, then
.) Since the above is only one equation and we have two unknown functions, it is reasonable to impose a second condition. We choose the following:

Now,

Differentiating again (omitting intermediary steps)

Now we can write the action of L upon uG as

Since u1 and u2 are solutions, then

We have the system of equations

Expanding,

So the above system determines precisely the conditions


We seek A(x) and B(x) from these conditions, so, given

we can solve for (A′(x), B′(x))T, so

where W denotes the Wronskian of u1 and u2. (We know that W is nonzero, from the assumption that u1 and u2 are linearly independent.) So,

While homogeneous equations are relatively easy to solve, this method allows the calculation of the coefficients of the general solution of the in homogeneous equation, and thus the complete general solution of the inhomogeneous equation can be determined.
Note that
and
are each determined only up to an arbitrary additive constant (the constant of integration). Adding a constant to
or
does not change the value of
because the extra term is just a linear combination of u1 and u2, which is a solution of
by definition.
Higher Order
The method of variation of parameters can also be applied to higher order differential equations. The process can be derived similarly. Suppose that we have a higher order differential equation of the following form:
We first solve the corresponding homogeneous differential equation to get
. The functions
,
, …,
form a fundamental set. Assume a particular solution to the nonhomogeneous differential equation is of the form:
We then solve the following system of equations for the functions
,
, …,
.
Once again, a unique solution is guaranteed since
,
, …,
form a fundamental set of solutions implies the Wronskian
is nonzero. Furthermore, it should be noted that the system above can be solved for with row reduction (if the process is simple) or more commonly by applying Cramer's rule once again.
We then integrate each of the functions
,
, …,
to obtain
,
, …,
. Lastly, we obtain that
as our particular solution.
We will now look at an example of using the method of variation of parameters for higher order nonhomogeneous differential equations.
Example 1
Solve the third order linear nonhomogeneous differential equation
using the method of variation of parameters.
For the corresponding homogeneous differential equation
we have that the characteristic equation is
which can be factored as
and so
or
. The solution to the corresponding homogeneous differential equation is therefore:
Furthermore,
,
, and
.
Now let's try to find a particular solution to this differential equation. We have that:
Thus we want to solve the following system of equations:
We will use Cramer's rule in order to solve for
,
, and
. We first find the corresponding Wronskian:
Now we have that:
We will now integrate
,
, and
to get:
Thus we have that:
Licensing
Content obtained and/or adapted from: