求解无穷积分$ \int_{-\infty}^\infty\frac{\cos x}{1+x^2}\;dx\ $时的方法错误排查求助
Hey there! Let's walk through where your two approaches went off track—you're so close to the right answer, just a couple of key missteps in how you're applying complex analysis tools here.
问题1:直接用$\cos z$做围道积分的误区
Your contour setup ($\gamma = \gamma_1 + \gamma_2$ with $\gamma_2$ as the upper semicircle) is totally correct, but here's the critical mistake: we can't use $\cos z$ directly for this contour integral.
Remember that $\cos z = \frac{e^{iz} + e^{-iz}}{2}$. When $z$ is in the upper half-plane ($\text{Im}(z) = y > 0$), $e^{-iz} = e^{-i(x+iy)} = e{y}e{-ix}$—this term grows exponentially as $y \to \infty$, which means the integral over $\gamma_2$ won't vanish like you assumed!
The fix is to work with $e^{ix}$ instead, since $\cos x$ is the real part of $e^{ix}$. For $e^{iz}$ in the upper half-plane, $e^{iz} = e{-y}e{ix}$, which decays exponentially as $y \to \infty$, so the integral over $\gamma_2$ does go to 0 as $R \to \infty$.
Now apply the residue theorem to $f(z) = \frac{e{iz}}{1+z2}$:
- The only singularity in the upper half-plane is $z = i$.
- The residue at $z=i$ is $\frac{e^{i \cdot i}}{2i} = \frac{e^{-1}}{2i}$.
- The contour integral equals $2\pi i \times \text{Res}(f,i) = 2\pi i \times \frac{e^{-1}}{2i} = \frac{\pi}{e}$.
Since our original integral is the real part of this result, we get $\int_{-\infty}^\infty\frac{\cos x}{1+x^2}dx = \frac{\pi}{e}$—the correct answer. Your mistake was using $\cos z$ instead of $e^{iz}$, which introduced the problematic $\cos i$ term.
问题2:部分分式分解后的积分误用
Your partial fraction decomposition $\frac{1}{1+z^2} = \frac{i}{2(z+i)} - \frac{i}{2(z-i)}$ is right, but again, the issue is using $\cos z$ in the split integrals.
When you split $\int_{-\infty}^\infty\frac{\cos z}{1+z^2}dx$ into two parts, you can't apply Cauchy's theorem directly to say the first integral is zero—because $\cos z$ isn't bounded in the upper half-plane (thanks to that growing $e^{-iz}$ term).
Instead, split the integral of $e^{ix}$ instead:
$$\int_{-\infty}\infty\frac{e{ix}}{1+x^2}dx = \frac{i}{2}\int_{-\infty}\infty\frac{e{ix}}{z+i}dx - \frac{i}{2}\int_{-\infty}\infty\frac{e{ix}}{z-i}dx$$
- For the first integral: the singularity $z=-i$ is in the lower half-plane, so if we close the contour in the upper half-plane (where $e^{iz}$ decays), there are no singularities inside the contour. By Cauchy's theorem, this integral is 0.
- For the second integral: the singularity $z=i$ is in the upper half-plane. Using Cauchy's integral formula, $\int_{-\infty}\infty\frac{e{ix}}{z-i}dx = 2\pi i e^{i \cdot i} = 2\pi i e^{-1}$.
Plugging these back in:
$$\frac{i}{2} \times 0 - \frac{i}{2} \times 2\pi i e^{-1} = -i^2\pi e^{-1} = \frac{\pi}{e}$$
Take the real part, and you get the correct result for your original $\cos x$ integral.
总结
The core issue in both approaches is that $\cos z$ doesn't decay in the upper half-plane—you need to use $e^{ix}$ (which does decay there) and then take its real part to get the integral of $\cos x$. That's why your calculations were giving you results with $\cos i$ instead of the clean $\pi/e$.
备注:内容来源于stack exchange,提问作者FNB

