Is it mathematically valid to separate variables in a differential equation? [duplicate]

The problem with this form of separation of variables (I say "this form" because "separation of variables" can refer to multiple things) is that treating the derivative $dy/dx$ as a ratio is a purely formal algebraic manipulation. There is a way to arrive at the same results in a rigorous fashion, but textbooks often don't address this.

To elaborate, separation of variables in ODEs most commonly refers to a method of solving the ODE $$ \frac{dy}{dx} = g(x)h(y) $$ for the unknown function $y(x)$. Introductory textbooks often tell you to split the "fraction" $dy/dx"$ and unite common variables, like so: $$ \frac{dy}{h(y)} = g(x)dx $$ and then integrate both sides, as long as $h(y)\neq 0$, to obtain $$ H(y(x)) = \int g(x)~dx + C, $$ where $H(y)$ is an antiderivative of $\frac{1}{h(y)}$.

Unfortunately "$dy$" and "$dx$" have no actual mathematical meaning in this context, so all we've done is pull a little algebraic trick without understanding why it works. To resolve this, we rearrange: $$ \frac{1}{h(y)}\frac{dy}{dx} = g(x). $$ Integrating in $x$, $$ \int \frac{1}{h(y(x))}\frac{dy}{dx}(x)~dx = \int g(x)~dx + C. $$ Now if $H(y)$ is an antiderivative of $1/h(y)$, then by the chain rule $$ \frac{d}{dx}H(y(x)) = \frac{1}{h(y(x))}\frac{dy}{dx}(x) $$ so the left-hand integral is $$ \int \frac{1}{h(y(x))}\frac{dy}{dx}(x)~dx = \int \frac{d}{dx}H(y(x))~dx = H(y(x)) $$ leading us to our desired conclusion, $$ H(y(x)) = \int g(x)~dx + C. $$

Doing it this way gives a rigorous justification of the result, but frankly the abuse of notation with the symbolic approach is much easier for most to memorize, so it is often the way it is taught to students. However, I think not explaining why the abuse of notation works confuses many students, both about the method and about their already flimsy understanding of the derivative.


You are misunderstanding what they mean by not mathematically valid in this situation. It has little to do with whether or not there is a proof and more to do with some formalism.

When we write $\frac{dy}{dx}$ I'm sure you've heard already that this is not a fraction. In particular this is really saying to apply the differential operator $\frac{d}{dx}$ to the function $y$.

So when you perform separation of variables by transitioning from $\frac{dy}{dx}=g(x)h(y)$ to $\frac{dy}{h(y)}=g(x)dx$ we have done something that seems to be fundamentally incorrect we took the operator $\frac{d}{dx}$ and split it as if it was a fraction. This obviously makes no sense if we really think of $\frac{d}{dx}$ as an operator and moreover the $dx$ and $dy$ we end up with make no sense either as we don't even know what they should mean.

On the other hand the resulting integrals $\int\frac{1}{h(y)}dy=\int g(x)dx$ actually have a reasonable mathematical meaning and moreover assuming $g(x)$ and $h(y)$ aren't very awful you get the correct result.

Now the fact that the resulting integral equation gives you the correct result is absolutely provable, we just shouldn't have gotten to it the way we did. Instead the following approach is appropriate:

$$\frac{dy}{dx}=g(x)h(y)$$ then assuming $h(y)$ is not $0$. $$\frac{1}{h(y)}\frac{dy}{dx}=g(x)$$ Further assuming both sides are integrable we get $$\int\frac{1}{h(y)}\frac{dy}{dx}dx=\int g(x)dx$$ Now performing a substitution in the integral on the left we get $$\int\frac{1}{h(y)}dy=\int g(x)dx$$

Now even in this explanation I've cheated in a few places slightly but it's a reasonable first approximation to explaining why separation of variables is a correct method for solving differential equations.

Edit You can actually build mathematics in such a way that $dy$ and $dx$ do have a reasonable meaning on their own and that you can pretty much treat $\frac{dy}{dx}$ as a fraction. This is usually called non-standard mathematics and makes use of something called infinitesimals. It's not particularly easy to do though and you still end up having some issues.