I'm trying to find the residue of $$z \cos\left(\frac{1}{z}\right)$$ at $z=0$. 

This is how I did it: 

$\cos(z)=\sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n}$. 
$\\$
Then $\cos(\frac{1}{z})=\sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n-1}$. $\\$
Finally, $z\cos(z)=\sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n}$, which is where I started. I thought the residue would by $0$ because there are no negative powers, but  it's supposed to be $-\frac{1}{2}$. Did I do something incorrectly?


Question: Making Simple IF Statements Shorter
Answer: 
  Is it bad practice to change a simple statement like this to the following?:


bool test2 = (str == "checked");


No, it's good practice. To me, the longer code:

if (str == "checked")
{  
    test1 = true;
}
else
{
    test1 = false;
} 


indicates that the programmer doesn't understand Boolean expressions.  The shorter form is much clearer.  Similarly, don't write:

if (boolean-expression) {
    return true;
} else {
    return false;
}


Just write return boolean-expression;