Numerical solution of a 1st order PDE

79 Views Asked by At

I tried to solve numerically this problem

$$ \begin{cases} u_x+3u_t=x\\ u(0,t)=3t^2 \end{cases} $$

Firstly, I solved it analitically, in order to have also the exact solution, that is

$$u(x,t)=\frac{x^2}{2}+3(t-3x)^2$$

Then I tried to solve it by finite differences method. I'll show You the passages:

$$ \begin{cases} \displaystyle \frac{u_{i+1,j}-u_{i,j}}{h}+3\frac{u_{i,j+1}-u_{i,j}}{k}=x_i\\ u_{0,j}=3t_j^2\\ x_{i+1}=x_i+h\\ t_{j+1}=t_j+k \end{cases} $$

Expliciting $u_{i+1,j}$ in the first recurrence relation, I obtained

$$ \begin{cases} \displaystyle u_{i+1,j}=\frac{k+3h}{k}u_{i,j}-\frac{3h}{k}u_{i,j+1}+hx_i\\ u_{0,j}=3t_j^2\\ x_{i+1}=x_i+h\\ t_{j+1}=t_j+k \end{cases} $$

So, I chose a sample step $h=k=10^{-11}$, and I noticed that the result explodes and, after 35 steps, $u_{35,j}=-3.09577358321454$, while the exact solution yields $1.62\cdot 10^{-18}$.

I just want to ask if there is any mistake in the reported computation of the recurrence relation or else if there is some possible mistake in the use of the formula. Can anyone suggest me an idea? Thanks in advance.