# Separation of variables

In mathematics, separation of variables (also known as the Fourier method) is any of several methods for solving ordinary and partial differential equations, in which algebra allows one to rewrite an equation so that each of two variables occurs on a different side of the equation.

Proportional first order differential equation
Linear first order differential equation

## Ordinary differential equations (ODE)

Suppose a differential equation can be written in the form

${\displaystyle {\frac {d}{dx}}f(x)=g(x)h(f(x))}$

which we can write more simply by letting ${\displaystyle y=f(x)}$ :

${\displaystyle {\frac {dy}{dx}}=g(x)h(y).}$

As long as h(y) ≠ 0, we can rearrange terms to obtain:

${\displaystyle {dy \over h(y)}=g(x)\,dx,}$

so that the two variables x and y have been separated. dx (and dy) can be viewed, at a simple level, as just a convenient notation, which provides a handy mnemonic aid for assisting with manipulations. A formal definition of dx as a differential (infinitesimal) is somewhat advanced.

### Alternative notation

Those who dislike Leibniz's notation may prefer to write this as

${\displaystyle {\frac {1}{h(y)}}{\frac {dy}{dx}}=g(x),}$

but that fails to make it quite as obvious why this is called "separation of variables". Integrating both sides of the equation with respect to ${\displaystyle x}$ , we have

${\displaystyle \int {\frac {1}{h(y)}}{\frac {dy}{dx}}\,dx=\int g(x)\,dx,\qquad \qquad (1)}$

or equivalently,

${\displaystyle \int {\frac {1}{h(y)}}\,dy=\int g(x)\,dx}$

because of the substitution rule for integrals.

If one can evaluate the two integrals, one can find a solution to the differential equation. Observe that this process effectively allows us to treat the derivative ${\displaystyle {\frac {dy}{dx}}}$  as a fraction which can be separated. This allows us to solve separable differential equations more conveniently, as demonstrated in the example below.

(Note that we do not need to use two constants of integration, in equation (1) as in

${\displaystyle \int {\frac {1}{h(y)}}\,dy+C_{1}=\int g(x)\,dx+C_{2},}$

because a single constant ${\displaystyle C=C_{2}-C_{1}}$  is equivalent.)

### Example

Population growth is often modeled by the differential equation

${\displaystyle {\frac {dP}{dt}}=kP\left(1-{\frac {P}{K}}\right)}$

where ${\displaystyle P}$  is the population with respect to time ${\displaystyle t}$ , ${\displaystyle k}$  is the rate of growth, and ${\displaystyle K}$  is the carrying capacity of the environment.

Separation of variables may be used to solve this differential equation.

{\displaystyle {\begin{aligned}&{\frac {dP}{dt}}=kP\left(1-{\frac {P}{K}}\right)\\[5pt]&\int {\frac {dP}{P\left(1-{\frac {P}{K}}\right)}}=\int k\,dt\end{aligned}}}

To evaluate the integral on the left side, we simplify the fraction

${\displaystyle {\frac {1}{P\left(1-{\frac {P}{K}}\right)}}={\frac {K}{P\left(K-P\right)}}}$

and then, we decompose the fraction into partial fractions

${\displaystyle {\frac {K}{P(K-P)}}={\frac {1}{P}}+{\frac {1}{K-P}}}$

Thus we have

