Unit 7 · Topic 7.6

Separate variables

Builds on antiderivatives, the chain rule, and slope fields with their constant solutions. 15 minutes.

  1. Example 1Recognize a separable equation
  2. Example 2Integrate both sides
  3. Example 3Recover an explicit family when possible
  4. Example 4Keep solutions lost through division
  5. Example 5State relevant domain restrictions

A differential equation \(\frac{dy}{dx}=F(x,y)\) gives the slope of a solution at each point, and a slope field shows its solutions without formulas (topic 7.4). The equation is separable if its right side is a function of \(x\) alone times a function of \(y\) alone:

\[\frac{dy}{dx}=g(x)\,h(y)\]

For such an equation, a method called separation of variables finds formulas for the solutions. This topic shows how to recognize one and find its general solution, the set of all its solutions. The general solution is usually one formula with an arbitrary constant, sometimes with constant solutions beside it, and each solution is defined on an interval.

Separating the variables

The slope field of dy/dx = 2x(y − 1), whose segments are flat along the y-axis and along a dashed row at y = 1. A chalk curve, the solution through the chalk dot (0, 2), is shaped like a U above the dashed row. Faint solutions lie above and below the row, and none crosses it. An orange point moves along the chalk curve. Below the field, the region between the line g(x) = 2x and its axis is shaded teal from x = 0 to the point, with an orange edge at the point. At the left, the region between the graph of 1/(y − 1), turned on its side, and its axis is shaded teal from y = 2 to the point's height, with an orange edge there. Two numbers under the figure give the two areas, which stay equal.

Figure 1The chalk curve is the solution of \(\frac{dy}{dx}=2x(y-1)\) through the start \((0,2)\). The faint curves are other solutions, and the dashed row is the constant solution \(y=1\). Each teal region runs from the start's \(x\) or \(y\) to the orange point's, where it ends in an orange edge.

To recognize a separable equation, try to factor its right side into a factor with only \(x\) and a factor with only \(y\). The product may be hidden, as in \(e^{x-y}=e^{x}e^{-y}\) or \(x^2y-3x^2=x^2(y-3)\). A constant counts as a function of \(x\), so \(\frac{dy}{dx}=h(y)\) is separable too.

A product also shows in the slope field. If \(g(a)=0\), the slope \(g(a)\,h(y)\) is 0 for every \(y\), so every segment in the column \(x=a\) is flat. In the same way, if \(h(c)=0\), every segment in the row \(y=c\) is flat. A point where a product is 0 therefore lies on a flat column or a flat row. In Figure 1, the field of \(\frac{dy}{dx}=2x(y-1)\) is flat on the \(y\)-axis and on the dashed row \(y=1\). For \(\frac{dy}{dx}=x+y\), the slope is 0 at the origin. Its row is the \(x\)-axis, where the slope is \(x\), and its column is the \(y\)-axis, where the slope is \(y\). Neither is flat, so the equation is not separable.

To separate the variables, divide both sides by \(h(y)\). You cannot divide by 0, so this step assumes that \(h(y)\neq0\). The result, \(\frac{1}{h(y)}\frac{dy}{dx}=g(x)\), is written in the separated form, with each variable on its own side:

\[\frac{1}{h(y)}\,dy=g(x)\,dx\]

In Figure 1, \(g(x)=2x\) and \(h(y)=y-1\), so the separated form is \(\frac{dy}{y-1}=2x\,dx\) wherever \(y\neq1\).

Integrating both sides

Below the field in Figure 1 is the graph of \(g\). At the left of the field, turned on its side so that its values run to the right, is the graph of \(\frac{1}{h(y)}=\frac{1}{y-1}\). The orange point moves along the solution through the start \((0,2)\). The teal region below lies between the graph of \(g\) and its axis, from the start's \(x\)-value to the point's. The teal region at the left lies between the graph of \(\frac1h\) and its axis, from the start's \(y\)-value to the point's. Each region has an orange edge at the point. Move the point. The numbers under the figure show that the two areas stay equal.

With \((x_0,y_0)\) for the start and \(\cy{(x,y)}\) for the point, the two areas are the two sides of

\[\cb{\int_{y_0}^{y}\frac{ds}{h(s)}}=\cb{\int_{x_0}^{x}g(t)\,dt}\]

Both sides are 0 at the start. By the Fundamental Theorem of Calculus, Part 1 (topic 6.4), the right side changes at the rate \(\cy{g(x)}\) for each unit of \(x\). That rate is the height of the orange edge below. In the same way, the left side changes at the rate \(\cy{\frac{1}{h(y)}}\) for each unit of \(y\). That rate is the length of the orange edge at the left. Along the solution, \(y\) moves \(g(x)\,h(y)\) units for each unit of \(x\). By the chain rule, the left side therefore changes at the rate \(\frac{1}{h(y)}\cdot g(x)\,h(y)=g(x)\) too. Two functions with the same derivative on an interval differ by a constant (topic 6.8). Here that constant is 0, so the two areas are equal along the whole solution.

