2025-08-06
Integral of an exponential with an imaginary exponent and a cosine modulus
Earlier we analyzed the integral with the modulus of the cosine and the sine to an integer power.
In this note, we will study the integral of the form \(\int |\cos(x)|\, e^{inx}\, \Bbb{d}x\), where the cosine is taken by absolute value, \(i\) is the imaginary unit, and \(n\) are positive integers.
Without the modulus of the cosine, it can be taken analytically without problems, but the modulus leads us to very unusual results and exceptions.
As a result of our analysis, we will obtain a slightly more complex, but still analytical solution to this integral.
Such an integral is taken by expansion in a Fourier series, a rather complicated approximation, which is often not very convenient:
\[ I = \int |\cos(x)|\, e^{inx}\, \Bbb{d}x = \int \left( \sum \limits_{m=0}^{\infty} A_m \cos(2mx) \right) e^{inx}\, \Bbb{d}x \tag{1}\]
As we can see, here we need to look for the coefficients of the Fourier series \(A_m\), then sum and integrate a large number of terms.
We give this method here as an example and will not return to it further.
We will go the other way and simplify the solution of such an integral for the interval \(0..T\) using the following method:
first we will take the integral without the modulus, and then we will divide the specified interval into parts, and in each of them we will find our solution.
That's what we will do.
Let's first take the integral without the absolute value, using standard integration methods
\[ \int \limits_{T_0}^T \cos(x)\, e^{inx}\, \Bbb{d}x = {1 \over 2 i} \left( {e^{i(n+1)T} \over n+1} + {e^{i(n-1)T} \over n-1} \right) \bigg|_{T_0}^T \tag{2}\]
and then we'll split this interval into parts, and we'll look for a solution in each of them.
Only first we'll denote several functions for a simpler notation of the general solution.
The first such function is made from (2):
\[ I(T,T_0) = {1 \over 2 i} \left( {e^{i(n+1)T} - e^{i(n+1) T_0} \over n+1} + {e^{i(n-1)T} - e^{i(n-1) T_0} \over n-1} \right) \tag{3}\]
Also recall that for \(n=1\) in this expression we need to find the limit, after which it will become:
\[ I(T,T_0) = {1 \over 2 i} \left( {e^{i 2 T} - e^{i 2 T_0} \over 2} + i(T - T_0) \right), \quad n=1 \tag{4}\]
Here: \(T_0\) is the lower boundary of integration.
Let's introduce a few more functions.
\[ R = Re \left[ I \left( {\pi \over 2},0 \right) \right] \tag{5}\]
where: \(Re\) is the real part of the expression.
Let's also introduce
\[ N = \mbox{floor} \left( {T \over 2\pi} \right) \tag{6}\]
where: \(\mbox{floor}\) is the smallest integer from the division, i.e. how many full periods are contained in \(T\).
The last function we need is:
\[ T_{mod} = \mbox{mod} (T, 2\pi) = T - 2\pi N \tag{7}\]
It returns the remainder of the division. For example, \(\mbox{mod} (3,2)\) returns 1, because 2 appears in 3 once, and the remainder is 1.
In the case of formula (7), it turns out that it shows the remainder after subtracting all the full \(2\pi\) periods from \(T\).
Then the desired integral will be found as follows:
\[I(T,0) = 4 N R +
\left\{\begin{matrix}
I(T,0) & \mbox{if} & T_{mod} \leqslant \pi/2 \mbox{ and } n \ne 1 \\
I(T,0) - 8 N R & \mbox{if} & T_{mod} \leqslant \pi/2 \mbox{ and } n = 1 \\
I(\pi/2,0) - I(T,\pi/2) & \mbox{if} & \pi/2 \lt T_{mod} \leqslant 3\pi/2 \\
I(3\pi/2,0) + I(T,3\pi/2) & \mbox{if} & T_{mod} \gt 3\pi/2 \mbox{ and } n \ne 1 \\
I(3\pi/2,0) + I(T,3\pi/2) - 8 N R & \mbox{if} & T_{mod} \gt 3\pi/2 \mbox{ and } n = 1
\end{matrix}\right. \tag{8}\]
Although the integral turned out to be rather cumbersome, it is still much simpler than in solution (1).
The right side of expression (8), after the bracket, is repeated periodically in each period, and the left side increases with each period.
It should also be noted that with each new period only the real part of the integral increases, the imaginary part remains periodic.
Full period
The integral may be of interest not over indefinite boundaries, but only its values after a certain number of periods.
This solution is simpler and is found as follows:
\[ I(N) = 2N \left( {\sin((n+1) \pi / 2) \over n+1} + {\sin((n-1) \pi / 2) \over n-1} \right), \quad N=0,1,2,3,\ldots \tag{9}\]
Here \(N\) is the number of full periods.
In this case, the upper boundary of integration will be as follows: \(T= 2\pi N\).
Formula (9) can be simplified taking into account even and odd degrees \(n\):
\[I(N) = \left\{\begin{matrix}
{\large {4 N \over 1 - n^2} (-1)^{n/2}} & \mbox{if} & n = 0,2,4,6,\ldots \\
0 & \mbox{if} & n = 1,3,5,7,\ldots \\
\end{matrix}\right. \tag{10}\]
Now we will be interested to know the sum of such integrals over all \(n\), from zero to infinity:
\[ 4 N \sum \limits_{n=0}^{\infty} {(-1)^{n} \over 1 - 4 n^2} = N(2 + \pi) \tag{11}\]
From here we find the final solution:
\[ \sum \limits_{n=0}^{\infty} I(N) = N(2 + \pi) \tag{12}\]
The following result may also be of interest:
\[ \sum \limits_{n=0}^{\infty} I(N)^2 = N(2 + \pi^2 / 4) \tag{13}\]
We will need such a sum of integrals over the total number of periods to solve some practical problems in the hypothesis of a single space.