{\displaystyle {\begin{aligned}&\int \left({\frac {1}{P}}+{\frac {1}{K-P}}\right)\,dP=\int k\,dt\\[6pt]&\ln {\begin{vmatrix}P\end{vmatrix}}-\ln {\begin{vmatrix}K-P\end{vmatrix}}=kt+C\\[6pt]&\ln {\begin{vmatrix}K-P\end{vmatrix}}-\ln {\begin{vmatrix}P\end{vmatrix}}=-kt-C\\[6pt]&\ln {\begin{vmatrix}{\cfrac {K-P}{P}}\end{vmatrix}}=-kt-C\\[6pt]&{\begin{vmatrix}{\dfrac {K-P}{P}}\end{vmatrix}}=e^{-kt-C}\\[6pt]&{\begin{vmatrix}{\dfrac {K-P}{P}}\end{vmatrix}}=e^{-C}e^{-kt}\\[6pt]&{\frac {K-P}{P}}=\pm e^{-C}e^{-kt}\\[6pt]{\text{Let }}&A=\pm e^{-C}.\\[6pt]&{\frac {K-P}{P}}=Ae^{-kt}\\[6pt]&{\frac {K}{P}}-1=Ae^{-kt}\\[6pt]&{\frac {K}{P}}=1+Ae^{-kt}\\[6pt]&{\frac {P}{K}}={\frac {1}{1+Ae^{-kt}}}\\[6pt]&P={\frac {K}{1+Ae^{-kt}}}\end{aligned}}}

Therefore, the solution to the logistic equation is

${\displaystyle P(t)={\frac {K}{1+Ae^{-kt}}}}$

To find ${\displaystyle A}$ , let ${\displaystyle t=0}$  and ${\displaystyle P\left(0\right)=P_{0}}$ . Then we have

${\displaystyle P_{0}={\frac {K}{1+Ae^{0}}}}$

Noting that ${\displaystyle e^{0}=1}$ , and solving for A we get

${\displaystyle A={\frac {K-P_{0}}{P_{0}}}.}$

### Generalization of separable ODEs to the nth order

Much like one can speak of a separable first-order ODE, one can speak of a separable second-order, third-order or nth-order ODE. Consider the separable first-order ODE:

${\displaystyle {\frac {dy}{dx}}=f(y)g(x)}$

The derivative can alternatively be written the following way to underscore that it is an operator working on the unknown function, y:
${\displaystyle {\frac {dy}{dx}}={\frac {d}{dx}}(y)}$

Thus, when one separates variables for first-order equations, one in fact moves the dx denominator of the operator to the side with the x variable, and the d(y) is left on the side with the y variable. The second-derivative operator, by analogy, breaks down as follows:
${\displaystyle {\frac {d^{2}y}{dx^{2}}}={\frac {d}{dx}}({\frac {dy}{dx}})={\frac {d}{dx}}({\frac {d}{dx}}(y))}$

The third-, fourth- and nth-derivative operators break down in the same way. Thus, much like a first-order separable ODE is reducible to the form
${\displaystyle {\frac {dy}{dx}}=f(y)g(x)}$

