Compute integral of periodic function numerical spectrally

166 Views Asked by At

I have a $2\pi$-periodic function $f(x)$, and I want to calculate numerically the integral $\int_{0}^{\alpha}f(x)dx$ where $\alpha$ is a point in the interval $[0,2\pi]$. I have the function evaluated in the points of a grid on that interval. I know that schemes like the trapezoidal rule converges spectrally for periodic functions, then I can calculate $\int_{0}^{2\pi}f(x)dx$ accuratelly with the points that I have. However, this rule do not allow me to calculate the integral up to $\alpha$, a point inside the interval, with the accuracy I need. I wonder if there is a scheme that allows me to perform this with spectral accuracy, for example using the fourier transform or something like that.

1

There are 1 best solutions below

4
On

If $u$ is the indicator function of the interval $[0,\alpha]$, you want to compute $$\int_0^{2\pi} u(x) f(x) \; dx = 2 \pi \sum_{n=-\infty} \overline{\hat{u}_n} \hat{f}_n$$ where $\hat{u}_n$ and $\hat{f}_n$ are the Fourier coefficients of $u$ and $f$.