Why is it legitimate to solve the differential equation $\frac{dy}{dx}=\frac{y}{x}$ by taking $\int \frac{1}{y}\ dy=\int \frac{1}{x}\ dx$? Answers to this question Homogeneous differential equation $\frac{dy}{dx} = \frac{y}{x}$ solution? assert that to find a solution to the differential equation $$\dfrac{dy}{dx} = \dfrac{y}{x}$$ we may rearrange and integrate $$\int \frac{1}{y}\ dy=\int \frac{1}{x}\ dx.$$  If we perform the integration we get $\log y=\log x+c$ or $$y=kx$$ for constants $c,k \in \mathbb{R}$.  I've seen others use methods like this before too, but I'm unsure why it works.
Question: Why is it legitimate to solve the differential equation in this way?
 A: I don't like the notation that's often used when solving ODEs.  I'd prefer to write the solution like this:
\begin{align}
& y'(x) = \frac{y(x)}{x} \quad \text{for all }x > 0 \\
\implies & \frac{y'(x)}{y(x)} = \frac{1}{x} \quad \text{for all }x > 0 \\
\implies & \log y(x) = \log x + C \quad \text{for all } x > 0 \,(\text{for some } C \in \mathbb R).
\end{align}
(I'm assuming $y(x) > 0$ for all $x>0$.)
A: To be honest I think it's BS to teach separable variables like this without the Riemann-Stieljes integral. The way I solve them is by doing what actually is done: integrate with respect to $x$ on both sides.

Remember that $y$ is a function (on the variable $x$). So your differential equation is, for all $x$ in a certain interval, $y'(x)=\dfrac{y(x)}{x}$ or equivalently $\dfrac{y'(x)}{y(x)}=\dfrac {1}{x}$and integrating with respect to $x$ you get the desired result.
In my opinion integrating with respect to $y$ is nothing more than a cheap trick, the same way $\dfrac{dy}{dx}=1\iff dy=dx$ is a cheap trick. It works only because of some higher math.

More generally, if you can rewrite your DE as $g(y(x))y'(x)=f(x)$ for some functions $f$ and $g$ that have antiderivatives, $F$ and $G$, in the given interval, then $g(y(x))y'(x)=f(x)\iff G(y(x))=F(x)+C$, for some $C\in \Bbb R$. (To establish $\Longleftarrow$ just differentiate). And if we're lucky enough for $G$ to be invertible, we get $y(x)=G^{-1}\left(F(x)+C\right)$. If $G$ isn't invertible, then hopefully the implicit function theorem will yield the solutions to the DE implicitly by the equation $G(y(x))=F(x)+C$.
In your example $g$ is the function $t\mapsto \dfrac{1}{t}$ which has $t\to \log (|t|)$ as an antiderivative. (Don't forget the absolute value).
A: You start with
$$
y'=\frac{y}{x}\implies \frac{y'}{y}=\frac{1}{x}\implies\int\frac{y'dx}{y}=\int \frac{dx}{x},
$$
and you make the change of variables in the first integral, which results in what you've written
$$
\int\frac{dy}{y}=\int \frac{dx}{x}
$$
A: $$\frac{dy}{dx} = \frac{y}{x}  \implies  (\frac{dy}{dx})\times \frac{1}{y} = \frac{1}{x}$$ ... integrating both sides wrt to $dx$ gives
$$\int \frac{1}{y}(\frac{dy}{dx})dx  = \int\frac{1}{x}dx  =>  \int \frac{1}{y}dy = \int \frac{1}{x}dx$$
So we are not integrating each side with respect to different variables, but with respect to $x$, and $(dy/dx)*dx = dy$, which then allows integration by the separate variables.
