## Section 1.3 Separable equations

When a differential equation is of the form \(y' = f(x)\text{,}\) we can just integrate: \(y = \int f(x) \,dx + C\text{.}\) Unfortunately this method no longer works for the general form of the equation \(y' = f(x,y)\text{.}\) Integrating both sides yields

\begin{equation*}
y = \int f(x,y) \,dx + C .
\end{equation*}

Notice the dependence on \(y\) in the integral.

### Subsection 1.3.1 Separable equations

In this video we learn our first main of solving ODEs beyond just integrating, and it applies to so called separable ODEs.

We say a differential equation is

*separable*if we can write it as
\begin{equation*}
y' = f(x)g(y) ,
\end{equation*}

for some functions \(f(x)\) and \(g(y)\text{.}\) Let us write the equation in the Leibniz notation

\begin{equation*}
\frac{dy}{dx} = f(x)g(y) .
\end{equation*}

Then we rewrite the equation as

\begin{equation*}
\frac{dy}{g(y)} = f(x) \,dx .
\end{equation*}

Both sides look like something we can integrate. We obtain

\begin{equation*}
\int \frac{dy}{g(y)} = \int f(x) \,dx + C .
\end{equation*}

If we can find closed form expressions for these two integrals, we can, perhaps, solve for \(y\text{.}\)

#### Example 1.3.1.

Take the equation

\begin{equation*}
y' = xy .
\end{equation*}

Note that \(y=0\) is a solution. We will remember that fact and assume \(y \not =0\) from now on, so that we can divide by \(y\text{.}\) Write the equation as \(\frac{dy}{dx} = xy\text{.}\) Then

\begin{equation*}
\int \frac{dy}{y} = \int x\,dx + C .
\end{equation*}

We compute the antiderivatives to get

\begin{equation*}
\ln \, \lvert y\rvert = \frac{x^2}{2} + C ,
\end{equation*}

or

\begin{equation*}
\lvert y \rvert = e^{\frac{x^2}{2} + C} = e^{\frac{x^2}{2}} e^C = D e^{\frac{x^2}{2}} ,
\end{equation*}

where \(D > 0\) is some constant. Because \(y=0\) is also a solution and because of the absolute value we can write:

\begin{equation*}
y = D e^{\frac{x^2}{2}} ,
\end{equation*}

for any number \(D\) (including zero or negative).

We check:

\begin{equation*}
y' = D x e^{\frac{x^2}{2}} = x \left( D e^{\frac{x^2}{2}} \right) = xy .
\end{equation*}

Yay!

We should be a little bit more careful with this method. You may be worried that we integrated in two different variables. We seemingly did a different operation to each side. Let us work through this method more rigorously. Take

\begin{equation*}
\frac{dy}{dx} = f(x)g(y) .
\end{equation*}

We rewrite the equation as follows. Note that \(y = y(x)\) is a function of \(x\) and so is \(\frac{dy}{dx}\text{!}\)

\begin{equation*}
\frac{1}{g(y)}\,\frac{dy}{dx} = f(x) .
\end{equation*}

We integrate both sides with respect to \(x\text{:}\)

\begin{equation*}
\int \frac{1}{g(y)}\,\frac{dy}{dx} \,dx = \int f(x) \,dx + C .
\end{equation*}

We use the change of variables formula (substitution) on the left hand side:

\begin{equation*}
\int \frac{1}{g(y)}\,dy = \int f(x) \,dx + C .
\end{equation*}

And we are done.

### Subsection 1.3.2 Implicit solutions

We sometimes get stuck even if we can do the integration. Consider the separable equation

\begin{equation*}
y' = \frac{xy}{y^2+1} .
\end{equation*}

We separate variables,

\begin{equation*}
\frac{y^2+1}{y}\,dy = \left(y+\frac{1}{y}\right)\,dy = x\,dx .
\end{equation*}

We integrate to get

\begin{equation*}
\frac{y^2}{2} + \ln \, \lvert y \rvert = \frac{x^2}{2} + C ,
\end{equation*}

or perhaps the easier looking expression (where \(D = 2C\))

\begin{equation*}
y^2 + 2 \ln \, \lvert y\rvert = x^2 + D .
\end{equation*}

It is not easy to find the solution explicitly as it is hard to solve for \(y\text{.}\) We, therefore, leave the solution in this form and call it an

