# Simplifying ArcTan[Cos[u], Sin[u]]

I am trying to evaluate the following expression in Mathematica:

$$\bigg| \frac{\left(1-z^{-2}\right)^n}{\left(1-z^{-1}\right) \left(2-z^{-n}-z^{-1}\right)} \bigg|^2$$

Here $z$ is the complex exponential (of the $Z$ transform) and is given by: $z=e^{-2i\pi f/f_s}$, where $f_s$ is a constant.

In order to evaluate this, I wrote the following code in Mathematica:

z := Exp[(2*Pi*I*f/fs)];
h := Abs[(1 - z^-2)^n/((1 - z^-1) (2 - (z^-1) - z^(-n)))];
Simplify[h^2, Element[f, Reals]] // ComplexExpand // TrigReduce


Mathematica evaluates the expression, however doesn't completely simplify it. I get terms of the following kind in the denominator:

ArcTan[Cos[(2*f*Pi)/fs], Sin[(2*f*Pi)/fs]]

The ArcTan function can obviously be simplified to just 2*f*Pi)/fs.

Is there any way to get Mathematica to do this on its own?

I have posted an image of the code and result I get in the figure.

• N is a reserved word. Use lowercase for your symbol names – Dr. belisarius Mar 8 '16 at 6:04
• Thanks fro your quick reply. I tried replacing N by small case, however I am still getting the same results. – Saqib Shah Mar 8 '16 at 6:32
• Try {ArcTan[Cos[(2*f*Pi)/fs], Sin[(2*f*Pi)/fs]], (2*f*Pi)/fs} /. {f -> 2, fs -> 1}. You'll see they aren't equal. – Michael E2 May 17 '16 at 11:19

First, use $n$ and $h$ (not $N$ and $H$) in your code. (Please change your problem accordingly). Second, be sure to use semicolons at the end of each line. Third, make the ArcTan simplification explicitly:

z := Exp[(2 π I f/fs)];
h := Abs[(1 - z^(-2))^n/((1 - z^(-1)) (2 - (z^(-1)) - z^(-n)))];
Simplify[ComplexExpand[h^2], Element[f, Reals]] //.
ArcTan[Cos[aa__], Sin[aa__]] -> aa


$\frac{2^{2 n-3} \csc ^2\left(\frac{\pi f}{\text{fs}}\right) \sin ^2\left(\frac{2 \pi f}{\text{fs}}\right)^n}{-2 \cos \left(\frac{2 \pi f n}{\text{fs}}\right)+\cos \left(\frac{2 \pi f}{\text{fs}}-\frac{2 \pi f n}{\text{fs}}\right)-2 \cos \left(\frac{2 \pi f}{\text{fs}}\right)+3}$

ArcTan[Cos[aa_], Sin[aa_]] -> aa


which means everywhere there is a term of this form (where I arbitrarily chose the variable name aa to refer to any set of variables), replace the ArcTan[...] with aa.

• Thanks David for your comment, the last line of your code uses a "->" symbol, I assume this forces Mathematica to convert every expression on the left to the one on the right? (Sorry about the basic question, but I have never used Mathematica before.). One more thing. Why do the Cos and Sin have the arguments "aa__"? – Saqib Shah Mar 8 '16 at 10:04
• @SaqibShah. Look up Rule and ReplaceRepeated in the documentation. – m_goldberg Mar 8 '16 at 12:16

It is important to keep in mind that ArcTan[Tan[x]] is not always equal to x. When x is between -Pi/2 and Pi/2, it is valid. So we have

In[24]:= ArcTan[Tan[x]]

Out[24]= ArcTan[Tan[x]]

And

In[25]:= FullSimplify[ArcTan[Tan[x]], -Pi/2 < x < Pi/2]

Out[25]= x

Similarly, it follows that

In[26]:= FullSimplify[ArcTan[Cos[x], Sin[x]], -Pi/2 < x < Pi/2]

Out[26]= x

Therefore, in the present question's context we have:

In[27]:= FullSimplify[ ArcTan[Cos[(2*f*Pi)/fs], Sin[(2*f*Pi)/fs]], -fs < 4 f < fs]

Out[27]= (2 f [Pi])/fs