Getting incorrect answers when computing $\int_{0}^a \frac{\cos(\pi n x/a)}{x^2+a^2}\ \! \mathrm dx$?

222 Views Asked by At

Please do not try to close this question. This question doesn't have the answer I want.

I found this integral in a book (I forgot the name).

$$\int_{0}^a \dfrac{\cos(\pi n x/a)}{x^2+a^2}\ \! \mathrm dx $$

Where $a>0$ and $n\in \mathbb{Z^+}$.

I tried differentiating under the integral sign w.r.t. $n$ and preparing a differential equation, but here is the problem.

Let's prepare differential equation from the raw form. $$I(n)=\int_0^a \dfrac{\cos(\pi n x /a)}{x^2+a^2}\ \! \mathrm dx $$ Differentiating both sides twice w.r.t. $n$, $$\begin{align} \dfrac{\mathrm d^2}{\mathrm d n^2}I(n)&=-\dfrac{\pi^2}{a^2}\int_0^a \dfrac{x^2\cos(\pi n x/a)}{x^2+a^2}\ \! \mathrm dx \\ &= -\dfrac{\pi^2}{a^2}\int_0^a \cos(\pi n x /a) \ \! \mathrm dx +\pi^2 \int_0^a \dfrac{\cos(\pi n x /a)}{x^2+a^2}\ \! \mathrm dx \\ &= -\dfrac{\pi}{an}\sin(\pi n )+\pi^2I(n)\end{align}$$ As we know, $\sin(n\pi)=0 \ , n\in \mathbb{Z}$, so we end up with

$$\dfrac{\mathrm d^2}{\mathrm d n^2}I(n)=\pi^2I(n)$$

Now, let's start with the substitution $x=at$. $$I(n)=\dfrac{1}{a}\int_0^1 \dfrac{\cos(\pi n t)}{t^2+1}\ \! \mathrm dt$$ Again differentiating twice w.r.t. $n$, $$\begin{align} \dfrac{\mathrm d^2}{\mathrm d n^2}I(n) &=-\dfrac{\pi^2}{a}\int_0^1 \dfrac{t^2\cos(\pi n t)}{t^2+1}\ \! \mathrm dt \\ &=-\dfrac{\pi^2}{a}\int_0^1 \cos(\pi n t)\ \! \mathrm dt+\dfrac{\pi^2}{a}\int_0^1 \dfrac{\cos(\pi n t)}{t^2+1}\ \! \mathrm dt \\ &= -\dfrac{\pi}{an}\sin(\pi n)+\pi^2I(n) \\ \dfrac{\mathrm d^2}{\mathrm d n^2}I(n)&=\pi^2I(n)\end{align}$$

In both the cases, the results are the same. But they don't work for different values of $a$ and $n$. How can I do this integral using the method I displayed?

As the comments have suggested we have to reconsider the domain of $n$, and solve the integral for $n \in \mathbb{R}$. In that case, the differential equation will be $$\dfrac{\mathrm d^2}{\mathrm dn^2}I(n)=\pi^2I(n)-\dfrac{\pi}{an}\sin(\pi n)$$ We have to solve this differential equation.