# Slight mistake in Stochastic Galerkin code

I'm following Paul Constantine's Primer on Stochastic Galerkin Method, Section 3.1 (2D Poisson Example). In this matlab code, the example attempts to solve the PDE $$\alpha(w)(u_{xx}+u_{yy})=1 \text{ in } \Omega=[-1,1]^2$$ $$u=0 \text{ on } \partial\Omega$$ with $\alpha(w)$ a uniformly randomly distributed variable whose values lie in $[1,3]$.

I was able to follow the derivation of the method and its implementation into the matlab available here. Except for one small detail...

In the matlab code, the linear operator $Lu=u_{xx}+u_{yy}$ was discretized by finite difference method using $n=16$ equispaced intervals. In my understanding of the problem, this would mean that $$\Delta x=\frac{2}{n}$$. However, the main program file *poisson_2d.m*, (line 38), he used

$$dx=1/n$$

I'm almost certain that this is a typo. Even though the stochastic galerkin code is supposedly verified by monte-carlo simulations, even the monte-carlo simulations use a finite difference discretization of $dx=1/n$.

I can't find any other reason to suspect that the spatial discretization of the laplacian for this problem should be $\frac{1}{n}$.

Can anyone, with some experience with this sort of thing, confirm/refute my suspicions?

• Have you asked the authors of the code? – Wolfgang Bangerth Oct 20 '13 at 2:05

I have just corresponded with the author of the software, and my suspicions were confirmed. The spatial stepsize for $n$ equispaced intervals for this problem should be $$\frac{x_{n+1}-x_0 }{n}=\frac{y_{n+1}-y_0}{n}=\frac{2}{n}$$.