*implicit solution*. It is still easy to check that an implicit solution satisfies the differential equation. In this case, we differentiate with respect to \(x\text{,}\) and remember that \(y\) is a function of \(x\text{,}\) to get
\begin{equation*}
y'\left(2y + \frac{2}{y}\right) = 2x .
\end{equation*}

Multiply both sides by \(y\) and divide by \(2(y^2+1)\) and you will get exactly the differential equation. We leave this computation to the reader.

If you have an implicit solution, and you want to compute values for \(y\text{,}\) you might have to be tricky. You might get multiple solutions \(y\) for each \(x\text{,}\) so you have to pick one. Sometimes you can graph \(x\) as a function of \(y\text{,}\) and then flip your paper. Sometimes you have to do more.

Computers are also good at some of these tricks. More advanced mathematical software usually has some way of plotting solutions to implicit equations. For example, for \(C=0\) if you plot all the points \((x,y)\) that are solutions to \(y^2+2\ln|y|=x^2\text{,}\) you find the two curves in Figure 1.8. This is not quite a graph of a function. For each \(x\) there are two choices of \(y\text{.}\) To find a function you would have to pick one of these two curves. You pick the one that satisfies your initial condition if you have one. For example, the top curve satisfies the condition \(y(1)=1\text{.}\) So for each \(C\) we really got two solutions. As you can see, computing values from an implicit solution can be somewhat tricky. But sometimes, an implicit solution is the best we can do.

The equation above also has the solution \(y=0\text{.}\) So the general solution is

\begin{equation*}
y^2 + 2 \ln \, \lvert y \rvert = x^2 + C, \qquad \text{and} \qquad y=0.
\end{equation*}

These outlying solutions such as \(y=0\) are sometimes called

*singular solutions*.### Subsection 1.3.3 Examples of separable equations

#### Example 1.3.2.

