# Converting Dirichlet Boundary Conditions to Neumann Boundary Conditions for the Heat Equation

I'm solving the heat equation on a two dimensional square domain. The problem is defined as: $$u_{xx}+u_{yy} = 0 \hskip{0.5cm}\text{for} \hskip{0.5cm} 0 \leq x \leq 1, 0 \leq y \leq 1$$ with the following boundary conditions: $$u(0,y)= 0, \hskip{0.5cm} u(1,y)= 0, \hskip{0.5cm} u(x,1)= 0, \hskip{0.5cm} u(x,0)= sin(\pi x)$$ I'm able to solve this eqations both numerically and analytically, however I'm having trouble with the following: I would like to convert the boundary condition on $u(x,0)$ to an equivalent Neumann boundary condition. I've tried the following: $$u_x(x,0) = \pi cos(\pi x)$$ However this is not resulting in a satisfactory result. Is my thinking correct?

edit:

The exact solution I get is: $$u(x,y)= sin(\pi y) \cdot \left[ cosh(\pi x) - coth(\pi) \cdot sinh(\pi x) \right]$$

Edit:

I've got it working now using $u_y(x,y) = \pi cosh(\pi) / sinh(\pi) sin(\pi x)$ as the neumann boundary condition.

Look at a solution $v(x,y)$ of the Neumann problem \begin{align*} v_{xx}+v_{yy}& =0\text{ in the unit square} \\ v_{x}(0,y)=v_{x}(1,y)& =0 \\ v_{y}(x,1)& =0 \\ v_{y}(x,0)& =-\pi \cos \pi x. \end{align*} Now obtain a solution $u(x,y)$ of your Dirichlet problem as the curve integral \begin{equation*} u(x,y)=\int_{\varphi }\left( -v_{y}\mathrm{\,d}x+v_{x}\,\mathrm{d}y\right) , \end{equation*} where $\varphi$ is any curve in the unit square connecting $(0,0)$ to $(x,y)$. By the Gauss-Green theorem and the heat equation satisfied by $v$, the value of this integral is independent of the path. For example, \begin{equation*} u(x,y)=-\int_{0}^{x}v_{y}(s,0)\mathrm{\,d}s+\int_{0}^{y}v_{x}(x,t)\,\mathrm{d }t. \end{equation*} From this follows that \begin{align*} u_{x}& =-v_{y} \\ u_{y}& =v_{x}, \end{align*} and hence \begin{equation*} u_{xx}+u_{yy}=-v_{yx}+v_{xy}=0. \end{equation*} Also the Dirichlet boundary values are easily checked.