# 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.

## Ordinary differential equations (ODE)

Suppose a differential equation can be written in the form

${\frac {d}{dx}}f(x)=g(x)h(f(x))$ which we can write more simply by letting $y=f(x)$ :

${\frac {dy}{dx}}=g(x)h(y).$ As long as h(y) ≠ 0, we can rearrange terms to obtain:

${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

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

${\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 $x$ , we have

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

$\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 ${\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

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

Population growth is often modeled by the differential equation

${\frac {dP}{dt}}=kP\left(1-{\frac {P}{K}}\right)$ Separation of variables may be used to solve this differential equation.

${\frac {dP}{dt}}=kP\left(1-{\frac {P}{K}}\right)$ $\int {\frac {dP}{P\left(1-{\frac {P}{K}}\right)}}=\int k\,dt$ To evaluate the integral on the left side, we simplify the fraction

${\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

${\frac {K}{P\left(K-P\right)}}={\frac {1}{P}}+{\frac {1}{K-P}}$ Thus we have

$\int \left({\frac {1}{P}}+{\frac {1}{K-P}}\right)\,dP=\int k\,dt$ $\ln {\begin{vmatrix}P\end{vmatrix}}-\ln {\begin{vmatrix}K-P\end{vmatrix}}=kt+C$ $\ln {\begin{vmatrix}K-P\end{vmatrix}}-\ln {\begin{vmatrix}P\end{vmatrix}}=-kt-C$ $\ln {\begin{vmatrix}{\cfrac {K-P}{P}}\end{vmatrix}}=-kt-C$ ${\begin{vmatrix}{\cfrac {K-P}{P}}\end{vmatrix}}=e^{-kt-C}$ ${\begin{vmatrix}{\cfrac {K-P}{P}}\end{vmatrix}}=e^{-C}e^{-kt}$ ${\frac {K-P}{P}}=\pm e^{-C}e^{-kt}$ Let $A=\pm e^{-C}$ .
${\frac {K-P}{P}}=Ae^{-kt}$ ${\frac {K}{P}}-1=Ae^{-kt}$ ${\frac {K}{P}}=1+Ae^{-kt}$ ${\frac {P}{K}}={\frac {1}{1+Ae^{-kt}}}$ $P={\frac {K}{1+Ae^{-kt}}}$ Therefore, the solution to the logistic equation is

$P\left(t\right)={\frac {K}{1+Ae^{-kt}}}$ $P_{0}={\frac {K}{1+Ae^{0}}}$ $A={\frac {K-P_{0}}{P_{0}}}$ ## Partial differential equations{{safesubst:#invoke:anchor|main}}

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 heat equation, wave equation, Laplace equation and Helmholtz equation.

### Homogeneous case

Consider the one-dimensional heat equation.The equation is

The boundary condition is homogeneous, that is Template:NumBlk

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:

Substituting u back into equation and using the product rule,

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:

and

− λ 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

$X(x)=Be^{{\sqrt {-\lambda }}\,x}+Ce^{-{\sqrt {-\lambda }}\,x}.$ From Template:EqNote we get

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

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

$X(x)=Bx+C.$ From Template:EqNote 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

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

$X(x)=B\sin({\sqrt {\lambda }}\,x)+C\cos({\sqrt {\lambda }}\,x).$ From Template:EqNote we get C = 0 and that for some positive integer n,

${\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 Template:EqNote.

In general, the sum of solutions to Template:EqNote which satisfy the boundary conditions Template:EqNote also satisfies Template:EqNote and Template:EqNote. Hence a complete solution can be given as

$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

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

$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 $\sin {\frac {n\pi x}{L}}$ and integrating over [0,L] result in

$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 $\left\{\sin {\frac {n\pi x}{L}}\right\}_{n=1}^{\infty }$ , are orthogonal and complete. In general this is guaranteed by Sturm-Liouville theory.

### Nonhomogeneous case

Suppose the equation is nonhomogeneous,

with the boundary condition the same as Template:EqNote.

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

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

Substitute Template:EqNote and Template:EqNote back to Template:EqNote and considering the orthogonality of sine functions we get

$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

$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 Template:EqNote and Template:EqNote 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.

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.

## 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:

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