$$\def\ans#1{\bbox[border:1px solid green,6pt]{#1}}$$

# Separable Differential Equations

## Introduction

So far, we haven't actually gotten to solve any differential equations; we've seen solutions to a few and we've talked about numerical approximations, but we haven't actually solved any analytically. Here we get our first method to do so: separation. It may seem to you the first time you see this material that the methods we're going to learn are disconnected and difficult to keep straight. In principle, though, this is similar to what we saw with integration methods: we have a whole toolbox of methods, and which one we use depends on the look of the problem. We'll only have to methods for solving first-order differential equations in this class, though, so that simplifies things a lot.

As the name suggests, we're going to be separating something, but what? We'll be separating the variables; if we can do it, we want to have all of the $$x$$'s on one side of the equation and all of the $$y$$'s on the other side. If we can do that, and if $$dx$$ and $$dy$$ are on the appropriate sides, we can integrate each side.

## Procedure

Let's illustrate with an example: $y' = \dfrac{x^2}{y^2}$ First of all, we need to rewrite this with Liebniz's notation, using $$dy/dx$$ instead of $$y'$$. Usually the notation we use doesn't matter that much, but when it comes to separation, it's crucial in order to see what we're doing. $\dfrac{dy}{dx} = \dfrac{x^2}{y^2}.$

Now comes the separation: $y^2 \ dy = x^2 \ dx.$ Since each side only has one variable present, as well as the appropriate differential, we can integrate both sides: \begin{align} \int y^2 \ dy &= \int x^2 \ dx\\ \dfrac{1}{3}y^3 &= \dfrac{1}{3}x^3 + C \end{align} (notice that we only included one arbitrary constant; if we put one on both sides, we could subtract the left-hand constant from both sides and get to where we are now).

As simple as that seemed, we've solved this differential equation. Now, if possible, we'd like to have an answer explicitly written in terms of $$y$$, and we can do that here. You should check the algebra and verify that the solution is $\ans{y = \sqrt[3]{x^3+3C}.}$

This is the general solution, and if we were given an initial condition, we could find the specific solution. Say, for example, that we were given the initial condition $y(0)=2.$ We can plug this into the solution: \begin{align} 2 &= \sqrt[3]{0^3 + 3C}\\ 2 &= \sqrt[3]{3C}\\ 8 &= 3C\\ \end{align}

Plugging this into the general solution, we get the following specific (or particular) solution: $\ans{y = \sqrt[3]{x^3+8}.}$ If you like, you can pause here, and check this answer by finding $$dy/dx$$ and plugging that and $$y$$ into the differential equation and verifying that it checks out.

### In General

Separation works in the case where we can write a differential equation in terms of the product of a function of $$x$$ and a function of $$y$$: $\dfrac{dy}{dx} = f(x)g(y).$ This may or may not be entirely obvious, because we may have to do a little algebra to get it written in this form. If we can, though, then we can separate by rearranging terms: $\dfrac{1}{g(y)} \ dy = f(x) \ dx.$ At this point, we can integrate: $\int \dfrac{1}{g(y)} \ dy = \int f(x) \ dx.$ After integrating, we have the answer, and if possible, we solve for $$y$$ to get the explicit solution (if not, we just leave it in implicit form). Finally, if we were given an initial condition, we can substitute that in to find the arbitrary constant that arose when we integrated.

## Examples

Solve the following differential equation. $\dfrac{dP}{dt} = kP$

#### Solution

Notice that we already saw the solution to this one in the introduction to diff eq, but now we'll see how to get to that solution. Separate the variables and integrate:

\begin{align} \dfrac{dP}{dt} &= kP\\ \dfrac{1}{P} \ dP &= k \ dt\\ \int \dfrac{1}{P} \ dP &= \int k \ dt\\ \ln P &= kt + C\\ P &= e^{kt+C} = e^{kt}e^C\\ \\ \end{align} $\ans{P = ae^{kt}}$

Be careful not to forget the integration constant; that completely changes the answer.

Solve the following differential equation. $xy'+y=y^2 \hspace{0.75in} y(1)=-1$

#### Solution

The way this one is set up, it doesn't look separable. But with a little algebra, we can write this as a product of a function of $$x$$ and a function of $$y$$: $xy'+y=y^2 \longrightarrow xy'=y^2-y \longrightarrow y' = \dfrac{1}{x}(y^2-y)$ Now we can separate and integrate. The only wrinkle is that the integration in this one requires partial fraction decomposition. I'll skip some of the details of that process, but you should verify them.

\begin{align} \dfrac{dy}{dx} &= \dfrac{1}{x}(y^2-y)\\ \dfrac{1}{y^2-y} \ dy &= \dfrac{1}{x} \ dx\\ \int \dfrac{1}{y^2-y} \ dy &= \int \dfrac{1}{x} \ dx\\ \int -\dfrac{1}{y} + \dfrac{1}{y-1} \ dy &= \int \dfrac{1}{x} \ dx\\ -\ln y + \ln |y-1| &= \ln x + C\\ \ln \left| \dfrac{y-1}{y} \right| &= \ln x + C\\ \dfrac{y-1}{y} &= e^{\ln x + C} = e^{\ln x}e^C\\ \dfrac{y-1}{y} &= kx\\ y-1 &= kxy\\ y-kxy &= 1\\ y(1-kx) &= 1\\ y &= \dfrac{1}{1-kx} \end{align} Substitute the initial condition in to find $$k$$: $-1 = \dfrac{1}{1-k(1)} \longrightarrow k=2$ $\ans{y = \dfrac{1}{1-2x}}$
###### Newton's Law of Cooling

