Consider a problem of solving $$ \begin{align*} -\Delta u &= f, \\ u|_\Gamma &= 0. \end{align*} $$ by a spectral method, where $\Omega = [0,1]^2$ is a unit square and $\Gamma=\partial\Omega$.
In a spectral method you will be working with a representation of the solution in the form $$ u(x,y) = \sum_{i=1}^N \sum_{j=1}^N \hat{u}_{i,j} \sin(\pi i x) \sin(\pi j y), $$ where $\hat{u}^N$ is just an $N\times N$ array.
Knowing $u(x,y)$, it is often practically not possible to compute $\hat{u}_{i,j}$ exactly. Hence one needs to use the Discrete Sine Transform (DST). The python's dst computes a one-dimensional DST, but we need a two-dimensional (2D) DST, which we compute in the following way:
Compute values $u(x,y)$ for $N^2$ points inside the domain $(x,y) = (h k, h \ell)$, $1\leq k,\ell \leq N$, $h = 1/(N+1)$.
Apply dst to each line in this array. This way you will be computing a "partial" 2D DST $$ u(x,y) = \sum_{j=1}^N \tilde{u}_{j}(x) \sin(\pi j y), $$
Apply dst to each column in the resulting array. This way you will be computing a full 2D DST.
Part (a)
In this case, obviously, a solution to the problem is $u=u_0$, but let us now pretend we do not know it.
(6pt) Compute the coefficients $\hat{u}^N$ from $\hat{f}^N$ found in part (a).
(6pt) We will estimate the error between the two solutions in the following way. We will take $N^2$ points in our domain, of the form $(h k, h \ell)$, same as before. We will then be interested in $$ {\rm err}_N = \max_{1\leq k,\ell\leq N} |u^N(h k, h \ell) - u^0(h k, h \ell)| $$ which we call an error of the solution. Calculate the error of your solution for a number of values of $N$. Explain your results
Part (b)
Part (c)
(6t) Instead of the exact error we have to use the error estimate $$ {\rm errest}_N = \max_{1\leq k,\ell\leq N} |u^N(h k, h \ell) - u^{2N+1}(h k, h \ell)| $$ (Why did we take $2N+1$ instead $2N$?) Report the values of ${\rm errest}_N$ for a sequence of values of $N$.
(6pt) Hence compute ${\rm errest}_N$ for a sequence of $N$ and comment on your results.
Consider a Poisson equation $$ \begin{align*} -\Delta u &= f, \\ u|_\Gamma &= 0, \end{align*} $$ where $\Omega = [0,1]^d$, $d = 2, 3$ and $\Gamma=\partial\Omega$.
Although the multigrid method has optimal complexity, there are some precomputations to be done. Therefore, it may have a bigger constant than, for instance, the spectral method or even sparse LU. In this problem you will be asked to find out in which case (2D, 3D, grid sizes) multigrid method is more appropriate.
In [1]:
from IPython.core.display import HTML
def css_styling():
styles = open("./styles/alex.css", "r").read()
return HTML(styles)
css_styling()
Out[1]: