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

\[y = \int f(x, y) dx + C\]

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

Separable equations

Let us suppose that the equation is separable. That is, let us consider

\[y' = f(x)g(y),\]

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

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

Then we rewrite the equation as

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

Now both sides look like something we can integrate. We obtain

\[\int \frac{dy}{g(y)} = \int f(x) dx + C\]

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

Example \(\PageIndex{1}\)

Take the equation

\[ y' = xy\]

First note that \(y = 0\) is a solution, so assume \(y \ne 0\) from now on, so that we can divide by \(y\). Write the equation as \(\frac{dy}{dx} = xy,\) then

\[\int \frac{dy}{y} = \int x dx + C.\]

We compute the antiderivatives to get

\[\ln \left \vert y \right \vert = \frac{x^2}{2} + C\]

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

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

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

It is not easy to find the solution explicitly as it is hard to solve for \(y\). 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\), and remember that \(y\) is a function of \(x\), to get

\[y' \left ( 2y + \frac{2}{y} \right ) = 2x\]

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\), you might have to be tricky. You might get multiple solutions \(y\) for each \(x\), so you have to pick one. Sometimes you can graph \(x\) as a function of \(y\), 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\), you find the two curves in Figure \(\PageIndex{1}\). This is not quite a graph of a function. For each \(x\) there are two choices of \(y\). 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\). 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\). So the general solution is \[y^2 + 2 \ln \, \lvert y \rvert = x^2 + C, \qquad \text{and} \qquad y=0.\] These outlying solutions such as \(y=0\) are sometimes called singular solutions.

Separate variables, integrate, and solve for \(y\)

\[\begin{align}\begin{aligned} \frac{y'}{1 + y^2} &= \frac {1 - x^2}{x^2}, \\ \frac{y'}{1 + y^2} &= \frac {1}{ x^2} -1, \\ \text{arctan}(y) &= -\frac{1}{x^2} - x + C, \\ y &= \tan \left( -\frac{1}{x} - x + C \right )\end{aligned}\end{align}\]

Solve for the initial condition, \(0 = \tan(-2+C)\) to get \(C=2\) (or \(C = 2 + \pi\), or \(C = 2 + 2\pi\), etc.). The particular solution we seek is, therefore, \[y = \tan \left(\frac{-1}{x} - x + 2 \right) .\]

Example \(\PageIndex{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?

Solution

Let \(T\) be the temperature of the coffee in degrees Celsius, and let \(A\) be the ambient (room) temperature, also in degrees Celsius. 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,

\[\frac{dT}{dt} = k(A - T),\]

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

\[\begin{align}\begin{aligned} \frac{1}{T -A} \frac {dT}{dt} &= -k, \\ \ln (T - A) &= -kt + C, \, \, \, \, \, \left ( \text {note that} T - A > 0 \right ) \\ T - A &= De^{-kt}, \\ T &= A + De^{-kt}\end{aligned}\end{align}\]

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

Example \(\PageIndex{4}\)

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

Solution

First note that \(y=0\) is a solution (a singular solution). Now assume that \(y \not= 0\). \[\begin{align}\begin{aligned} -\frac {3}{y^2} y' &= x , \\ \frac {3}{y} &= \frac {x^2}{2} + C, \\ y &= \frac {3}{ \frac{x^2}{2} + C} = \frac {6}{x^2 + 2C}.\end{aligned}\end{align}\] So the general solution is, \[y=\frac{6}{x^{2}+2C},\quad\text{and}\quad y=0.\]