# Control of the heat equation

We describe here a simple example for the one dimensional heat equation, over the domain $Latex formula$. We set $Latex formula$, where the final time is fixed. The control $Latex formula$ is either (i) over a part of the domain, with Dirichlet conditions, or (ii) at the boundary by the Neumann condition. So the state equation is in case (i)

$Latex formula$

$Latex formula$

where $Latex formula$, and $Latex formula$ is the characteristic function of $Latex formula$, and in case (ii)

$Latex formula$

$Latex formula$

The cost function is, for $Latex formula$ and $Latex formula$:

$Latex formula$

We discretize in space by standard finite difference approximations.

Numerical simulations: problem heat
As an example, we take 50 space variables, with $Latex formula$, $Latex formula$, and a final time T=20.
The discretization method is implicit Euler with 200 steps.
We set here $Latex formula$, which gives a singular arc for the control.
We display on Fig. 1 the results in the case of the Dirichlet boundary condition $Latex formula$.
Fig. 2 shows the Neumann case, this time with $Latex formula$.
We can clearly see the differences between the boundary conditions $Latex formula$ and $Latex formula$.

Figure 1: Heat equation, Dirichlet condition, $Latex formula$ and $Latex formula$.

Figure 2: Heat equation, Neumann condition, $Latex formula$ and $Latex formula$.