Let us say I want to use Forward Euler scheme to solve the heat equation $$ \frac{\partial u}{\partial t} = -\frac{\partial^2 u}{\partial x^2} $$ in the domain $t \in (0, 1)$, $x \in (0,1)$ but instead of an initial condition $u(x, 0)$ I have the end condition $u(x, t=1)$. How will then the Forward Euler look? Can I simply step backwards like this: $$ \frac{u_j^{n-1} - u_j^n}{\Delta t} = - \left( \frac{u_{j+1}^{n} -2u_j^{n} + u_{j-1}^n}{(\Delta x)^2} \right) $$ where $n$ are the time-steps and $j$ are the $x$-steps. The reason I have doubts about this solution is that when I try to look at the truncation error for this scheme by Taylor-expanding LHS at $t_n$ and RHS at $x_j$, I end up with the expression $$ -\frac{\partial u}{\partial t} + O(\Delta t) = -\frac{\partial^2 u}{\partial x^2} + O(\Delta x) $$ which does not allow me to substitute the exact solution $\frac{\partial u}{\partial t} = -\frac{\partial^2 u}{\partial x^2}$ since the expressions have opposite signs. I don't see that my Taylor expansions have any errors, so it might seem that the whole method is wrong?
Any help much appreciated.
Note that equation you're solving is not exactly the heat equation, since the heat equation is $$ \frac{\partial u}{\partial t} = \varkappa \frac{\partial^2 u}{\partial x^2}, \qquad \varkappa > 0, $$ but If you're solving your problem backward in time, the problem becomes well posed only when $\varkappa < 0$, and you need to be careful when approximating the time derivative with a finite difference. Whatever the time direction is the time derivative is approximated as $$ \frac{u^{n} - u^{n-1}}{\Delta t} $$ assuming $\Delta t > 0$ and as $$ \frac{u^{n-1} - u^{n}}{\Delta t} $$ if $\Delta t < 0$. That's a matter of convention, no more. Since you've moving backward in time the $\Delta t = t_{n-1} - t_n < 0$. Thus $$ u^{n-1} = u(t_{n-1}) = u(t_{n} + \Delta t) = u(t_n) + \Delta t u_t(t_n) + O(\Delta t^2), $$ so you would have $$ \frac{\partial u}{\partial t} + O(\Delta t) $$ on the left side.