a separable second-order ODE is reducible to the form
${\displaystyle {\frac {d^{2}y}{dx^{2}}}=f(y')g(x)}$

and an nth-order separable ODE is reducible to
${\displaystyle {\frac {d^{n}y}{dx^{n}}}=f(y^{(n-1)})g(x)}$

### Example

Consider the simple nonlinear second-order differential equation:

${\displaystyle y''=(y')^{2}}$

This equation is an equation only of y'' and y', meaning it is reducible to the general form described above and is, therefore, separable. Since it is a second-order separable equation, collect all x variables on one side and all y' variables on the other to get:
${\displaystyle {\frac {d(y')}{(y')^{2}}}=dx}$

Now, integrate the right side with respect to x and the left with respect to y':
${\displaystyle \int {\frac {d(y')}{(y')^{2}}}=\int dx}$

This gives
${\displaystyle {\frac {-1}{y'}}=x+C_{1}}$

which simplifies to:
${\displaystyle y'={\frac {1}{C_{1}-x}}}$

This is now a simple integral problem that gives the final answer:
${\displaystyle y=C_{2}-\ln |C_{1}-x|}$

## Partial differential equations

The method of separation of variables is also used to solve a wide range of linear partial differential equations with boundary and initial conditions, such as the heat equation, wave equation, Laplace equation, Helmholtz equation and biharmonic equation.

The analytical method of separation of variables for solving partial differential equations has also been generalized into a computational method of decomposition in invariant structures that can be used to solve systems of partial differential equations.[1]

### Example: homogeneous case

Consider the one-dimensional heat equation. The equation is

${\displaystyle {\frac {\partial u}{\partial t}}-\alpha {\frac {\partial ^{2}u}{\partial x^{2}}}=0}$

(1)

The variable u denotes temperature. The boundary condition is homogeneous, that is

${\displaystyle u{\big |}_{x=0}=u{\big |}_{x=L}=0}$

(2)

Let us attempt to find a solution which is not identically zero satisfying the boundary conditions but with the following property: u is a product in which the dependence of u on x, t is separated, that is:

${\displaystyle u(x,t)=X(x)T(t).}$

(3)

Substituting u back into equation (1) and using the product rule,

${\displaystyle {\frac {T'(t)}{\alpha T(t)}}={\frac {X''(x)}{X(x)}}.}$

(4)

Since the right hand side depends only on x and the left hand side only on t, both sides are equal to some constant value − λ. Thus:

${\displaystyle T'(t)=-\lambda \alpha T(t),}$

(5)

and

${\displaystyle X''(x)=-\lambda X(x).}$

(6)

− λ here is the eigenvalue for both differential operators, and T(t) and X(x) are corresponding eigenfunctions.

We will now show that solutions for X(x) for values of λ ≤ 0 cannot occur:

Suppose that λ < 0. Then there exist real numbers B, C such that

${\displaystyle X(x)=Be^{{\sqrt {-\lambda }}\,x}+Ce^{-{\sqrt {-\lambda }}\,x}.}$

From (2) we get

${\displaystyle X(0)=0=X(L),}$

(7)

and therefore B = 0 = C which implies u is identically 0.

Suppose that λ = 0. Then there exist real numbers B, C such that

${\displaystyle X(x)=Bx+C.}$

From (7) we conclude in the same manner as in 1 that u is identically 0.

Therefore, it must be the case that λ > 0. Then there exist real numbers A, B, C such that

${\displaystyle T(t)=Ae^{-\lambda \alpha t},}$

and

${\displaystyle X(x)=B\sin({\sqrt {\lambda }}\,x)+C\cos({\sqrt {\lambda }}\,x).}$

From (7) we get C = 0 and that for some positive integer n,

${\displaystyle {\sqrt {\lambda }}=n{\frac {\pi }{L}}.}$

This solves the heat equation in the special case that the dependence of u has the special form of (3).

In general, the sum of solutions to (1) which satisfy the boundary conditions (2) also satisfies (1) and (3). Hence a complete solution can be given as

${\displaystyle u(x,t)=\sum _{n=1}^{\infty }D_{n}\sin {\frac {n\pi x}{L}}\exp \left(-{\frac {n^{2}\pi ^{2}\alpha t}{L^{2}}}\right),}$

where Dn are coefficients determined by initial condition.

Given the initial condition

${\displaystyle u{\big |}_{t=0}=f(x),}$

we can get

${\displaystyle f(x)=\sum _{n=1}^{\infty }D_{n}\sin {\frac {n\pi x}{L}}.}$

This is the sine series expansion of f(x). Multiplying both sides with ${\displaystyle \sin {\frac {n\pi x}{L}}}$  and integrating over [0,L] result in

${\displaystyle D_{n}={\frac {2}{L}}\int _{0}^{L}f(x)\sin {\frac {n\pi x}{L}}\,dx.}$

This method requires that the eigenfunctions of x, here ${\displaystyle \left\{\sin {\frac {n\pi x}{L}}\right\}_{n=1}^{\infty }}$ , are orthogonal and complete. In general this is guaranteed by Sturm-Liouville theory.

### Example: nonhomogeneous case

Suppose the equation is nonhomogeneous,

${\displaystyle {\frac {\partial u}{\partial t}}-\alpha {\frac {\partial ^{2}u}{\partial x^{2}}}=h(x,t)}$

(8)

with the boundary condition the same as (2).

Expand h(x,t), u(x,t) and f(x) into

${\displaystyle h(x,t)=\sum _{n=1}^{\infty }h_{n}(t)\sin {\frac {n\pi x}{L}},}$

(9)

${\displaystyle u(x,t)=\sum _{n=1}^{\infty }u_{n}(t)\sin {\frac {n\pi x}{L}},}$

(10)

${\displaystyle f(x)=\sum _{n=1}^{\infty }b_{n}\sin {\frac {n\pi x}{L}},}$

(11)

where hn(t) and bn can be calculated by integration, while un(t) is to be determined.

Substitute (9) and (10) back to (8) and considering the orthogonality of sine functions we get

${\displaystyle u'_{n}(t)+\alpha {\frac {n^{2}\pi ^{2}}{L^{2}}}u_{n}(t)=h_{n}(t),}$

which are a sequence of linear differential equations that can be readily solved with, for instance, Laplace transform, or Integrating factor. Finally, we can get

${\displaystyle u_{n}(t)=e^{-\alpha {\frac {n^{2}\pi ^{2}}{L^{2}}}t}\left(b_{n}+\int _{0}^{t}h_{n}(s)e^{\alpha {\frac {n^{2}\pi ^{2}}{L^{2}}}s}\,ds\right).}$

If the boundary condition is nonhomogeneous, then the expansion of (9) and (10) is no longer valid. One has to find a function v that satisfies the boundary condition only, and subtract it from u. The function u-v then satisfies homogeneous boundary condition, and can be solved with the above method.

### Example: mixed derivatives

For some equations involving mixed derivatives, the equation does not separate as easily as the heat equation did in the first example above, but nonetheless separation of variables may still be applied. Consider the two-dimensional biharmonic equation

${\displaystyle {\frac {\partial ^{4}u}{\partial x^{4}}}+2{\frac {\partial ^{4}u}{\partial x^{2}\partial y^{2}}}+{\frac {\partial ^{4}u}{\partial y^{4}}}=0.}$

Proceeding in the usual manner, we look for solutions of the form

${\displaystyle u(x,y)=X(x)Y(y)}$

and we obtain the equation

${\displaystyle {\frac {X^{(4)}(x)}{X(x)}}+2{\frac {X''(x)}{X(x)}}{\frac {Y''(y)}{Y(y)}}+{\frac {Y^{(4)}(y)}{Y(y)}}=0.}$

Writing this equation in the form

${\displaystyle E(x)+F(x)G(y)+H(y)=0,}$

we see that the derivative with respect to x and y eliminates the first and last terms, so that

${\displaystyle F'(x)G'(y)=0,}$

i.e. either F(x) or G(y) must be a constant, say -λ. This further implies that either ${\displaystyle -E(x)=F(x)G(y)+H(y)}$  or ${\displaystyle -H(y)=E(x)+F(x)G(y)}$  are constant. Returning to the equation for X and Y, we have two cases

{\displaystyle {\begin{aligned}X''(x)&=-\lambda _{1}X(x)\\X^{(4)}(x)&=\mu _{1}X(x)\\Y^{(4)}(y)-2\lambda _{1}Y''(y)&=-\mu _{1}Y(y)\end{aligned}}}

and

{\displaystyle {\begin{aligned}Y''(y)&=-\lambda _{2}Y(y)\\Y^{(4)}(y)&=\mu _{2}Y(y)\\X^{(4)}(x)-2\lambda _{2}X''(x)&=-\mu _{2}X(x)\end{aligned}}}

which can each be solved by considering the separate cases for ${\displaystyle \lambda _{i}<0,\lambda _{i}=0,\lambda _{i}>0}$  and noting that ${\displaystyle \mu _{i}=\lambda _{i}^{2}}$ .

### Curvilinear coordinates

In orthogonal curvilinear coordinates, separation of variables can still be used, but in some details different from that in Cartesian coordinates. For instance, regularity or periodic condition may determine the eigenvalues in place of boundary conditions. See spherical harmonics for example.

## Applicability

Partial differential equations

For many PDEs, such as the wave equation, Helmholtz equation and Schrodinger equation, the applicability of separation of variables is a result of the spectral theorem. In some cases, separation of variables may not be possible. Separation of variables may be possible in some coordinate systems but not others,[2] and which coordinate systems allow for separation depends on the symmetry properties of the equation.[3] Below is an outline of an argument demonstrating the applicability of the method to certain linear equations, although the precise method may differ in individual cases (for instance in the biharmonic equation above).

Consider an initial boundary value problem for a function ${\displaystyle u(x,t)}$  on ${\displaystyle D=\{(x,t):x\in [0,l],t\geq 0\}}$  in two variables:

${\displaystyle (Tu)(x,t)=(Su)(x,t)}$

where ${\displaystyle T}$  is a differential operator with respect to ${\displaystyle x}$  and ${\displaystyle S}$  is a differential operator with respect to ${\displaystyle t}$  with boundary data:

${\displaystyle (Tu)(0,t)=(Tu)(a)=0}$  for ${\displaystyle t\geq 0}$
${\displaystyle (Su)(x,0)=h(x)}$  for ${\displaystyle 0\leq x\leq a}$

where ${\displaystyle g}$  is a known function.

We look for solutions of the form ${\displaystyle u(x,t)=f(x)g(t)}$ . Dividing the PDE through by ${\displaystyle f(x)g(t)}$  gives

${\displaystyle {\frac {Tf}{f}}={\frac {Sg}{g}}}$

The right hand side depends only on ${\displaystyle x}$  and the left hand side only on ${\displaystyle t}$  so both must be equal to a constant ${\displaystyle K}$ , which gives two ordinary differential equations

${\displaystyle Tf=Kf,Sg=Kg}$

which we can recognize as eigenvalue problems for the operators for ${\displaystyle T}$  and ${\displaystyle S}$ . If ${\displaystyle T}$  is a compact, self-adjoint operator on the space ${\displaystyle L^{2}[0,l]}$  along with the relevant boundary conditions, then by the Spectral theorem there exists a basis for ${\displaystyle L^{2}[0,l]}$  consisting of eigenfunctions for ${\displaystyle T}$ . Let the spectrum of ${\displaystyle T}$  be ${\displaystyle E}$  and let ${\displaystyle f_{\lambda }}$  be an eigenfunction with eigenvalue ${\displaystyle \lambda \in E}$ . Then for any function which at each time ${\displaystyle t}$  is square-integrable with respect to ${\displaystyle x}$ , we can write this function as a linear combination of the ${\displaystyle f_{\lambda }}$ . In particular, we know the solution ${\displaystyle u}$  can be written as

${\displaystyle u(x,t)=\sum _{\lambda \in E}c_{\lambda }(t)f_{\lambda }(x)}$

For some functions ${\displaystyle c_{\lambda }(t)}$ . In the separation of variables, these functions are given by solutions to ${\displaystyle Sg=Kg}$

Hence, the spectral theorem ensures that the separation of variables will (when it is possible) find all the solutions.

For many differential operators, such as ${\displaystyle {\frac {d^{2}}{dx^{2}}}}$ , we can show that they are self-adjoint by integration by parts. While these operators may not be compact, their inverses (when they exist) may be, as in the case of the wave equation, and these inverses have the same eigenfunctions and eigenvalues as the original operator (with the possible exception of zero).[4]

## Matrices

The matrix form of the separation of variables is the Kronecker sum.

As an example we consider the 2D discrete Laplacian on a regular grid:

${\displaystyle L=\mathbf {D_{xx}} \oplus \mathbf {D_{yy}} =\mathbf {D_{xx}} \otimes \mathbf {I} +\mathbf {I} \otimes \mathbf {D_{yy}} ,\,}$

where ${\displaystyle \mathbf {D_{xx}} }$  and ${\displaystyle \mathbf {D_{yy}} }$  are 1D discrete Laplacians in the x- and y-directions, correspondingly, and ${\displaystyle \mathbf {I} }$  are the identities of appropriate sizes. See the main article Kronecker sum of discrete Laplacians for details.

## Software

Some mathematical programs are able to do separation of variables: Xcas[5] among others.