# Heat equation with Neumann and Dirichlet conditions on same boundary

I am looking at numerical solutions to the heat equation with Dirichlet and Neumann conditions on the same boundary. That is $u(x,t)$ satisfying $$u_t = u_{xx}\,, \quad x \in[0,1]\,, \quad t>0\,,$$ with $$\begin{gathered} u(x,0) = u_0(x)\,,\\ u(0,t) = g(t) \quad \forall \, t>0\,,\\ u_x(0,t) = h(t) \quad \forall \, t>0. \end{gathered}$$ This is with a view to solving an advection-diffusion problem with the same BCs.

If I discretise on $N+1$ points, $$U^n_j \approx u(j \Delta x, n \Delta t)$$ with $\Delta x = 1/N$ then I would expect to discretise as $$(U_j)_t = \frac{1}{\Delta x^2}\left[ U_{j-1} - 2 U_j + U_{j+1} \right]\,,$$ but then I can't see how to discretise both the boundary conditions. If I let $$U_0(t) = g(t)\,,$$ and $$\frac{U_1(t) - U_0(t)}{\Delta x} = h(t)$$ then I have an issue determining $(U_N)_t$.

Resentfully I tried discretising with backwards difference twice $$(U_j)_t = \frac{1}{\Delta x^2}\left[ U_{j-2} - 2 U_{j-1} + U_{j} \right]\,,$$ which allows me to impose both boundary conditions on $(U_2)_t$, but I think this is unconditionally unstable.

Does this even make sense? I was thinking about a shooting method using a shooting parameter $s$ with $u(1,t)=s$ to try to match $u_x(0,t;s)=h(t;s)$ at each time step, but this feels inefficient.

• Possible duplicate: scicomp.stackexchange.com/q/20836 (or at least related)? – Christian Clason Nov 16 '16 at 21:35
• Short answer: This is called a lateral Cauchy problem and is the textbook example of an ill-posed problem (meaning it does not admit a stable solution), independent of any numerical method. There are ways of approximating this problem with a family of stable problems, such as the quasireversibility method (basically, add a very small fourth-order term to the equation, such that these boundary conditions become well-posed). But in general you should rather ask yourself whether that is really the right model. – Christian Clason Nov 16 '16 at 21:41