How i can put the Neumann BC in my code? I tested but I get error, because the arrays are not the same size
$$U_t=U_{xx},\quad 0<x<1$$
$$u_x(0,t)=0$$ $$u_x(1,t)=0$$
$$u(x,0)=f(x)$$
I have my equation discretized by the method and my program
the BC Neumann it are when $i=1$ :
$$u(2,j)=u(0,j)$$
$$u(n+1,j)=u(n-1,j)$$
here is the problem with the boths BC
an apology if not in code here is somewhat long, thanks for your help!


By my comment, here is what I meant:
I solved the PDE analytically and obtained: $$ u(x, t) = \frac{1}{\pi}\sum_{n = 1}^{\infty}\frac{\sin[(2n -1)\pi x]}{2n -1}\exp(-\pi^2(2n-1)^2t) $$ where I assumed $f(x) = 1$ just so I could plot something.