# What am I doing when I separate the variables of a differential equation?

I see an equation like this:

$$y\frac{\textrm{d}y}{\textrm{d}x} = e^x$$

and solve it by "separating variables" like this:

$$y\textrm{d}y = e^x\textrm{d}x$$ $$\int y\textrm{d}y = \int e^x\textrm{d}x$$ $$y^2/2 = e^x + c$$

What am I doing when I solve an equation this way? Because $\textrm{d}y/\textrm{d}x$ actually means

$$\lim_{\Delta x \to 0} \frac{\Delta y}{\Delta x}$$

they are not really separate entities I can multiply around algebraically.

I can check the solution when I'm done this procedure, and I've never run into problems with it. Nonetheless, what is the justification behind it?

What I thought of to do in this particular case is write

$$\int y \frac{\textrm{d}y}{\textrm{d}x}\textrm{d}x = \int e^x\textrm{d}x$$ $$\int \frac{\textrm{d}}{\textrm{d}x}(y^2/2)\textrm{d}x = e^x + c$$

then by the fundamental theorem of calculus

$$y^2/2 = e^x + c$$

Is this correct? Will such a procedure work every time I can find a way to separate variables?

• Please see this for why we cannot anyhow solve so-called separable differential equations blindly (and hence why your question is a good one). See my comments starting here for extra details. Mar 24, 2019 at 9:00
• Related to that, the answer by Mike Spivey is wrong, because it fails to get the right answer to the differential equation in the linked post. Mar 25, 2019 at 8:06

The basic justification is that integration by substitution works, which in turn is justified by the chain rule and the fundamental theorem of calculus.

More specifically, suppose you have: $$\frac{dy}{dx} = g(x) h(y)$$ Rewrite as: $$\frac{1}{h(y)} \frac{dy}{dx} = g(x)$$ Add the implicit dependency of $y$ on $x$ to obtain $$\frac{1}{h(y(x))} \frac{dy}{dx} = g(x)$$

Now, integrate both sides with respect to $x$: $$\int \frac{1}{h(y(x))} \frac{dy}{dx} \, dx = \int g(x) \, dx$$ If we do a variable substitution of $y$ for $x$ on the left-hand side (i.e., use the integration by substitution technique), we replace $\frac{dy}{dx} dx$ with $dy$. Thus we have $$\int \frac{1}{h(y)}\, dy = \int g(x) \, dx,$$ which is the separation of variables formula.

So if you believe integration by substitution, then separation of variables is valid.

• you can also give it a formal justification by working with differential forms. The only difficulty is why "dy/dx" is defined, and I think the answer is that under reasonable assumption, the module of 1-forms is free of rank 1, so you may define "divison" of two forms and the answer is a function. Mar 16, 2011 at 18:59
• @theL Can you give a reference/more details on this please? Aug 24, 2014 at 22:07
• @Mike spivey Is there any chance you could write the substitution explicitly? In specific what is the "u" here? I am pondering about this as treating the dxs and dys as ratios won't work if it's attempted as a solution for a differential equation in standard form (ie. not dividing by 1/y).
– Dole
Jun 28, 2016 at 19:02
• @Dole: I'm using $y$ instead of $u$. A variable switch from $x$ to $u$ would have $du = \frac{du}{dx} dx$ for the $dx$ switch to $du$. So I'm just using $y$ instead of $u$. Jun 28, 2016 at 21:25
• @MrReality: At some places in the derivation I wanted to emphasize the dependence of $y$ on $x$, and at other places I wanted to de-emphasize that dependency. Oct 27, 2017 at 17:49

"Separation of variables" in ODE (which has nothing to do with separation of variables in PDE) is a kind of magic that is easy to perform but difficult to justify.

Assume that in the given differential equation the quantities $x$ and $y$ are functions of a hidden variable $t$ (time). Then the equation $y\>y'=e^x$ is equivalent to $y(t){\dot y(t)\over \dot x(t)}\equiv e^{x(t)}$, resp. $$y(t)\dot y(t)\equiv e^{x(t)}\dot x(t).$$ Integrating this from $t=0$ to $t=T$ one gets $${1\over2}(y^2(T)-y_0^2)=e^{x(T)}-e^{x_0},$$ where $(x_0,y_0)$ is the initial condition and $T$ is arbitrary. This means: At any given time the quantities $x$ and $y$ are related by the equation $${1\over2}(y^2-y_0^2)=e^x-e^{x_0}.$$ Looking back, one can see that the relation between $x$ and $y$ obtained in this way is exactly the equation obtained by following the recipe given in the books.

maybe its better to think of it as $y\frac{dy}{dx}=e^x$. the two functions of $x$ are equal, so their indefinite integrals (with respect to $x$) are equal (i.e. the way you talked about it at the end). moving the "differentials" around is more of a convenience.

I encountered a similar problem: I had to study the solution to second order autonomous differential equations. I found it fruitful to first think of symbols like "$$dx$$" or "$$dt$$" as small quantities and then take limits. Possibly this is the way Newton and Leibniz thought about infinitesimals.

So, going back to your (very nice) example, let us think about the two integrals as limits of sums. Each summand on the right is of the shape $$e^{x_k} (x_k - x_{k-1})$$ (here I've put the function value to the right of the interval, but it doesn't matter, because the exponential function is continuous and the intervals get smaller and smaller in the limit which we are going to take), and on the left hand side there are summands $$y(x_k) (y(x_k) - y(x_{k-1})).$$

Now we make the intervals smaller and smaller, and due to the continuity of $$y$$ and the fact that we may set $$z_k = y(x_k)$$ to simplify the right hand side summands to $$z_k (z_k - z_{k-1})$$ (which corresponds to the integral of the function $$f(w) = w$$), we can already sort of see that we get the right answer. (Of course, we then also have to take the limits of the integration into account; notationally, I've found that it helps using capital letters for these.)

• Note that this works for functions of $y$ that are different from the identity. Indeed, then we get $f(z_k) = f(y(x_k))$ for a generic $f$. Feb 16 at 21:40
• I'm still having trouble making this work in an easy way for the Lebesgue integral, which is a pity, because the Lebesgue integral is conceptually much cleaner, representing the area below a graph. Feb 16 at 21:45

Seperation of variables involves manipulating the differentials (the $dx$'s and $dy$'s in your equation). A differential is the infinitesimal change in a variable, and can be treated as a variable in its own right in many applications. With this perspective, $dy$ is a function of $x$ and $dx$, and the derivative $dy/dx$ is the ratio of these two differentials, which is a function of $x$. What you are doing is simply performing an algebraic manipulation of these variables and then using calculus to remove the differential terms.

• The $dx$ and $dy$ are coming from a single limit. That's what I've been taught in calculus. This answer is logically equivalent to saying "you can do that because you can do that". Mar 16, 2011 at 17:20
• They can be defined differently as I described. For a more detailed discussion, see en.wikipedia.org/wiki/Differential_of_a_function#Definition. Mar 16, 2011 at 17:25
• Thanks for the link, but the description there is not what you said. Differentials as described in Wikipedia are not infinitesimal changes. Mar 16, 2011 at 17:30
• That's naive unless you're willing to work in a non-standard setting, which is far from what the OP wanted. Mar 17, 2011 at 11:57
• Leibniz's calculus of differentials isn't exactly radical. Mar 17, 2011 at 14:06