In mathematics, variation of parameters also known as variation of constants, is a general method to solve inhomogeneous linear ordinary differential equations. It was developed by the Italian-French mathematician Joseph Louis Lagrange.
For first-order inhomogeneous linear differential equations it's usually possible to find solutions via integrating factors or undetermined coefficients with considerably less effort, although those methods are rather heuristics that involve guessing and don't work for all inhomogenous linear differential equations.
Given an ordinary non-homogeneous linear differential equation of order n
. (i)
let
be a fundamental system of the corresponding homogeneous equation
(ii)
Then a particular solution to the non-homogeneous equation is given by
(iii)
where the
are continuous functions which satisfy the equations
(iv) (results from substitution of (iii) into the homogeneous case (ii); )
and
. (v)
(results from substitution of (iii) into (i) and applying (iv);
for all x and i is the only way to satisfy the condition, since all
are linearly independent. It implies that all
are independent of x in the homogeneous case b(x)=0. )
This linear system of n equations can then be solved using Cramer's rule yielding

where
is the Wronskian determinant of the fundamental system and
is the Wronskian determinant of the fundamental system with the i-th column replaced by
The particular solution to the non-homogeneous equation can then be written as
.
Examples
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

Form the characteristic equation


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


Because the Wronskian is non-zero, the general solution found for the differential equation is linearly independent so it is correct.
We seek functions A(x) and B(x) so A(x)u1+B(x)u2 is a general solution of the inhomogeneous equation. We need only calculate the integrals

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
. We desire A=A(x) and B=B(x) to be of the form

Now,



and since we have required the above condition, then we have

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,


Whilst homogeneous equations are relatively easy to solve, this method allows the calculation of the coefficients of the general solution of the inhomogeneous 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); one would expect two constants of integration because the original equation was second order. Adding a constant to
or
does not change the value of
because
is linear.