<s>[INST] Get $f(x)=u_x\frac{x}{u}$ from ODE for $u$ Consider the Cauchy-Euler ODE
\begin{align*}
\frac{1}{2}x^2u_{xx}+xu_x-u=0.
\end{align*}
Guessing $u(x)=Cx^n$ gives
\begin{align*}
\frac{1}{2}n(n-1)Cx^n+nCx^n-Cx^n=0,
\end{align*}
which we can solve to get
\begin{align*}
n_1&=-2,\\
n_2&=1.
\end{align*}
Given initial conditions and boundary behavior, we can pin down a unique solution.

I'm really interested in the function $$f(x)=u_x\frac{x}{u}.$$ Given the solution for $u$, we can compute $f$ to be $f(x)=n$, which is constant!
Q: I wonder whether I can find $f$, without solving the ODE first?

Set $f=u_x\frac{x}{u}$. Then, $u_x=\frac{fu}{x}$ and $u_{xx}=\frac{f_xu}{x}+\frac{fu_x}{x}-\frac{fu}{x^2}$. The ODE then turns into
\begin{align*}
\frac{1}{2}\left(xf_xu+xfu_x-fu\right)+fu-u=0.
\end{align*}
Dividing this ODE by $u$ gives
\begin{align*}
\frac{1}{2}\left(xf_x+f^2-f\right)+f-1=0.
\end{align*}
If I assume $f_x=0$, then I get
\begin{align*}
\frac{1}{2}f^2+\frac{1}{2}f-1=0,
\end{align*}
which is a normal quadratic equation with solutions
\begin{align*}
f_1&=-2,\\
f_2&=1.
\end{align*}
These are precisely the solutions I expected from the previous calculations.

However, I had to assume $f_x=0$. I only knew this because I already knew the solution.
Why doesn't the second approach work? Is there a way to compute $f(x)$ without first solving the ODE for $u(x)$?
 [/INST] Your claim that $f$ is a constant for any $u$ which satisfies the given equation is false. Indeed,
$$u(x) = \frac{x^3 + 1}{x^2}$$
certainly satisfies the equation, but using that $u$ we have
$$ f(x) = \frac{x^3-2}{x^3+1} $$
Now, it's certainly true that some $u$ which satisfy the original equation make $f$ constant. In particular, it seems you were considering the $x^n$ solution. In general,
$$ u(x) = ax + bx^{-2} $$
so if we force one of $a,b$ to be zero, then we have the desired identity. We can get those by imposing the initial conditions $ u(0) = 0 $ for $b$ to vanish, and $ u(\infty) = 0 $ for $a$ to vanish.
In fact, setting $f'$ to zero gives an equation for $u$ with solution
$$u(x) = \alpha x^\beta$$
showing that this result is independent of the original equation for $u$.
</s>