Solve \(x^2y' = 1 - x^2+y^2 - x^2y^2\text{,}\) \(y(1) = 0\text{.}\)

Factor the right-hand side

\begin{equation*}
x^2y' = (1 - x^2)(1+y^2) .
\end{equation*}

Separate variables, integrate, and solve for \(y\text{:}\)

\begin{equation*}
\begin{aligned}
\frac{y'}{1+y^2} & = \frac{1 - x^2}{x^2} , \\
\frac{y'}{1+y^2} & = \frac{1}{x^2} - 1 , \\
\operatorname{arctan} (y) & = \frac{-1}{x} - x + C , \\
y & = \tan \left(\frac{-1}{x} - x + C\right) .
\end{aligned}
\end{equation*}

Solve for the initial condition, \(0 = \tan(-2+C)\) to get \(C=2\) (or \(C = 2 +
\pi\text{,}\) or \(C = 2 + 2\pi\text{,}\) etc.). The particular solution we seek is, therefore,

\begin{equation*}
y = \tan \left(\frac{-1}{x} - x + 2 \right) .
\end{equation*}

#### Video 1.3.2. Newton’s Law of Cooling.

In this example we investigate the modelling process to determine the temperature on a cooling object like a cup of tea. The ODE we come up with is separable, and so this gives us a nice second example. However, we have to collect a bit more data than just an initial condition because our model has some undetermined parameter in it.

#### Example 1.3.3.

Bob made a cup of coffee, and Bob likes to drink coffee only once reaches 60 degrees Celsius and will not burn him. Initially at time \(t=0\) minutes, Bob measured the temperature and the coffee was 89 degrees Celsius. One minute later, Bob measured the coffee again and it had 85 degrees. The temperature of the room (the ambient temperature) is 22 degrees. When should Bob start drinking?

Let \(T\) be the temperature of the coffee in degrees Celsius, and let \(A\) be the ambient (room) temperature, also in degrees Celsius. Newton’s law of cooling states that the rate at which the temperature of the coffee is changing is proportional to the difference between the ambient temperature and the temperature of the coffee. That is,

\begin{equation*}
\frac{dT}{dt} = k(A-T) ,
\end{equation*}

for some constant \(k\text{.}\) For our setup \(A=22\text{,}\) \(T(0) = 89\text{,}\) \(T(1) = 85\text{.}\) We separate variables and integrate (let \(C\) and \(D\) denote arbitrary constants):

\begin{equation*}
\begin{aligned}
\frac{1}{T-A} \, \frac{dT}{dt} & = -k , \\
\ln (T-A) &= -kt + C , \qquad \text{(note that } T-A > 0 \text{)} \\
T-A &= D\, e^{-kt} , \\
T &= A + D\, e^{-kt} .
\end{aligned}
\end{equation*}

That is, \(T = 22 + D\, e^{-kt}\text{.}\) We plug in the first condition: \(89 = T(0) = 22 +
D\text{,}\) and hence \(D = 67\text{.}\) So \(T = 22 + 67\, e^{-kt}\text{.}\) The second condition says \(85 = T(1) =
22 + 67\, e^{-k}\text{.}\) Solving for \(k\) we get \(k = - \ln \frac{85-22}{67} \approx 0.0616\text{.}\) Now we solve for the time \(t\) that gives us a temperature of 60 degrees. Namely, we solve

\begin{equation*}
60 = 22 + 67 e^{-0.0616t}
\end{equation*}

to get \(t = - \frac{\ln \frac{60-22}{67}}{0.0616} \approx 9.21\) minutes. So Bob can begin to drink the coffee at just over 9 minutes from the time Bob made it. That is probably about the amount of time it took us to calculate how long it would take. See Figure 1.9.

#### Example 1.3.4.

*Geogebra Activity:*Use this Geogebra applet

^{ 1 }to explore Newton’s Law of Cooling. Try a few different initial conditions and explore how they affect the cooling curve. You can use this application as a check when solving problems involving Newton cooling.

#### Example 1.3.5.

Find the general solution to \(y' = \frac{-xy^2}{3}\) (including singular solutions).

First note that \(y=0\) is a solution (a singular solution). Now assume that \(y \not= 0\text{.}\)

\begin{equation*}
\begin{aligned}
\frac{-3}{y^2} y' & = x , \\
\frac{3}{y} & = \frac{x^2}{2} + C , \\
y & = \frac{3}{\nicefrac{x^2}{2} + C}
= \frac{6}{x^2 + 2C}.
\end{aligned}
\end{equation*}

So the general solution is,

\begin{equation*}
\begin{aligned}
y = \frac{6}{x^2 + 2C}, \qquad \text{and} \qquad y=0 .
\end{aligned}
\end{equation*}

### Subsection 1.3.4 Exercises

#### Exercise 1.3.1.

Solve \(y' = \nicefrac{x}{y}\text{.}\)

Solution.

Rearranging we get \[ \int ydy=\int xdx \] \[ \frac{y^2}{2}=\frac{x^2}{2}+c \] Solving for \(y\) \[ y=\sqrt{x^2+c} \textrm{or} y=-\sqrt{x^2+c} \] The choice of sign would depend on initial conditions.

#### Exercise 1.3.2.

Solve \(y' = x^2y\text{.}\)

Answer.

\(y=Ce^{x^3/3}\)

#### Exercise 1.3.3.

Solve \(\dfrac{dx}{dt} = (x^2-1)\,t\text{,}\) for \(x(0) = 0\text{.}\)

Answer.

\(x=\tanh \left(\frac{-t^2}{2}\right)=-\frac{e^{t^2}-1}{e^{t^2}+1}\)

#### Exercise 1.3.4.

Solve \(\dfrac{dx}{dt} = x\,\sin(t)\text{,}\) for \(x(0) = 1\text{.}\)

Solution.

Rearranging \[ \int \frac{dx}{x}=\int \sin(t)dt\rightarrow \ln \lvert x \rvert =-\cos t+c \] Applying the initial condition \(x(0)=1\) we get \(c=1\text{.}\) Therefore \[ \lvert x \rvert =e^{1-\cos(t)} \rightarrow x=\pm e^{1-\cos(t)} \] Checking the initial condition again \(x(0)=\pm e^0=\pm 1\) so we choose the positive sign. Thus \[ x=e^{1-\cos(t)} \]

#### Exercise 1.3.5.

Solve \(\dfrac{dy}{dx} = xy+x+y+1\text{.}\) Hint: Factor the right-hand side.

Answer.

\(y=Ce^{x^2/2+x}-1\)

#### Exercise 1.3.6.

Solve \(xy' = y + 2x^2 y\text{,}\) where \(y(1) = 1\text{.}\)

Answer.

\(y=\lvert x \rvert e^{x^2-1}\)

#### Exercise 1.3.7.

Solve \(\dfrac{dy}{dx} = \dfrac{y^2+1}{x^2+1}\text{,}\) for \(y(0) = 1\text{.}\)

Answer.

\(y=\tan \left(\arctan(x)+\frac{\pi}{4}\right)\)

#### Exercise 1.3.8.

Find an implicit solution for \(\dfrac{dy}{dx} = \dfrac{x^2+1}{y^2+1}\text{,}\) for \(y(0) = 1\text{.}\)

Solution.

Rearranging \[ \int y^2+1 dy=\int x^2+1 dx\rightarrow \frac{y^3}{3}+y=\frac{x^3}{3}+x+c \] Applying the initial condition \(y(0)=1\) we get \(c=\frac{4}{3}\text{.}\) Thus the implicit solution is \[ \frac{y^3}{3}+y=\frac{x^3}{3}+x+\frac{4}{3} \]

#### Exercise 1.3.9.

Find an explicit solution for \(y' = xe^{-y}\text{,}\) \(y(0)=1\text{.}\)

Answer.

\(y=\ln(\frac{x^2}{2}+e)\)

#### Exercise 1.3.10.

Find an explicit solution for \(xy' = e^{-y}\text{,}\) for \(y(1)=1\text{.}\)

Answer.

\(y=\ln\left(\ln \lvert x \rvert +e\right)\)

#### Exercise 1.3.11.

Find an explicit solution for \(y' = ye^{-x^2}\text{,}\) \(y(0)=1\text{.}\) It is alright to leave a definite integral in your answer.

Answer.

\(y=e^{\int e^{-x^2}dx}\text{.}\) It is implied that the integral doesn’t have an integration constant. A proper way to write this would be \(y=e^{\int_0^x e^{-t^2}dt}\)

#### Exercise 1.3.12.

Suppose a cup of coffee is at 100 degrees Celsius at time \(t=0\text{,}\) it is at 70 degrees at \(t=10\) minutes, and it is at 50 degrees at \(t=20\) minutes. Compute the ambient temperature.

Solution.

Applying the three conditions to the equation \[ T=A+De^{-kT} \] We get a system of three equations

\begin{equation*}
\begin{aligned}
100=& A+D \\
70=& A+De^{-10k} \\
50=& A+De^{-20k}
\end{aligned}
\end{equation*}

Solving this system we get \(A=10^{\circ}\) C (and \(D=90\text{,}\) \(k\approx 0.0405\)).

#### Exercise 1.3.13.

Solve \(y'=2xy\text{.}\)

Answer.

\(y = Ce^{x^2}\)

#### Exercise 1.3.14.

Solve \(x'=3xt^2-3t^2\text{,}\) \(x(0)=2\text{.}\)

Answer.

\(x = e^{t^3}+1\)

#### Exercise 1.3.15.

Find an implicit solution for \(x'=\frac{1}{3x^2+1}\text{,}\) \(x(0)=1\text{.}\)

Answer.

\(x^3+x=t+2\)

#### Exercise 1.3.16.

Find an explicit solution to \(x y' = y^2\text{,}\) \(y(1) = 1\text{.}\)

Answer.

\(y = \frac{1}{1-\ln x}\)

#### Exercise 1.3.17.

Find an implicit solution to \(y' = \frac{\sin(x)}{\cos(y)}\text{.}\)

Answer.

\(\sin(y) = -\cos(x) + C\)

#### Exercise 1.3.18.

Take Example 1.3.3 with the same numbers: 89 degrees at \(t=0\text{,}\) 85 degrees at \(t=1\text{,}\) and ambient temperature of 22 degrees. Suppose these temperatures were measured with precision of \(\pm 0.5\) degrees. Given this imprecision, the time it takes the coffee to cool to (exactly) 60 degrees is also only known in a certain range. Find this range. Hint: Think about what kind of error makes the cooling time longer and what shorter.

Answer.

The range is approximately 7.45 to 12.15 minutes.

#### Exercise 1.3.19.

A population \(x\) of rabbits on an island is modeled by \(x' = x- \bigl(\nicefrac{1}{1000} \bigr) x^2\text{,}\) where the independent variable is time in months. At time \(t=0\text{,}\) there are 40 rabbits on the island.

- Find the solution to the equation with the initial condition.
- How many rabbits are on the island in 1 month, 5 months, 10 months, 15 months (round to the nearest integer).

Answer.

a) \(x = \frac{1000e^t}{e^t+24}\text{.}\) b) 102 rabbits after one month, 861 after 5 months, 999 after 10 months, 1000 after 15 months.

`www.geogebra.org/m/n7byk5wt`