General solution to $\frac{\partial u}{\partial x}+xy \frac{\partial u}{\partial y}=x^2$ I need to solve the following first order linear partial differential equation:
$$\frac{\partial u}{\partial x}+xy \frac{\partial u}{\partial y}=x^2$$
I could solve solve the homogeneous equation
$$\frac{\partial u}{\partial x}+xy \frac{\partial u}{\partial y}=0$$
by setting $u(x,y)=f(x)g(y)$:
$$f(x)'g(y)+xyf(x)g'(y)=0$$
After separation, we get 2 simple differential equation. Solving them, we get that the solution for $f$ and $g$ are
$$f(x)=k_1\exp\left(\frac{cx^2}{2}\right)$$
and
$$g(y)=k_2y^{-c}$$
so
$$u(x,y)=k\exp\left(\frac{cx^2}{2}\right)y^{-c}$$
So the general solution to the homogeneous part is
$$u(x,y)=c_1\exp\left(\frac{c_2x^2}{2}\right)y^{-c_2}+c_3$$ 
Q: How can I find the general solution to the original equation?
 A: Using the method of characteristics, we see that
\begin{align}
\frac{d}{dx}u(x, y(x))= \frac{\partial u}{\partial x}+y'(x) \frac{\partial u}{\partial y } = x^2
\end{align}
where $y'(x) = yx$ and $u(0, y) = f(y)$.
Solving for $y$ yields
\begin{align}
y = y_0\exp\left(\frac{1}{2}x^2\right)
\end{align}
where $y_0 = y(0)$. Hence it follows
\begin{align}
u(x, y)= u(0, y_0)  + \frac{1}{3}x^3 = u(0,y\exp(-x^2/2))+\frac{1}{3}x^3= f(y\exp(-x^2/2))+\frac{1}{3}x^3. 
\end{align}
A: $$\frac{\partial u}{\partial x}+xy \frac{\partial u}{\partial y}=x^2$$
System of characteristic ODEs :
$$\frac{dx}{1}=\frac{dy}{xy}=\frac{du}{x^2}$$
First characteristics, from $\quad\frac{dx}{1}=\frac{dy}{xy}$ :
$$ye^{-\frac12 x^2}=c_1$$
Second characteristics, from $\quad\frac{dx}{1}=\frac{du}{x^2}$ :
$$u-\frac13 x^3=c_2$$
General solution : $\quad u-\frac13 x^3=F\left(ye^{-\frac12 x^2}\right)\quad$ where $F$ is an arbitrary function.
$$u(x,y)=\frac13 x^3+F\left(ye^{-\frac12 x^2}\right)$$
The function $F$ has to be determined according to some boundary conditions (Which are not specified in the wording of the question).
