Commit c31e7bfc authored by Jochen Schulz's avatar Jochen Schulz
Browse files

added exercises 25

parent 461a3205
%% Cell type:markdown id: tags:
# Exercises 25
##problem 1
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 &- 1 &- 1 \end{array}\right)$$
You can use repa stencils for this. Reading the image can also be done with
```haskell
import Data.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
import Graphics.Rendering.Plot
import Data.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).
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 $$
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.
For a testcase use the appropriate stencil for the 1d poisson equation.
......@@ -181,12 +181,6 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment