# Calculating energy spectral density function of half-cosine function

I have the following function:

$$g(t) = A\cdot \textrm{rect}\left(\frac{t}{T}\right)\cos\left(\frac{\pi t}{T}\right)$$

How do I find the energy spectral density function? I think? it is defined as :

$$\int\limits_{-\infty}^\infty \left|g(t)\right|^2\, dt$$

After squaring it, I'm a bit lost since I do not know how to continue...

• Are you sure you are giving the definition of the "spectral density"? It seems to be the energy only. You can look a little below on the wiki page en.wikipedia.org/wiki/Spectral_density#Energy_spectral_density "spectral" here is a hint of a frequency domain calculation – Laurent Duval Mar 18 '16 at 6:45
• I agree with @LaurentDuval, you need to work on the frequency domain to get the energy spectral density. Have a look to these definitions and then, you may be able to calculate $G(f)$ convolving the fft of the rect and the fft of the cosine which is 2 deltas. Check the fft tables in here. – Behind The Sciences Mar 18 '16 at 6:56

For a "deterministic finite energy" continuous time signal $x\left(t\right)$, as you have exemplified, the energy density spectrum, or equivalently energy spectral density, which is a real nonnegative signal, meant to be used as a function showing the energy distribution of the signal with respect to the frequency is defined to be: $$S_x\left(\omega\right) = \left|X\left(j\omega\right)\right|^2$$ where $X\left(j\omega\right)$ is the Continuous-Time Fourier Transform $\left(CTFT\right)$ of the signal $x\left(t\right)$ given as: $$X\left(j\omega\right) = \int_{-\infty}^{\infty}{x\left(t\right)e^{-j\omega t} dt}$$

Now coming to the specific sample of your question, you should first find the CTFT $G\left(j\omega\right)$ of $g\left(t\right)$: That your signal is a multiplication of two other signals you should use a fundamental property of CTFT namely the ${multiplication}$ in time equals ${convolution}$ in frequency. Hence

$$x\left(t\right)y\left(t\right) \leftrightarrow \frac{1}{2\pi} X\left(j\omega\right) \star Y\left(j\omega\right)$$

From a table of FTs (or by carrying out the integral if you can) find that for $x\left(t\right)= \textrm {rect} \left( \frac {t}{T} \right)$ which is defined from $t=-T/2$ to $t=T/2$, we have: $$X\left(j\omega\right) = \frac{2 \sin \left({\omega \frac{T}{2} }\right)} {\omega}$$ and for the $y\left(t\right) = \cos\left( \pi \frac {t}{T}\right)$ we have $$Y\left(j\omega\right) = \pi \delta \left(\omega - \frac {\pi}{T}\right) + \pi \delta \left(\omega + \frac{\pi}{T}\right)$$

What remains now is to compute their convolution, which is easy considering the convolution with impulse given as:$X\left(j\omega\right) \star \delta\left(\omega - \omega_0\right) = X\left(j\left(\omega - \omega_0\right)\right)$

Hence we get: $$G\left(j\omega\right) = \frac{1}{2\pi} X\left(j\omega\right) \star Y\left(j\omega\right)$$

as $$\frac{\sin \left({\left(\omega- \frac {\pi}{T}\right) \frac{T}{2} }\right)} {\left(\omega- \frac {\pi}{T}\right)} + \frac{\sin \left({\left(\omega + \frac {\pi}{T}\right) \frac{T}{2} }\right)} {\left(\omega + \frac {\pi}{T}\right)}$$

which, after simplyfying, becomes: $$G\left(j\omega\right) = \cos\left({\omega\frac{T}{2} }\right) \left( \frac{-1} {\left(\omega- \frac {\pi}{T}\right)} + \frac{1} {\left(\omega + \frac {\pi}{T}\right)} \right)$$

whose magnitude is $$\left|G\left(j\omega\right)\right| = \left|\cos\left(\omega \frac{T}{2}\right)\right| \cdot \left|\left( \frac{ \frac{-2\pi}{T}}{\omega^2 - \frac{\pi^2}{T^2}} \right)\right|$$

And from which we conclude for the Energy Spectrum Density to be: $$S_x\left(\omega\right) = \left|G\left(j\omega\right)\right|^2 = A^2 \cos^2\left(\omega \frac{T}{2}\right) \left( \frac{ \frac{2\pi}{T}}{\omega^2 - \frac{\pi^2}{T^2}} \right)^2$$

where I have added the last linear scaler A in $g\left(t\right)$.

• This is a good example of a bad answer. It presumably gets the right answer (I haven't checked the details) but works only because one function is a sinusoid which makes the frequency domain convolution easy to carry out. More generally, we would need to convolve a sinc with some Fourier transform. Why not just calculate \begin{align}G(\omega)&=\int_{-\infty}^infty g(t)e^{-j\omega t}\,dt\\&=\int_{-T/2}^{T/2}A\cos\left(\frac{\pi t}{T}\right)e^{-j\omega t}\,dt\\&=\frac A2\int_{-T/2}^{T/2}(e^{j\pi t/T}+e^{-j\pi t/T})e^{-j\omega t}\,dt\end{align} directly? Those exponentials are easy to integrate! – Dilip Sarwate Mar 19 '16 at 14:11
• No it is not! it is a preferred method when one of the functions is a sinusoidal, whose impulse based spectral convolution lets one to see graphically what is happening to the spectra of the keyed pulse. This is useful in conceptual understanding better than a direct integral evaluation. Especially for non-rectengular complex pulses. Direct integration would not only be tedious but also be useless in giving a meaning to what happens. Therefore yours is a good example of bad comment :) – Fat32 Mar 19 '16 at 15:49
• I disagree. When one of the functions is a sinusoid, the preferred method is the modulation theorem: $$\mathcal F(h(t)\cos(\omega_0t)) = \frac{H(\omega-\omega_0)+H(\omega+\omega_0)}{2}$$ which clearly shows what is happening to the spectrum and gives the result more easily than your contorted calculations. – Dilip Sarwate Mar 19 '16 at 16:11
• You are either joking or don't know what you are talking about! The "modulation theorem" is a direct consequence of frequency domain convolution with a pair of impulses which comes from the cosine term of a multiplier and that is EXACTLY what I used in my answer. Now please prevent any further discussion of this obvious fact. Put down your answer instead. – Fat32 Mar 19 '16 at 17:04
• I am not joking, and I do know what I am talking about. In an earlier comment, I had said "... presumably gets the right answer (I haven't checked the details)". I did check the details and now withdraw my presumption. Your assertion "From a table of FTs (or by carrying out the integral if you can) find that for $x\left(t\right)= \textrm {rect} \left( \frac {t}{T} \right)$ we have $$X\left(j\omega\right) = e^{-j\omega \frac{T}{2}} \frac{2 \sin \left({\omega \frac{T}{2} }\right)} {\omega}$$ is false: the Fourier transform of the rect function is a (real-valued) since function. – Dilip Sarwate Mar 21 '16 at 16:32