Mayank447 / Pseudo-Spectral-Discretization

GNU General Public License v3.0
0 stars 1 forks source link

Fix dimensionful formulae #27

Closed chillenzer closed 1 month ago

chillenzer commented 1 month ago

Re-opening of #19. Here again the reasoning from the comment there:

Our eigenfunctions have the form

\left\langle x \mid p \right\rangle = Ce^{ipx}

for some yet to determine normalisation constant $C$. Now, we want

1 = \left\langle p \mid p \right\rangle = |C|^2 \int_0^L \mathrm{d}x\; e^{-ipx}e^{ipx} = C^2 L \quad \Leftrightarrow |C| = \frac{1}{\sqrt{L}}

This fixes the normalisation of the continuum eigenfunctions. Now, the weight in the quadrature could be computed from the general formulae but is quite simply guessed if you just approximate the integral by a Riemann sum:

\int_0^L\mathrm{d}x\; \dots \longrightarrow \sum_{i=0}^{N-1}\Delta x \; \dots

Expansion:

The missing piece in the old version was the following: The FFT (with norm='ortho') projects onto a basis with $C = 1/\sqrt{N}$, so assumes $\Delta x = 1$. So, if given a periodic function $f:[0,L]\to C$ we have

f(x) = \sum_p \left\langle x\mid p \right\rangle\left\langle p \mid f\right\rangle = \frac{1}{\sqrt{L}}\sum_p e^{ipx} f_p

while the inverse FFT convention yields

f(x) = \frac{1}{\sqrt{N}}\sum_p e^{ipx} f_p

and we can see that we lack a factor of $1/\sqrt{\Delta x}$ because $L = N\Delta x$. The factor for the forward transformation is obviously the inverse because

\mathrm{FT}^{-1} = \frac{1}{\sqrt{\Delta x}} \mathrm{FFT}^{-1} \quad \Rightarrow \quad \mathrm{FT} = \left(\frac{1}{\sqrt{\Delta x}}\right)^{-1} \mathrm{FFT}

In particular, we can see that we can only ever get a unitary transformation if $\Delta x=1$.

Please review and merge at your earliest convenience.

Mayank447 commented 1 month ago

Makes sense

Mayank447 commented 1 month ago

But before merging. I will add tests to check normalization of eigenfunctions. Will merge if it passes the tests