The argument needs \(g\) and \(\frac1h\) to be continuous, so \(h\) must be continuous and never 0 on the values of \(y\) along the solution. Near the dashed row, \(\frac1h\) is unbounded, because \(h(1)=0\).

Let \(H\) be an antiderivative of \(\frac1h\) and \(G\) an antiderivative of \(g\). By the Fundamental Theorem of Calculus, Part 2 (topic 6.7), the two areas are \(H(y)-H(y_0)\) and \(G(x)-G(x_0)\). The difference \(H(y)-G(x)\) therefore has one value along the whole solution, its value at the start. Call it \(C\). Every solution on which \(h(y)\neq0\) satisfies \(H(y)=G(x)+C\).

In practice, you integrate each side of the separated form with respect to its own variable. Each side has a constant of integration, and their difference is one arbitrary constant, written on the side of \(x\). For Figure 1, \(\ln|y-1|\) is an antiderivative of \(\frac{1}{y-1}\), so

\[\ln|y-1|=x^2+C\]

Conversely, if a differentiable function \(y\) satisfies \(H(y)=G(x)+C\), implicit differentiation (topic 3.2) gives \(\frac{1}{h(y)}\frac{dy}{dx}=g(x)\). Multiplying by \(h(y)\) returns the differential equation, so \(y\) is a solution. An equation in \(x\) and \(y\) that describes the solutions without solving for \(y\) is called an implicit solution.

The general solution

When it is possible, solve the implicit solution for \(y\). This writes each solution as a function of \(x\), an explicit solution. For Figure 1, raise \(e\) to the power of each side of \(\ln|y-1|=x^2+C\):

\[|y-1|=e^{x^2+C}=e^{C}e^{x^2}\]

Along a solution with \(y\neq1\), the continuous function \(y-1\) is never 0, so by the Intermediate Value Theorem it keeps one sign (topic 1.16). Either \(y-1=e^{C}e^{x^2}\) at every \(x\), or \(y-1=-e^{C}e^{x^2}\) at every \(x\). With \(A\) equal to \(e^{C}\) or \(-e^{C}\), which can be any number except 0, every such solution is

\[y=1+Ae^{x^2}\]

Dividing by \(y-1\) left out the dashed row. The constant function \(y=1\) is a solution too, because its derivative is 0 and \(2x(1-1)=0\). It is the formula with \(A=0\). The right side \(2x(y-1)\) is a polynomial, so by the Existence and Uniqueness Theorem (topic 7.4), different solutions never meet. In particular, a solution other than \(y=1\) never reaches the row. The general solution is therefore \(y=1+Ae^{x^2}\), where \(A\) is any real number, and each solution is defined for every \(x\). For any equation \(\frac{dy}{dx}=g(x)\,(y-c)\), the same steps turn \(\ln|y-c|=G(x)+C\) into \(y=c+Ae^{G(x)}\).

In general, solve \(h(y)=0\) before you divide by \(h(y)\). Each zero \(c\) gives a constant solution \(y=c\), or equilibrium solution, because both sides of the equation are 0 for it. The formula from the separated form may leave it out. For \(\frac{dy}{dx}=(y-1)^2\), dividing by \((y-1)^2\) and integrating gives

\[\begin{aligned}-\frac{1}{y-1}&=x+C\\y&=1-\frac{1}{x+C}\end{aligned}\]

This formula is never 1. The right side is again a polynomial, so the general solution is this formula together with the constant solution \(y=1\).

The slope field of dy/dx = (y − 1)², whose segments are flat along a dashed row at y = 1 and steep far from it. A chalk curve through an orange dot at (0, 2) rises from the left edge toward a vertical asymptote at x = 1, and stays above the dashed row. A faint curve with the same formula rises from the bottom edge, right of x = 1, toward the dashed row. Dragging the dot, or the sliders, moves the start. A button puts the dot on the dashed row; the solution is then the row itself, and the faint curve disappears.

Figure 2The chalk curve is the solution of \(\frac{dy}{dx}=(y-1)^2\) through the orange dot, and the dashed row is the constant solution \(y=1\). The faint curve has the same formula on the other side of its vertical asymptote.

Drag the orange dot in Figure 2, or use its sliders. The chalk curve, the solution through the dot, never crosses the dashed row. Then use the button to put the dot on the row. The solution through the dot is now the row itself, which no value of \(C\) gives.

The formula \(1-\frac{1}{x+C}\) also shows a domain restriction. It has no value at \(x=-C\), and near that input its graph has a vertical asymptote. A solution is a differentiable function on an interval (topic 7.2), so each value of \(C\) gives two solutions, one for \(x<-C\) and one for \(x>-C\). In Figure 2, the faint curve has the same formula as the chalk curve, on the other side of the asymptote. In general, a solution's interval leaves out the inputs where its formula has no value. Its graph also avoids the points where the equation has none, as in Example 3.

Example 1

Recognize a separable equation

