# Ordinary Differential Equations/Separable 1

First Order Differential Equations

This section deals with a technique of solving differential equation known as Separation of Variables. Before we begin discussing separation of variables it is very helpful to recall the theorem behind integration by substitution from calculus.

Which states that if ${\displaystyle f(x)}$ is a continuous function and ${\displaystyle y}$ has a derivative that is a continuous function - hence ${\displaystyle y}$ being a function itself, then integrating such chained functions yields

${\displaystyle \int f{\big (}y(x){\big )}y'\,dx=\int f(y)\,dy}$

In other words, our integrand ${\displaystyle f(y(x))y'(x)}$ and our antiderivate will be the same if we took the antiderivative of ${\displaystyle f}$ and plugged it into ${\displaystyle y(x)}$. This provides a very useful tool to solve many ODE's.

To take an example let's consider the differential equation:

${\displaystyle y'=ay}$

We comment the constant function ${\displaystyle y(x)=0}$ is a solution. We will focus on finding solutions that are not zero. As commented before it is a consequence of the uniqueness of solutions that two solutions can never intersect. For this problem it means that solutions are always positive or always negative because they cannot cross ${\displaystyle y(x)=0}$. For easier understanding, picture a normal Cartesian coordinate system. The solutions can only be above or below the x-axis.

For this reason we are justified for the remainder in assuming that ${\displaystyle y(x)\neq 0}$. Thus we can divide by ${\displaystyle y(x)}$ as division by zero is undefined, to find that:

${\displaystyle {\frac {1}{y}}y'=a}$

Now integrating both sides with respect to ${\displaystyle x}$ we have that

${\displaystyle \int {\frac {1}{y}}y'\,dx=\int a\,dx}$

Using the theorem about integration by substitution theorem:

${\displaystyle \int {\frac {1}{y}}\,dy=\int a\,dx}$

Or

${\displaystyle \ln |y|=ax+C}$.
${\displaystyle y=\pm e^{C}e^{ax}=Ce^{ax}}$.

Finally we comment that, ${\displaystyle e^{c}>0}$ and ${\displaystyle e^{c}}$ collapsing to ${\displaystyle C}$, so technically speaking the above derivation only shows that we get a solution if ${\displaystyle C>0}$ or if ${\displaystyle C<0}$, taking into account ${\displaystyle \pm }$. Notice on the other hand that if we allow ${\displaystyle C=0}$ then we can recover the solution ${\displaystyle y(x)=0}$. Thus we can represent all solutions as

${\displaystyle y(x)=Ce^{ax}}$

where ${\displaystyle C}$ is a real number.

This method is known as separation of variables because after we have divided we have one side that is entirely in terms of ${\displaystyle y}$ and the other side entirely in terms of ${\displaystyle x}$.

While the change of variables theorem is the mathematical justification, using Leibniz' notation for derivatives allows for excellent mnemonics for remembering how separation of variables works.

We present two notationally different but equivalent derivations here:

Beginning from the point where we have divided by ${\displaystyle y(x)}$ and using Leibniz notation we have that:

${\displaystyle {\frac {1}{y}}{\frac {dy}{dx}}=a.}$

One might not view this as fully separated because there is still a "dx" on the left hand side. But one can fully separate the equation by multiplying by "dx", to get:

${\displaystyle {\frac {1}{y}}\,dy=a\,dx}$

Then placing an integral in front of each term one gets:

${\displaystyle \int {\frac {1}{y}}\,dy=\int a\,dx}$.

This arrives at the correct place, but treating "dx" as a number is purely heuristic.

A second mnemonic which is fairly similar uses Leibniz notation to remind us how the change of variables theorem should work. Beginning from the step in the original example where we integrated both sides with respect to x, and using Leibniz notation we have:

${\displaystyle \int {\frac {1}{y}}{\frac {dy}{dx}}\,dx=\int a\,dx}$.

Now we can "cancel the dx" to get that ${\displaystyle \int {\frac {1}{y}}{\frac {dy}{\cancel {dx}}}\,{\cancel {dx}}=\int {\frac {1}{y}}\,dy}$. Thus

${\displaystyle \int {\frac {1}{y}}\,dy=\int a\,dx}$.

Again, "dx" is not a number, so it cannot really be canceled. But the heuristic does correctly give the change of variables formula.

The reader should use which ever of the above methods seems most clear to them individually. The book will undoubtedly use anyone of the three at different points in its exposition.

## What is a Separable Equation?

An ordinary differential equation is called separable if it can be rewritten in the form:

${\displaystyle M(x)+N(y)y'=0}$

Integrating both sides with respect to ${\displaystyle x}$

${\displaystyle \int M(x)\,dx+\int N(y)y'\,dx=C}$

Now by one of the methods we discussed above we can change and simplfy the second integral to

${\displaystyle \int M(x)\,dx+\int N(y)\,dy=C}$

An equation where you can factor out both P and Q into separate functions of x and y

${\displaystyle P_{1}(x)P_{2}(y)dx+Q_{1}(x)Q_{2}(y)dy=0}$

is called separable because the equation can become an equation with separated variables.

${\displaystyle {\frac {P_{1}(x)}{Q_{1}(x)}}dx+{\frac {Q_{2}(y)}{P_{2}(y)}}dy=0}$
${\displaystyle {\frac {P_{1}(x)}{Q_{1}(x)}}dx=-{\frac {Q_{2}(y)}{P_{2}(y)}}dy}$

However, attention must be paid to this process of division. The cases when ${\displaystyle Q_{1}(x)=0}$ and ${\displaystyle P_{2}(y)=0}$ will be additional possible integral solutions that will not be found through the integral because of this division.

## Trivial cases

There are two special cases of a separable equation that make the solution almost trivial. These are the cases where either

${\displaystyle N(y)=k\,}$

or

${\displaystyle M(x)=k,\,}$

where k is a constant. In either case, the equation changes from being in terms of 3 variables and reduces down to 2. When we can throw out one of the two variables, the solution can be achieved by a simple integral.

### No y term: N(y) = k

If N(y)=k, we can treat k as part of M(x), and turn N(y) into 1. That is, if we divide both sides by k and let f(x) = M(x)/k. Then we're left with

${\displaystyle {\frac {dy}{dx}}=M(x)/k=f(x)}$.

This is now basic calculus - take the integral of both sides. The general solution is

${\displaystyle y=\int f(x)dx+C,}$

where C is a constant.

Let's take a look at a few examples.

#### Example 1

${\displaystyle {\frac {dy}{dx}}=x^{2}+7}$

Here, we have a derivative equaling a function of x. The original function is the antiderivative of this, that is, we have to integrate to find it. Now we integrate both sides of the equation, w.r.t.x (with regard to 'x'):

${\displaystyle \int {\frac {dy}{dx}}\,dx=\int (x^{2}+7)\,dx}$
${\displaystyle y={\frac {1}{3}}x^{3}+7x+C}$

This is the general solution. A function that solves a differential equation is said to satisfy it, so

${\displaystyle y={\frac {1}{3}}x^{3}+7x+C}$

satisfies the differential equation

${\displaystyle {\frac {dy}{dx}}=x^{2}+7}$.

#### Example 2

${\displaystyle {\frac {dy}{dx}}=\sin x+e^{x}}$

This works the same as before - integrate both sides with respect to x.

${\displaystyle \int {\frac {dy}{dx}}\,dx=\int \sin x+e^{x}\,dx}$
${\displaystyle y=-\cos x+e^{x}+C\,}$

Note that even in this simple case, it may be impossible to write down a formula for the solution because f(x) cannot be integrated in elementary terms. In this case, writing the integral of y, which is the function we are looking for, symbolically with an integral symbol is deemed to be a solution.

### No x term: M(x)=k

Another special case is when

${\displaystyle M(x)=k.}$

The only difference is how we make it into an integrable form. Our equation is

${\displaystyle N(y){\frac {dy}{dx}}=-k.}$

This type of equation is called an autonomous differential equation. The differential equation has no explicit dependence on the independent variable x except through the function y. We will have more to say about this type of equation later, but for the moment we note that this type of equation is always separable.

Integrating both sides with respect to x we get

${\displaystyle \int N(y){\frac {dy}{dx}}\,dx=\int k\,dx.}$

We now have two integrals, each with respect to the functions contained in them. The solution is of the form

${\displaystyle \int N(y)\,dy=kx+C.}$

You can now try to solve for y. It is possible that the left hand side doesn't have an antiderivative that can be expressed as a nice formula, and in that case, we leave it in a as clean a form as possible, that is with the integral symbol unresolved. Another important concept emerges here.

#### Example 4

${\displaystyle {\frac {dy}{dx}}={\frac {k}{y}}}$

Here we multiply through by y, and multiply through by dx. The rest of the math works as before.

${\displaystyle ydy=kdx\,}$
${\displaystyle \int ydy=\int kdx\,}$
${\displaystyle {\frac {1}{2}}y^{2}=kx+C}$
${\displaystyle y^{2}=2kx+C\,}$

In this case, its more convenient to solve for y2 than y. If we take the square root to solve for y, we change the equation (since the square root of a number is always positive, we would lose half of each solution curve). In these cases its just fine to leave it in its current form.

You may have noticed that the right hand side of the equation, before solving for y, is the same for both examples. When f(x)=k, the right hand side will always be kx+C where k is whatever constant is in the problem. It only changes when f(x) is not constant.

As before, it may be impossible to do the integral. Even if it is possible, it may then not be possible to invert the equation to give y explicitly as a function of x, for example if we get tan(y) + 1/y = x. Again, this does not matter; the result is regarded as a valid solution.

## General Separable Variable Equations

In the most general case, neither M(x) or N(y) is a constant. In this case, we use the same method as before (although the variables might have to be separated first). The only difference is that both sides result in non-trivial integrals, so we a little more work to do. This can produce some untidy solutions, and ODEs are known for this. This untidiness often means that we might want to check our result at the end.

#### Example 5

${\displaystyle {\frac {dy}{dx}}=y^{3}x}$

Dividing by y3 and multiplying by dx gives

${\displaystyle {\frac {dy}{y^{3}}}=xdx}$
${\displaystyle \int {\frac {dy}{y^{3}}}=\int xdx}$
${\displaystyle -{\frac {1}{2y^{2}}}={\frac {1}{2}}x^{2}+C}$
${\displaystyle y^{2}=-{\frac {1}{x^{2}+C}}}$

### Example 6

${\displaystyle {\frac {dy}{dx}}={\frac {y}{x}}}$

We multiply by ${\displaystyle {\frac {dx}{y}}}$:

${\displaystyle {\frac {dy}{y}}={\frac {dx}{x}}}$
${\displaystyle \int {\frac {dy}{y}}=\int {\frac {dx}{x}}\,}$
${\displaystyle \ln(y)=\ln(x)+C\,}$
${\displaystyle y=e^{\ln(x)+C}=e^{C}e^{\ln(x)}=Cx\,}$

Again ${\displaystyle e^{c}}$ collapsing into ${\displaystyle C}$.

### Example 7

${\displaystyle {\frac {dy}{dx}}=xy+y}$

This doesn't look separable at first glance. A little factoring can be applied though:

${\displaystyle {\frac {dy}{dx}}=(x+1)y}$

This is separable.

${\displaystyle {\frac {dy}{y}}=(x+1)dx}$
${\displaystyle \int {\frac {dy}{y}}=\int (x+1)dx}$
${\displaystyle \ln(y)={\frac {1}{2}}x^{2}+x+C}$
${\displaystyle y=Ce^{{\frac {1}{2}}x^{2}+x}}$

## Problems with Initial Conditions

Solving an initial value problem is fairly easy. Solve for y as we did above. Then once you have the equation, plug in b for y and a for x. Then, solve for the constant.

### Example 8

${\displaystyle {\frac {dy}{dx}}=ky,\quad y(0)=10}$

As we saw in example 3, the general solution to this is y=Cekx. Let's plug in our boundary conditions:

${\displaystyle 10=Ce^{0k}\,}$
${\displaystyle 10=Ce^{0}\,}$
${\displaystyle C=10\,}$
${\displaystyle y=10e^{kx}\,}$

This is the particular solution.

Unfortunately in some cases care must be used when solving for the constant.

### Example 9

${\displaystyle 2yy'=2x+2\qquad y(0)=-2}$

This equation is already separated, so integrating both sides

${\displaystyle \int 2yy'\,dx=\int 2x+2\,dx}$
${\displaystyle y^{2}=x^{2}+2x+C}$

By plugging in we find that:

${\displaystyle C=(-2)^{2}=4}$

So now we have that:

${\displaystyle y^{2}=x^{2}+2x+4.}$

But if we continue to solve for y we must be careful. One may naively write: ${\displaystyle y=\pm {\sqrt {x^{2}+2x+4}}.}$

But there is a problem, we are looking for a function y(x), which means the function must be single valued (see Single-valued function). And we should be careful what we mean by ${\displaystyle \pm }$. Do we mean that for each different x there is a different possibility of a sign?

Fortunately since the function has to be differentiable (and hence continuous), the function y(x) cannot jump back and forth between positive and negative values. So we must mean there is one choice of sign:

${\displaystyle y={\sqrt {x^{2}+2x+4}};}$ Or
${\displaystyle y=-{\sqrt {x^{2}+2x+4}}.}$

But which one? It is a nice consequence of uniqueness, that only one of the two functions could solve the problem. Both solve the differential equation, so we can double check the initial condition. In the first instance y(0)=2, so that is not our solution, but for the second function y(0)=-2 as desired. Thus the solution is given by:

${\displaystyle y=-{\sqrt {x^{2}+2x+4}}.}$

### Example 10

Another interesting example that illustrates problems that may arise is:

${\displaystyle y'=6xy^{2/3}\qquad y(0)=0.}$

In order to solve this initial value problem we begin by separating variables.

${\displaystyle \int y^{-2/3}y'\,dx=\int 6x\,dx}$
${\displaystyle 3y^{1/3}=3x^{2}+C}$
${\displaystyle y=(x^{2}+C)^{3}}$

Now to plug in the initial conditions we have that:

${\displaystyle 0=(0^{2}+C)^{3}}$, Thus
${\displaystyle C=0}$

So we have a solution ${\displaystyle y(x)=x^{6}}$. But by inspection we also have the solution ${\displaystyle y(x)=0}$. So there are at least two solutions to this problem. Perhaps there are more, at the moment we have no way to be sure. Worse, there is nothing that comes up while separating variables to indicate we are in a situation where the situations are not unique. For this reason we will return to issue and discuss the general mathematical theorems that guarantee the existence of unique solutions.

This may be important for many reasons. For example, often one believes a real life process is described by a function which satisfies an ODE. Usually using the ODE, and actual measurements of the process you'd like to deduce what function is governing the process so you can make predictions about future behaviour. But if the solutions to the ODE are not unique, it is difficult to tell when you have found the one solution which is really giving the behaviour of the real world process.

### Example 11

In the example above we saw that sometimes a differential equation is not well behaved and admits multiple solutions. In this example we see that sometimes the problem is perfectly well behaved but if we are not careful we may think we find multiple soluitons.

${\displaystyle y'=4y^{1/2}x\qquad y(0)=4.}$
${\displaystyle \int y^{-1/2}y'\,dx=\int 4x\,dx}$
${\displaystyle 2y^{1/2}=2x^{2}+C}$
${\displaystyle y=(x^{2}+C)^{2}}$

Now by plugging in the initial condition we find that

${\displaystyle 4=(0^{2}+C)^{2}=C^{2}}$

At this point it is very tempting to claim that:

${\displaystyle C=\pm 2}$

And we appear get two solutions

${\displaystyle y=(x^{2}+2)^{2}}$
${\displaystyle y=(x^{2}-2)^{2}}$

But if we are careful we can see that the second equation is not really a solution. To see this let's plug it into the equation.

If

${\displaystyle y=(x^{2}-2)^{2}}$, then
${\displaystyle y'=4x(x^{2}-2)}$, and
${\displaystyle y^{1/2}=|x^{2}-2|}$.

Thus when we plug into ${\displaystyle y'=4y^{1/2}x}$ we are trying to equate

${\displaystyle 4x(x^{2}-2)}$ and ${\displaystyle 4x|x^{2}-2|}$,

but notice the first equation is negative for ${\displaystyle 0 while the second equation is always positive.

This doesn't happen for the other function because we end up trying to compare ${\displaystyle 4x(x^{2}+2)}$ ${\displaystyle y'=4x|x^{2}+2|}$, since ${\displaystyle x^{2}+2>0}$ we can drop the absolute values in the second expression.

So what went wrong? We introduced the ambiguity when we were solving for ${\displaystyle y}$ by squaring both sides of the equation. We could have avoided this issue if we solved for ${\displaystyle C}$ immediately after integrating, in which case we would have been working with the equation ${\displaystyle 2y^{1/2}=2x^{2}+C}$ and:

${\displaystyle 2(4)^{1/2}=2(0)^{2}+C}$, so
${\displaystyle C=4}$

Plugging this back in and solving for y we get:

${\displaystyle 2y^{1/2}=2x^{2}+4}$
${\displaystyle y^{1/2}=x^{2}+2}$
${\displaystyle y=(x^{2}+2)^{2}}$

Proceed to the next part of the lesson: Examples