$T' = -k(T-T_m)$ A man was found dead at 10:06 pm, at which time his body temperature was 77.9°F. The thermostat was set at 72°F. At 11:06 pm, his body temperature was 75.6°F. If his normal body temperature was 98.6°F (although this isn't the average), at what time did he die?

#### Solution

First, notice that $$T_m$$, the temperature of the medium, is set by the thermostat at 73°F: $\dfrac{dT}{dt} = -k(T-72)$

Now separate and integrate:

\begin{align} \dfrac{1}{T-72} \ dT &= -k \ dt\\ \int \dfrac{1}{T-72} \ dT &= \int -k \ dt\\ \ln |T-72| &= -kt+C\\ T-72 &= Ae^{-kt}\\ \\ T &= 72+Ae^{-kt} \end{align}

There are two unknowns (A and k), which is why we need two pieces of information: the man's initial temperature and his temperature an hour later. \begin{align} T(0) &= 77.9\\ T(1) &= 75.6 \end{align}

Using the first condition: $77.9 = 72+Ae^{-k(0)} \longrightarrow A = 5.9$ With the second condition, we can find $$k$$: $75.6 = 72+5.9e^{-k} \longrightarrow 3.6 = 5.9e^{-k} \longrightarrow -k = \ln \dfrac{3.6}{5.9} \longrightarrow k = -\ln \dfrac{3.6}{5.9} \approx 0.494$

The full model, then, is $T=72+5.9e^{-0.494t}.$ The final question is to find when the man died, or in other words, when his temperature was 98.6°F: $98.6 = 72+5.9e^{-0.494t} \longrightarrow t = -3.05$ Therefore, the man died 3.05 hours before he was found. The time of death, then, was $\ans{\text{7:03 pm}.}$

## Mixing Problem Example

###### Mixing Problem

A tank initially contains 20 kg of salt dissolved in 5000 L of water. Brine (another word for salt water) that contains 0.03 kg of salt per liter of water enters the tank at a rate of 25 L/min. The solution in the tank is kept thoroughly mixed and drains from the tank at 25 L/min as well. Find a solution for $$y(t)$$, the amount of salt in the tank after $$t$$ minutes, and use this to predict how much salt will be in the tank after 30 minutes.

#### Solution

The key to setting this one up is noting that the rate of change of salt in the tank is the difference between the rate in and the rate out: $\dfrac{dy}{dt} = \text{rate in } - \text{ rate out}.$ Next, the rate of salt into the tank is the concentration times the flowrate, and the rate out is the same: $\dfrac{dy}{dt} = 0.03 \dfrac{kg}{L} \cdot 25 \dfrac{L}{min} - (\text{concentration of salt})\left(25 \dfrac{L}{min}\right).$

What's the concentration of salt in the tank? The concentration, just like with the inlet, is the amount of salt divided by the volume of brine. The key here is that the amount of salt in the tank is the unknown $$y$$. Also, note that the volume of brine is consistent at 5000 L, since the flowrates into and out of the tank are equal. $\dfrac{dy}{dt} = 0.75-\dfrac{y}{5000}\cdot 25 = 0.75-\dfrac{y}{200}$ Now, to solve this by separation, we need to rewrite this as a single fraction: $\dfrac{dy}{dt} = \dfrac{150-y}{200}.$

To solve, separate and integrate:

\begin{align} \dfrac{1}{150-y} \ dy &= \dfrac{1}{200} \ dt\\ \int \dfrac{1}{150-y} \ dy &= \int \dfrac{1}{200} \ dt\\ -\ln |150-y| &= \dfrac{t}{200} + C\\ \ln |150-y| &= -\dfrac{t}{200} - C\\ 150-y &= Ke^{-t/200}\\ y &= 150 - Ke^{-t/200} \end{align}

To find $$K$$, plug in the initial condition: $$y(0) = 20$$. $20 = 150-Ke^{0} \longrightarrow K=130$

Therefore, the final solution is $\ans{y(t) = 150-130e^{-t/200}.}$ After 30 minutes, there are 38.1 kg of salt in the tank.

### Observations

What if we changed the problem?

1. What if the tank initially was full of pure water? In that case, all that would change would be the initial condition: $$y(0)=0$$.
2. What if there were more inlets? In that case, we would simply add the rates in together.
3. What if the flowrate in and out were different? This is the one that significantly changes the problem. For instance, if the flowrate out were 20 L/min, the volume of brine in the tank would be rising by 5 L each minute (since 25 liters come in and 20 liters go out), so instead of $\dfrac{y}{5000},$ we'd have $\dfrac{y}{5000+5t}.$ And of course, if more were going out than coming in, we'd subtract instead of adding. It turns out that this problem cannot be done by separation; we need the method from the next section to do it.