Is \(\dfrac{dy}{dx}=xy+2y-x-2\) separable? Is \(\dfrac{dy}{dx}=xy-6\)? Write each separable equation with each variable on its own side.

Solution

In the first equation, group the terms that contain \(y\). Both groups then share the factor \(x+2\):

\[\begin{aligned}&xy+2y-x-2\\&=y(x+2)-(x+2)\\&=(x+2)(y-1)\end{aligned}\]

The right side is a function of \(x\) times a function of \(y\), so the equation is separable. Where \(y\neq1\), dividing both sides by \(y-1\) gives

\[\frac{dy}{y-1}=(x+2)\,dx\]

In the second equation, the right side \(xy-6\) is 0 at \((2,3)\). A product \(g(x)\,h(y)\) that is 0 there is 0 on the whole column \(x=2\) or on the whole row \(y=3\). On the axes, however, \(xy=0\), so the right side is \(-6\) at \((2,0)\) and at \((0,3)\). It is therefore not such a product, and the equation is not separable.

Example 2

Integrate both sides

Find the general solution of \(\dfrac{dy}{dx}=\dfrac{2x}{2+\cos y}\).

Solution

The denominator \(2+\cos y\) is at least 1, so the right side is defined everywhere, and \(h(y)=\frac{1}{2+\cos y}\) is never 0. The equation has no constant solution, and multiplying both sides by \((2+\cos y)\,dx\) loses nothing. Integrate each side with respect to its own variable, with one constant:

\[\begin{aligned}(2+\cos y)\,dy&=2x\,dx\\2y+\sin y&=x^2+C\end{aligned}\]

No algebra isolates \(y\), so the general solution stays in this implicit form. Each curve is still the graph of a solution defined for every \(x\). The derivative of \(2y+\sin y\) with respect to \(y\) is \(2+\cos y\ge1\), so this expression increases at least as fast as \(y\). By the Intermediate Value Theorem, it therefore takes each real value at exactly one \(y\). That \(y\) is a differentiable function of \(x\) (topic 3.3).

Example 3

Recover an explicit family when possible

Find the general solution of \(\dfrac{dy}{dx}=\dfrac{3x^2}{2y}\). Write the solutions as explicit functions of \(x\).

Solution

The equation has no value where \(y=0\), so no solution reaches the \(x\)-axis. Multiplying both sides by \(2y\,dx\) and integrating gives

\[\begin{aligned}2y\,dy&=3x^2\,dx\\y^2&=x^3+C\end{aligned}\]

A solution is continuous and never 0, so by the Intermediate Value Theorem it keeps one sign. Solving for \(y\) therefore gives two functions, called branches, one for the positive solutions and one for the negative ones:

\[\begin{aligned}y&=\sqrt{x^3+C}\\y&=-\sqrt{x^3+C}\end{aligned}\]

Each branch needs \(x^3+C>0\), which means \(x>-\sqrt[3]{C}\). At \(x=-\sqrt[3]{C}\), the branches reach \(y=0\), where the equation has no value, so each solution is defined for \(x>-\sqrt[3]{C}\).

Example 4

Keep solutions lost through division

Find the general solution of \(\dfrac{dy}{dx}=2x(y-3)^2\). Then find the solution that satisfies \(y(0)=3\).

Solution

Before dividing by \((y-3)^2\), solve \((y-3)^2=0\). Its only zero is 3, and the constant function \(y=3\) is a solution, because both sides of the equation are 0 for it. The right side is a polynomial, so different solutions never meet (topic 7.4), and every other solution stays off the line \(y=3\). For those, separating and integrating gives

\[\begin{aligned}\frac{dy}{(y-3)^2}&=2x\,dx\\-\frac{1}{y-3}&=x^2+C\\y&=3-\frac{1}{x^2+C}\end{aligned}\]

This formula is never 3, so it leaves out the constant solution. The general solution is this formula, on each interval where \(x^2+C\neq0\), together with \(y=3\).

At \(x=0\), the formula gives \(3-\frac{1}{C}\), which is never 3, or no value when \(C=0\). The solution that satisfies \(y(0)=3\) is therefore the constant solution \(y=3\).

Example 5

State relevant domain restrictions

Find the general solution of \(\dfrac{dy}{dx}=e^{y}\), and give the interval on which each solution is defined.

Solution

The factor \(e^{y}\) is never 0, so there is no constant solution. Multiplying both sides by \(e^{-y}\,dx\) separates the variables, and integrating each side gives

\[\begin{aligned}e^{-y}\,dy&=dx\\-e^{-y}&=x+C\end{aligned}\]

Then \(e^{-y}=K-x\), where \(K=-C\) is also an arbitrary constant. A power of \(e\) is positive, so a solution exists only where \(K-x>0\). Taking the natural logarithm of both sides gives

\[y=-\ln(K-x),\qquad x<K\]

Each solution is defined for \(x<K\). As \(x\) approaches \(K\) from the left, \(K-x\) approaches 0, so \(y\) increases without bound.

Each example is one of the five skills of topic 7.6 in Which & Why: AP Calculus.