# Solving a linear PDE: $x^2 u_x - 2u_y - xu = x^2$

For a homework problem in my course on PDEs, I'm to find the general solution to the following PDE:

$$x^2 u_x - 2u_y - xu = x^2$$

In addition, I'm to find the solution corresponding to the initial condition $$u(x,0)=e^x$$ and to graph some of the characteristic curves, but neither of those should really pose any trouble.

What is giving me trouble is finding the general solution. In essence, from what I've gathered is we are supposed to set up an equation

$$\frac{du}{dx} = u_x + u_y \frac{dy}{dx}$$

This equation should simplify somehow in general (drawing on the original PDE's partial derivatives) and lead to a simple ODE in which we solve for $$y$$.

However, here I get (noting that $$dy/dx = -2/x^2$$)

$$\frac{du}{dx} = \frac{x+u}{x}$$

which I can't really seem to do anything with. Notably, I was able to find something of that $$x^2$$ was just $$0$$ (the homogenous case), which would negate the $$x$$ in the numerator and make life so much easier, but I feel like that isn't how to go.

Is there something I'm missing? How exactly would one go about solving this?

For what it's worth, the solution is supposedly

$$u(x,y) = x \cdot f(y-2/x) + x \ln x$$

in the general case, from what I could look up online.

I'll give a comprehensive answer because I'm not sure what the whole problem is here. If you are just asking how to solve $$u' = \frac{x + u}{x}$$ then use an integrating factor (as I do below).
If we parameterise $$u = u(x,y)$$ with $$t$$ i.e $$u(x,y) = u(x(t),y(t))$$, then the chain rule says \begin{align} \frac{du}{dt} &= u_{x} \frac{dx}{dt} + u_{y} \frac{dy}{dt} \\ &= x^{2} u_{x} - 2 u_{y} \quad \text{(equating to PDE)} \\ &= xu + x^{2} \quad \text{(equating to PDE)} \end{align} Hence, the three ODEs you need to solve are \begin{align} x' &= x^{2} \\ y' &= -2 \\ u' &= xu + x^{2} \end{align} Eliminating $$dt$$ from each yields $$\frac{dx}{x^{2}} = \frac{dy}{-2} = \frac{du}{xu + x^{2}}$$ which is the parameterisation invariant form of the Charpits method. Now we just need to solve any two combinations of these equations. Solving the first two \begin{align} dy &= \frac{-2 dx}{x^{2}} \\ \implies y &= \frac{2}{x} + c_{1} \end{align} Solving the first and third \begin{align} u' &= \frac{u}{x} + 1 \\ \implies u' - \frac{u}{x} &= 1 \\ \implies \left( \frac{1}{x} u \right)' &= \frac{1}{x} \\ \implies \frac{1}{x} u &= \ln x + c_{2} \end{align} Now, for any differentiable function $$\phi$$, we have $$\phi(c_{1}, c_{2}) = 0$$ and hence \begin{align} \phi(c_{1}, c_{2}) &= \phi \left(y - \frac{2}{x}, \frac{1}{x} u - \ln x \right) \\ \implies \frac{1}{x} u - \ln x &= f \left(y - \frac{2}{x} \right) \quad \text{(equivalent to the form above)} \\ \implies u &= x \ln x + x f \left(y - \frac{2}{x} \right) \end{align}