# Compute integral of periodic function numerical spectrally

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.

• What is "spectral accuracy" supposed to mean? Ghostly accuracy, maybe? If it's a sufficiently smooth periodic function, why don't you just compute its Fourier series, and integrate that, term by term? – Professor Vector Jun 19 at 19:49
• Yeah, I think they are the same, spectral mean something like exponential convergence in the number of points – Almost nice Jun 19 at 20:22

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$$.
• Should there be a convolution in Fourier space corresponding to the pointwise product in $x$-space? – whpowell96 Jun 19 at 19:54
• Ah I see where I was confused. Taking the conjugate of the coefficients of the indicator function is equivalent to the discrete convolution of the Fourier coefficients of $u$ and $f$ – whpowell96 Jun 19 at 19:58