# spectrum and phase of function in frequency domain

This must be a very basic question but I am a finance student just learning some basics about Fourier Transformation to apply to time series analysis. I did a fourier transform on a function in time domain to get the following function in frequency domain:

$Y_1[\omega] = \frac{1}{1-\phi_1 e^{-jw}}$

$Y_2[\omega] = \frac{1}{1-(\phi_1 + \phi_2)e^{-jw} +\phi_1\phi_2e^{-2jw}}$

How do I find the spectrum of this function for given $\phi_1$ and $\phi_2$ coefficients and in the discretization interval $w = [-\pi:.1*\pi: \pi]$? Then, how do I find the 'magnitude' of spectrum and 'phase' of spectrum?

-

## migrated from physics.stackexchange.comFeb 13 '11 at 0:57

This question came from our site for active researchers, academics and students of physics.

Mind supplying some definitions? – Qiaochu Yuan Feb 13 '11 at 1:05
reference: en.wikipedia.org/wiki/Fourier_transform – user957 Feb 13 '11 at 1:39

Let \begin{align*} Z(\omega) & = 1-\phi e^{-jw} = 1-\phi (\cos(\omega) - j \sin(\omega))\\ & = 1-\phi \cos(\omega) + j \phi \sin(\omega)\\ \end{align*} Hence, we get that \begin{align*} |Z(\omega)| = & \sqrt{(1-\phi (\cos(\omega))^2 + (\phi \sin(\omega))^2} = \sqrt{1 + \phi^2 - 2 \phi \cos(\omega)}\\ \angle{Z(\omega)} = & \tan^{-1}(\frac{\phi \sin(\omega)}{1-\phi \cos(\omega)}) \end{align*}

$$Y(\omega) = \frac{1}{Z(\omega)}$$ Hence, we get that \begin{align*} |Y(\omega)| = & \frac{1}{\sqrt{1 + \phi^2 - 2 \phi \cos(\omega)}}\\ \angle{Y(\omega)} = & -\tan^{-1}(\frac{\phi \sin(\omega)}{1-\phi \cos(\omega)}) \end{align*}

Finding the magnitude and phase for $|Y_2(\omega)|$ is a trivial process once you have done the previous one.

$Y_2(\omega) = \frac{1}{1-\phi_1 e^{-jw}} \times \frac{1}{1-\phi_2 e^{-jw}}$.

Hence, \begin{align*} |Y_2(\omega)| = & \frac{1}{\sqrt{1 + \phi_1^2 - 2 \phi_1 \cos(\omega)}} \times \frac{1}{\sqrt{1 + \phi_2^2 - 2 \phi_2 \cos(\omega)}}\\ \angle{Y_2(\omega)} = & -\tan^{-1}(\frac{\phi_1 \sin(\omega)}{1-\phi_1\cos(\omega)}) -\tan^{-1}(\frac{\phi_2 \sin(\omega)}{1-\phi_2\cos(\omega)}) \end{align*}

-
Thanks. But I am using R and I don't think it has these functions. I am looking for mathematical formula for finding magnitude/phase so that I can write my functions. – user957 Feb 13 '11 at 1:12
Sweet. Do you happen to come across function in R that does this similar to matlab? – user957 Feb 13 '11 at 2:01
@user957: I am not too familiar with R. But writing up your own function should be easy once you know these formulas. – user17762 Feb 13 '11 at 2:03
@user957, Just write an R function that takes the coefficients for the numerator (as a vector) and the denominator (again, as a vector) and a vector of frequencies $\omega$ at which to evaluate. Then, evaluate the complex rational and take $\mathrm{abs}(\cdot)$ and $\mathrm{atan}(\cdot)$ to get the magnitude and phase, respectively. – cardinal Feb 13 '11 at 2:11
Got it guys. Once I have the fourier transform computed analytically, I can easily set up the complex vector and compute the amplitude and phase. R has support for complex numbers ugrad.stat.ubc.ca/R/library/base/html/complex.html and includes functions for finding amplitude and phase. Thanks all. – user957 Feb 13 '11 at 2:38