# How to do Weierstrass-transform in MATLAB?

I have a diagonalization problem. I have the eigenstates correctly, and I want to do a Gaussian-smearing (Weierstrass-transform) on them. So I have the wave functions ($$\Psi$$), and the continuous equation:

$$\zeta(x)=\int \mathrm{d} x' g_{\sigma_x}\left(x-x'\right)\left|\Psi(x')\right|^2,$$

where $$g_{\sigma_x}$$ is a normal distribution.

I do not know, how to do this with discrete vectors in MATLAB, i.e., $$|\Psi|^2, \zeta \in \mathbb{C}^n$$.

What you want is the convolution between two functions $$f = |\Psi|^2$$ and $$g = g_{\sigma_x}(x)$$, $$h = (f * g)(x)$$.

You can compute the Fourier transform of $$h$$, to get

$$\mathcal{F}\{h\} = \mathcal{F}\lbrace f\rbrace \mathcal{F}\lbrace g\rbrace\, ,$$

and then, just compute the inverse Fourier transform to obtain what you want

$$h = \mathcal{F}^{-1}\lbrace\mathcal{F}\lbrace f \rbrace \mathcal{F}\lbrace g\rbrace\rbrace\, .$$

To do that in MATLAB, you need to sample your functions over your domain and use the Fast Fourier Transform instead. Maybe, MATLAB already has something like fftconvolve.

• Thanks, I think this has to work. Now I have problem only with normalization. $\sum_n \zeta(n)$ has to be one. – Zsombor Jun 2 '19 at 19:22
• @Zsombor, you can divide by the norm of it. – nicoguaro Jun 2 '19 at 19:23