Skip to main content
Mathematics LibreTexts

2.4: Separation of Variables

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Solving many of the linear partial differential equations presented in the first section can be reduced to solving ordinary differential equations. We will demonstrate this by solving the initial-boundary value problem for the heat equation as given in (2.1.1). We will employ a method typically used in studying linear partial differential equations, called the Method of Separation of Variables. In the next subsections we describe how this method works for the one-dimensional heat equation, one-dimensional wave equation, and the two-dimensional Laplace equation.

    Heat Equation

    We want to solve the heat equation, \[u_t = ku_{xx},\quad 0 < t,\quad 0 ≤ x ≤ L.\nonumber\] subject to the boundary conditions \[u(0, t) = 0,\quad u(L, t) = 0,\quad t > 0,\nonumber\] and the initial condition \[u(x, 0) = f(x),\quad 0 < x < L.\nonumber\]

    We begin by assuming that \(u\) can be written as a product of single variable functions of each independent variable, \[u(x,t)=X(x)T(t).\nonumber\] Substituting this guess into the heat equation, we find that \[XT'=kX''T.\nonumber\]

    The prime denotes differentiation with respect to the independent variable and we will suppress the independent variable in the following unless needed for emphasis.

    Dividing both sides of this result by \(k\) and \(u = XT\), yields \[\frac{1}{k}\frac{T'}{T}=\frac{X''}{X}.\nonumber\]

    We have separated the functions of time on one side and space on the other side. The constant \(k\) could be on either side of this expression, but we moved it to make later computations simpler.

    The only way that a function of \(t\) equals a function of \(x\) is if the functions are constant functions. Therefore, we set each function equal to a constant, \(λ\) : [For example, if \(Ae^{ct} = ax^2 + b\) is possible for any \(x\) or \(t\), then this is only possible if \(a = 0\), \(c = 0\) and \(b = A\).]

    \[\underset{\text{function of }t}{\underbrace{\frac{1}{k}\frac{T'}{T}}} = \underset{\text{function of }x}{\underbrace{\frac{X''}{X}}}=\underset{\text{constant}}{\underbrace{\lambda.}} \nonumber\]

    This leads to two equations:

    \[T'=k\lambda T,\label{eq:1}\]

    \[X''=\lambda X.\label{eq:2}\]

    These are ordinary differential equations. The general solutions to these constant coefficient equations are readily found as

    \[T(t)=Ae^{k\lambda t},\label{eq:3}\]


    We need to be a little careful at this point. The aim is to force the final solutions to satisfy both the boundary conditions and initial conditions. Also, we should note that \(λ\) is arbitrary and may be positive, zero, or negative. We first look at how the boundary conditions on \(u(x, t)\) lead to conditions on \(X(x)\).

    The first boundary condition is \(u(0, t) = 0\). This implies that

    \[X(0)T(t)=0,\quad\text{for all }t.\nonumber\]

    The only way that this is true is if \(X(0) = 0\). Similarly, \(u(L, t) = 0\) for all \(t\) implies that \(X(L) = 0\). So, we have to solve the boundary value problem

    \[X''-\lambda X=0,\quad X(0)=0=X(L).\label{eq:5}\]

    An obvious solution is \(X ≡ 0\). However, this implies that \(u(x, t) = 0\), which is not an interesting solution. We call such solutions, \(X ≡ 0\), trivial solutions and will seek nontrivial solution for these problems.

    There are three cases to consider, depending on the sign of \(λ\).

    \(\lambda >0\)

    In this case we have the exponential solutions


    For \(X(0) = 0\), we have


    We will take \(c_2 = −c_1\). Then,


    Applying the second condition, \(X(L) = 0\) yields


    This will be true only if \(c_1 = 0\), since \(λ > 0\). Thus, the only solution in this case is the trivial solution, \(X(x) = 0\).

    \(\lambda =0\)

    For this case it is easier to set \(λ\) to zero in the differential equation. So, \(X'' = 0\). Integrating twice, one finds


    Setting \(x = 0\), we have \(c_2 = 0\), leaving \(X(x) = c_1x\). Setting \(x = L\), we find \(c_1L = 0\). So, \(c_1 = 0\) and we are once again left with a trivial solution.

    III. \(\lambda <0\)

    In this case is would be simpler to write \(λ = −µ^2\). Then the differential equation is


    The general solution is

    \[X(x)=c_1\cos\mu x+c_2\sin\mu x.\nonumber\]

    At \(x = 0\) we get \(0 = c_1\). This leaves \(X(x) = c_2 \sin µx\). At \(x = L\), we find

    \[0=c_2\sin\mu L.\nonumber\]

    So, either \(c_2 = 0\) or \(\sin µL = 0\). \(c_2 = 0\) leads to a trivial solution again. But, there are cases when the sine is zero. Namely,

    \[\mu L=n\pi ,\quad n=1,2,\ldots .\nonumber\]

    Note that \(n = 0\) is not included since this leads to a trivial solution. Also, negative values of \(n\) are redundant, since the sine function is an odd function.

    In summary, we can find solutions to the boundary value problem \(\eqref{eq:5}\) for particular values of \(λ\). The solutions are

    \[X_n(x)=\sin\frac{n\pi x}{L},\quad n=1,2,3,\ldots \nonumber\]


    \[\lambda_n=-\mu_n^2=-\left(\frac{n\pi}{L}\right)^2,\quad n=1,2,3,\ldots .\nonumber\]

    We should note that the boundary value problem in Equation \(\eqref{eq:5}\) is an eigenvalue problem. We can recast the differential equation as

    \[LX=\lambda X,\nonumber\]



    is a linear differential operator. The solutions, \(X_n(x)\), are called eigenfunctions and the \(λ_n\)’s are the eigenvalues. We will elaborate more on this characterization later in the next chapter.

    We have found the product solutions of the heat equation (2.1.1) satisfying the boundary conditions. These are

    \[\label{eq:7}u_n(x,t)=e^{k\lambda_n t}\sin\frac{n\pi x}{L},\quad n=1,2,3,\ldots .\]

    However, these do not necessarily satisfy the initial condition \(u(x, 0) = f(x)\). What we do get is

    \[u_n(x,0)=\sin\frac{n\pi x}{L},\quad n=1,2,3,\ldots .\nonumber\]

    So, if the initial condition is in one of these forms, we can pick out the right value for \(n\) and we are done.

    For other initial conditions, we have to do more work. Note, since the heat equation is linear, the linear combination of the product solutions is also a solution of the heat equation. The general solution satisfying the given boundary conditions is given as

    \[\label{eq:8}u(x,t)=\sum\limits_{n=1}^\infty b_ne^{k\lambda_nt}\sin\frac{n\pi x}{L}.\]

    The coefficients in the general solution are determined using the initial condition. Namely, setting \(t = 0\) in the general solution, we have

    \[f(x)=u(x,0)=\sum\limits_{n=1}^\infty b_n\sin\frac{n\pi x}{L}.\nonumber\]

    So, if we know \(f(x)\), can we find the coefficients, \(b_n\)? If we can, then we will have the solution to the full initial-boundary value problem.

    The expression for \(f(x)\) is a Fourier sine series. We will need to digress into the study of Fourier series in order to see how one can find the Fourier series coefficients given \(f(x)\). Before proceeding, we will show that this process is not uncommon by applying the Method of Separation of Variables to the wave equation in the next section.

    Wave Equation

    In this section we will apply the Method of Separation of Variables to the one dimensional wave equation, given by

    \[\label{eq:9}\frac{\partial^2u}{\partial^2t}=c^2\frac{\partial^2u}{\partial^2x},\quad t>0,\quad 0\leq xłL,\]

    subject to the boundary conditions

    \[u(0, t) = 0,\quad u(L, t) = 0,\quad t > 0,\nonumber\]

    and the initial conditions

    \[u(x, 0) = f(x),\quad u_t(x, 0) = g(x),\quad 0 < x < L.\nonumber\]

    This problem applies to the propagation of waves on a string of length \(L\) with both ends fixed so that they do not move. \(u(x, t)\) represents the vertical displacement of the string over time. The derivation of the wave equation assumes that the vertical displacement is small and the string is uniform. The constant \(c\) is the wave speed, given by


    where \(τ\) is the tension in the string and \(µ\) is the mass per unit length. We can understand this in terms of string instruments. The tension can be adjusted to produce different tones and the makeup of the string (nylon or steel, thick or thin) also has an effect. In some cases the mass density is changed simply by using thicker strings. Thus, the thicker strings in a piano produce lower frequency notes.

    The \(u_{tt}\) term gives the acceleration of a piece of the string. The \(u_{xx}\) is the concavity of the string. Thus, for a positive concavity the string is curved upward near the point of interest. Thus, neighboring points tend to pull upward towards the equilibrium position. If the concavity is negative, it would cause a negative acceleration.

    The solution of this problem is easily found using separation of variables. We let \(u(x, t) = X(x)T(t)\). Then we find


    which can be rewritten as


    Again, we have separated the functions of time on one side and space on the other side. Therefore, we set each function equal to a constant, \(λ\).

    \[\underset{\text{function of }t}{\underbrace{\frac{1}{c^2}\frac{T''}{T}}}=\underset{\text{function of }x}{\underbrace{\frac{X''}{X}}}=\underset{\text{constant}}{\underbrace{\lambda .}}\nonumber\]

    This leads to two equations:

    \[\label{eq:10}T''=c^2\lambda T,\]

    \[\label{eq:11}X''=\lambda X.\]

    As before, we have the boundary conditions on \(X(x)\):

    \[X(0)=0,\quad\text{and}\quad X(L)=0,\nonumber\]

    giving the solutions, as shown in Figure \(\PageIndex{1}\),

    \[X_n(x)=\sin\frac{n\pi x}{L},\quad\lambda_n =-\left(\frac{n\pi}{L}\right)^2.\nonumber\]

    Figure \(\PageIndex{1}\): The first three harmonics of the vibrating string.

    The main difference from the solution of the heat equation is the form of the time function. Namely, from Equation \(\eqref{eq:10}\) we have to solve

    \[\label{eq:12}T''+\left(\frac{n\pi c}{L}\right)^2T=0.\]

    This equation takes a familiar form. We let

    \[\omega_n=\frac{n\pi c}{L},\nonumber\]

    then we have


    This is the differential equation for simple harmonic motion and \(\omega_n\) is the angular frequency. The solutions are easily found as


    Therefore, we have found that the product solutions of the wave equation take the forms \(\sin\frac{n\pi x}{L}\cos \omega_n t\) and \(\sin\frac{n\pi x}{L}\sin\omega_n t\). The general solution, a superposition of all product solutions, is given by

    \[\label{eq:14}u(x,t)=\sum\limits_{n=1}^\infty\left[ A_n\cos\frac{n\pi ct}{L}+B_n\sin\frac{n\pi ct}{L}\right]\sin\frac{n\pi x}{L}.\]

    This solution satisfies the wave equation and the boundary conditions. We still need to satisfy the initial conditions. Note that there are two initial conditions, since the wave equation is second order in time.

    First, we have \(u(x, 0) = f(x)\). Thus,

    \[\label{eq:15}f(x)=u(x,0)=\sum\limits_{n=1}^\infty A_n\sin\frac{n\pi x}{L}.\]

    In order to obtain the condition on the initial velocity, \(u_t(x, 0) = g(x)\), we need to differentiate the general solution with respect to \(t\):

    \[\label{eq:16}u_t(x,t)=\sum\limits_{n=1}^\infty\frac{n\pi c}{L}\left[-A_n\sin\frac{n\pi ct}{L}+B_n\cos\frac{n\pi ct}{L}\right]\sin\frac{n\pi x}{L}.\]

    Then, we have from the initial velocity

    \[\label{eq:17}g(x)=u_t(x,0)=\sum\limits_{n=1}^\infty\frac{n\pi c}{L}B_n\sin\frac{n\pi x}{L}.\]

    So, applying the two initial conditions, we have found that \(f(x)\) and \(g(x)\), are represented as Fourier sine series. In order to complete the problem we need to determine the coefficients \(A_n\) and \(B_n\) for \(n = 1, 2, 3,\ldots\). Once we have these, we have the complete solution to the wave equation. We had seen similar results for the heat equation. In the next chapter we will find out how to determine these Fourier coefficients for such series of sinusoidal functions.

    This page titled 2.4: Separation of Variables is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Russell Herman via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.