# Discrete time inverse fourier transform of cosine squared

$$X(\omega) = \cos^2(\omega)$$

I tried this problem, and I ended up getting $0$, which doesn't make any sense. I integrated:

$$x(n) = \frac{1}{2\pi}\int_{0}^{2\pi} \cos^2(\omega)e^{j{\pi}n} d\omega$$

Which can be changed to

$$x(n) = \frac{1}{2\pi}\int_{0}^{2\pi} \bigg(\frac{e^{j\omega}+e^{-j\omega}}{2}\bigg)^2e^{j\omega} d\omega$$

To $$x(n) = \frac{1}{2\pi}\int_{0}^{2\pi} \frac{e^{j\omega(n+2)} + e^{j\omega(n-2)} + 2e^{jn\omega}}{4} d\omega$$

Now, taking out the four, each anti-derivative term contains the original term. And since each original term is of the form $$e^{jk\omega}, k\in \mathbb{Z}$$ and we're integrating from $0$ to $2\pi$, which are identical frequencies, the result ends up being zero. What went wrong?

• (cos(x))^2=(1+cos(2x))/2 – Stanley Pawlukiewicz Dec 5 '17 at 2:46
• @StanleyPawlukiewicz all roads lead to Rome, right? – One Normal Night Dec 6 '17 at 1:11
• some roads are more scenic. some roads are straighter – Stanley Pawlukiewicz Dec 6 '17 at 14:13

The only thing that went wrong is your last statement:

They're only zero if $k\ne 0$.

Thus, you get three Dirac delta distributions.

Let's look at your last equation, and work with that:

\begin{align} x(n) &= \frac{1}{2\pi}\int\limits_{0}^{2\pi} \frac{e^{j\omega(n+2)} + e^{j\omega(n-2)} + 2e^{jn\omega}}{4}\,d\omega \tag1\label{orig}\\ &=\frac1{8\pi}\left(\int\limits_{0}^{2\pi}e^{j(n+2)\omega}\,d\omega + \int\limits_{0}^{2\pi}e^{j(n-2)\omega}\,d\omega + \int\limits_{0}^{2\pi}e^{jn\omega}\,d\omega \right)\tag2\label{linearint} \end{align}

From $\eqref{orig}$ to $\eqref{linearint}$ I just went ahead and used the fact that integration is a linear operation to decompose that single integral into a sum of three, very similar, integrals.

Now, let's look at the last one, as you (sadly, with a mistake), already did: $$i(n):=\int\limits_0^{2\pi}e^{jn\omega}\,d\omega = \begin{cases}\frac1{jn}e^{jn\omega}\Big|_{\omega=0}^{2\pi} \overset{e^x\text{ is }j2\pi\text{-periodic}}= 0& \text{for } n\omega \ne 0\\ \int\limits_0^{2\pi}e^{0}\,d\omega= \int\limits_0^{2\pi}1\,d\omega= 2\pi& \text{else.} \end{cases}$$

So, this integral yields zero for all values of $n$ but for $n=0$, in which case it yields a fixed, finite, non-zero value.

Your other two integrals are just the same, but shifted w.r.t. $n$ by $2$ to the left or the right.

For more info on the Dirac delta distribution (looks like a function, isn't quite exactly a function), I'd recommend your favourite textbook or wikipedia. It's a thing that, when integrated, has an integral of $1$, but in an arbitrarily narrow support around $0$, outside of which its value is $0$.

• Sorry, I don't understand. if, for example, I integrate the last term I get (e^(jnw)/(jn))/2 from 0 to 2π. Both 2π and 0 as omega will equate, thus canceling each other out. PS: what is a dirac? – One Normal Night Dec 5 '17 at 0:46
• I think Marcus is saying that your math is correct but, for n = 2, n = -2 and n = 0, what you said about the integral being zero is not true. In those cases, you get $\delta(0)$, $\delta(0)$ and $\delta(0)$. But hopefully Marcus can provide more details. Thanks Marcus. – mark leeds Dec 5 '17 at 8:20
• @markleeds If you think that an answer is useful and correct please indicate so by upvoting or selecting like I did (+1), rather than commenting. Of course you don't have to but that's how the site is designed... – Fat32 Dec 5 '17 at 10:10
• @OneNormalNight hope this edit helped! – Marcus Müller Dec 5 '17 at 11:37
• @Fat32. Done. I didn't even know that I could upvote. thanks. – mark leeds Dec 5 '17 at 19:44

What you haven't understood is the fact that

$$\frac{1}{2\pi}\int_0^{2\pi}e^{j\omega k}d\omega=\delta[k]\tag{1}$$

where $\delta[k]=1$ for $k=0$ and zero otherwise. Note that in $(1)$ with $k=0$ you get

$$\frac{1}{2\pi}\int_0^{2\pi}1\cdot d\omega=1$$