The following formula used in numerical integration but I do not understand where it comes from. Can somebody give me any hint? $$\int_{-\pi}^{\pi}f(x)\sin x dx=(1-\frac{8}{\pi^2})[f(\pi)-f(-\pi)]+\frac{16}{\pi^2}[f(\frac{\pi}{2})-f(\frac{-\pi}{2})]$$
2026-05-04 10:00:29.1777888829
I do not know where the formula comes from?
45 Views Asked by user361960 https://math.techqa.club/user/user361960/detail At
1
It is basically Gaussian quadrature: we introduce the ansatz $$ \int_{[-\pi,\pi]}f(x)\sin(x)\approx \sum_{i=1}^n w_if(x_i) $$ for some conveniently chosen nodes $\{x_i\}$. The weights $\{w_i\}$ are determined by insisting that this approximation is exact for some conveniently chosen functions (e.g., the first $n$ monomials $\{x^i\}_{i\in[0,n-1]}$). Taking $\{x_i\}=\{-\pi,-\pi/2,\pi/2,\pi\}$, and requiring this ansatz to be exact for $f=1,x,x^2,x^3$ leads to the expression in the OP.
--
Equivalently, construct the polynomial that interpolates $\{(x_i,f(x_i))\}$ at the nodes $\{x_i\}=\{-\pi,-\pi/2,\pi/2,\pi\}$: $$ P_f(x)=\frac{4 \left(-2 f\left(\frac{\pi }{2}\right)+2 f\left(-\frac{\pi }{2}\right)-f(-\pi )+f(\pi )\right) x^3+4 \pi \left(-f\left(\frac{\pi }{2}\right)-f\left(-\frac{\pi }{2}\right)+f(-\pi )+f(\pi )\right) x^2+\pi ^2 \left(8 f\left(\frac{\pi }{2}\right)-8 f\left(-\frac{\pi }{2}\right)+f(-\pi )-f(\pi )\right) x-\pi ^3 \left(-4 f\left(\frac{\pi }{2}\right)-4 f\left(-\frac{\pi }{2}\right)+f(-\pi )+f(\pi )\right)}{6 \pi ^3} $$ and integrate explicitly.