# Solving PDE using the method of characteristics

I am trying to solve this PDE using method of characteristics:

$u_y + 3u_x = -u^2, u(x,0)=f(x)$

This is how I started:

$\frac{dy}{ds}=1$

$\frac{dx}{ds}=3$

$\frac{du}{ds}=-u^2$

I then integrated these equations and got:

$y=s+y_0$

$x=3s+x_0$

$u=\frac{1}{s+u_0}$

Next step, find $s$ and $u_0$. I let $y_0=0$ so $s=y$. To get my $u_0$:

$u_0=u(x_0,0)=f(x_0)$

$x_0=x-3y$

$u_0=f(x-3y)$

Finally, I put $s$ and $u_0$ in my expression for $u$ to get the solution:

$u(x,y)=\frac{1}{y+f(x-3y)}$

But that isn't the same solution as the one my professor got. I don't understand what I did wrong. Is there something wrong with my use of the initial condition?

Obviously, the solution that you got $\quad u(x,y)=\frac{1}{y+f(x-3y)}\quad$ doesn't fit the specified boundary condition :

$u(x,0)=\frac{1}{0+f(x-3(0))}=\frac{1}{f(x)}$ which is not $u(x,0)=f(x)$ as expected.

In fact, you found the general solution : $$\quad u(x,y)=\frac{1}{y+F(x-3y)}$$ where $F$ is an arbitrary function.

Don't confuse $F$ with $f$.

Then, the condition is :

$u(x,0)=\frac{1}{0+F(x-3(0))}=\frac{1}{F(x)}=f(x)\quad$ which determines the function $F(X)=\frac{1}{f(X)}$

Putting it into the general solution where $X=x-3y$ and $F(x-3y)=\frac{1}{f(x-3y)}$leads to the particular solution which fits the condition.

$u(x,y)=\frac{1}{y+F(x-3y)}=\frac{1}{y+\frac{1}{f(x-3y)}}$ $$u(x,y)=\frac{f(x-3y)}{y\;f(x-3y)+1}$$