First order partial differential equation - how to finish the solution? I have problems solving this simple pde. I don't know what I'm doing wrong:
$$yu_x - u_y = y, \ \ \ u(x,0 ) = \frac{1}{x}$$
Here is how I do it. The equation is equivalent to this one:
$$\frac{dx}{y} = \frac{dy}{-1} = \frac{du}{y}$$
So $\frac{dx}{y} = - dy, \ \ dx=du$
This means that $dx = -ydy$ and $u = x+ C$
So $x + C' = - \frac{y^2}{2} $ and $u = x+C$
This above gives us an  integral curve $F(x,y) = - x - \frac{y^2}{2}$ of $yu_x - u_y=0$, but not of the main pde.
If we plug $F(x,0) = -x$, we get $u(x,0) = - \frac{1}{F(x,0)}$, so $u(x,y) = - \frac{1}{F(x,y)} = \frac{1}{x+ \frac{y^2}{2}}$, which is not the solution.
Could you help me fix it?
 A: Use method of characteristics.
First, reparameterise your curve letting
$$x \to x(s) \\
y \to y(s)$$
Hence you have
$$u = u(x(s), y(s))$$
Taking the total derivative wrt to $s$
$$\begin{align}
\implies \frac{d}{ds} u &= \frac{\partial u}{\partial x} \frac{dx}{ds} + \frac{\partial u}{\partial y} \frac{dy}{ds} \\
&= \frac{\partial u}{\partial x} \cdot y + \frac{\partial u}{\partial y} \cdot (-1) \\
&= y \\
\end{align}$$
Equating, we find
$$\begin{align}
\frac{dy}{ds} &= -1 \\
\implies dy &= -ds \ \ \ \ \ (1) \\
\frac{dx}{ds} &= y \\
\implies \frac{dx}{-dy} &= y \ \ \ \ \ \ \ \ \ \ (2) \\
\frac{du}{ds} &= y \\
\implies \frac{du}{-dy} &= y \ \ \ \ \ \ \ \ \ \ (3) \\
\end{align}$$
Solving
$$\begin{align}
(2) \implies x(s) &= \frac{-y^{2}}{2} + x_{0} \\
(3) \implies u(x, y) &= \frac{-y^{2}}{2} + f(x_0) \\
&= \frac{-y^{2}}{2} + f \bigg(x + \frac{y^{2}}{2} \bigg) \ \ \ \ \ \ (4) \\
\end{align}$$
Using our initial condition
$$\begin{align}
u(x,0) &= f(x) \\
&= \frac{1}{x} \\
\implies f \bigg(x + \frac{y^{2}}{2} \bigg) &=  \frac{1}{x + \frac{y^{2}}{2}} \\
\end{align}$$
Substituting into $(4)$, we find
$$u(x, y) = \frac{-y^{2}}{2} + \frac{1}{x + \frac{y^{2}}{2}}$$
You can check by differentiation that this satisfies the PDE and initial condition.
