Put together the stationary heat equation (poisson equation) with the explicit Euler method to be able to solve the *time dependent heat equation*.

Given a rectangular domain $\Omega \subset \mathbb{R}^2 $ and a time dependent function

$u(x,t) , x \in \Omega , t \in \mathbb{R}^{+}$. Then the time dependent heat equation is

$$\frac{\partial u}{\partial t} - \alpha \triangle u = 0 \text{ in } \Omega $$

where $\alpha \in \mathbb{R}$ is a constant . Given dirichlet boundary conditions

$$u = R , \text{ on } \partial \Omega$$

with a function $R: \partial \Omega \mapsto C(\partial \Omega)$. At time $t=0$ let

$$u(x,0) = f(x), \forall x \in \Omega.$$

with a arbitrary, but fixed initial function $f: \mathbb{R} \mapsto \mathbb{R}$.

*Remark:* Try to write the code with a sparse matrix (but with small number of points per axis up to 50 a dense matrix is also fine)

%% Cell type:markdown id: tags:

## problem 2

Lets look into a bit image transformation. Take the greyscale image `"images/Grayscale_8bits_palette.bmp"` and make a *edge detection* on it. *edge detection* works through applying a convolution of the (here grayscale values in every pixel) with the convolution-matrix

$$\left(\begin{array}

-- 1 & - 1 &- 1 \\

- 1 &8 &- 1 \\

- 1 & 8&- 1 \\

- 1 &- 1 &- 1 \end{array}\right)$$

You can use repa stencils for this. Reading the image can also be done with

```haskell

importData.Array.Repa.IO.BMP(readImageFromBMP)

```

You can either write the image again (and the show it with an imageviewer) or you can use

the simple plot-interface

```haskell

importGraphics.Rendering.Plot

```

together with

```haskell

importData.Packed.Repa(repaToMatrix)

```

%% Cell type:markdown id: tags:

## problem 3

Remember the *Jacobi* method to solve an system of linear equations. Rewrite the Jacobi method that it works with *stencils* (so the forward operator is given as stencil).

Remember the *Jacobi* method to solve an system of linear equations. Rewrite the Jacobi method that it works with *stencils* (so the forward operator is given as a stencil).

For this you also the need the componentwise version of the Jacobi method, which is given by

$$x_i^{( k + 1 )} = \frac{1}{a_{ii}} ( b_i - \sum_{j = i} a_{ij} x_j^{( k )} ) , i = 1 , 2 , … , n $$

$$x_i^{( k + 1 )} = \frac{1}{a_{ii}} ( b_i - \sum_{j \neq i} a_{ij} x_j^{( k )} ) , i = 1 , 2 , … , n $$

where $a_{ij}$ are the component of the matrix $A$, $b$ is the right hand side and the $x$ starts from an initial guess.

You can work along the line of the example of the cg-method from the lecture.

You can work along the lines of the example of the cg-method from the lecture (create a stencil, a right hand side and a jacobi function which makes the parallel computation)

For a testcase use the appropriate stencil for the 1d poisson equation.

For a testcase use the appropriate stencil and right hand side for the 2d poisson equation.