nature of the series $\sum (-1)^{n}n^{-\tan\left(\tfrac{\pi}{4}+\tfrac{1}{n} \right)}$ I would like to study the nature of the following serie:
$$\sum_{n\geq 0}\ (-1)^{n}n^{-\tan\left(\dfrac{\pi}{4}+\dfrac{1}{n} \right)} $$
we can use simply this question :
Show : $(-1)^{n}n^{-\tan\left(\tfrac{\pi}{4}+\tfrac{1}{n} \right)}=\tfrac{(-1)^{n}}{n}+\mathcal{O}\left(\tfrac{\ln(n)}{n^{2}} \right)$
$$\sum_{n\geq 1} (-1)^{n}n^{-\tan\left(\dfrac{\pi}{4}+\dfrac{1}{n} \right)}=\sum_{n\geq 1}\dfrac{(-1)^{n}}{n}+\sum_{n\geq 1} \mathcal{O}\left(\dfrac{\ln(n)}{n^{2}} \right) $$
Since :


*

*Alternating harmonic series $\sum_{n\geq 1}\dfrac{(-1)^{n}}{n}$ is convergent 

*$\sum_{n\geq 1} \mathcal{O}\left(\dfrac{\ln(n)}{n^{2}} \right) $ is convergent since $\left|  \mathcal{O}\left(\dfrac{\ln(n)}{n^{2}} \right)\right|\leq \dfrac{\ln(n)}{n^{2}}$


thus $\sum_{n\geq 0}\ (-1)^{n}n^{-\tan\left(\dfrac{\pi}{4}+\dfrac{1}{n} \right)} $ is convergent 
My question :


*

*Why we can't take expansion up to  $2$ $\frac{1}{1-z}=1+z+O(z^2)$ instead of $\frac{1}{1-z}=1+z+z^2+O(z^3)$


\begin{align}
 \tan\left(\frac{\pi}{4}+\frac1n\right)&=\left(1+\tan(1/n)\right)\left(1-\tan(1/n)\right)^{-1}\\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right) \\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)+\mathcal{O}\left(\left(\frac{-1}{n}+\mathcal{O}\left(\frac{1}{n^3}\right)\right)^{2} \right) \right) \\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{2}}\right) \right) \\
&=1-\frac{1}{n^2}+\mathcal{O}\left( \frac{1}{n^{2}}\right)
 \end{align}
then :
\begin{align}
e^{-\tan\left(\frac{\pi}{4}+\frac1n\right)\log(n)}&=e^{\left(-1-\frac{1}{n^2}+\mathcal{O}\left( \frac{1}{n^{2}}\right)\right)\log(n)}\\\\
&=\frac1n\,e^{\left(-\frac{\log(n)}n^{2}+O\left(\frac{\log(n)}{n^2}\right)\right)}\\\\
&=\frac1n\,\left(1-\frac{\log(n)}{n^{2}}+O\left(\frac{\log(n)}{n^2}\right)+O\left(\frac{\log^{2}(n)}{n^4}\right) \right)\\\\
&=\frac1n +O\left(\frac{\log(n)}{n^3}\right)
\end{align}
$$(-1)^{n}e^{-\tan\left(\frac{\pi}{4}+\frac1n\right)\log(n)}=(-1)^{n}\frac1n +O\left(\frac{(-1)^{n}\log(n)}{n^3}\right) $$
and since  $\sum O\left(\frac{\log(n)}{n^3}\right)$ and $(-1)^{n}\frac1n$ are convergent
i prove that the series is conevrgent only by using expansion up to 2 why we can't take it
 A: You made a mistake in
\begin{align}
 \tan\left(\frac{\pi}{4}+\frac1n\right)&=\left(1+\tan(1/n)\right)\left(1-\tan(1/n)\right)^{-1}\\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right) \\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)+\mathcal{O}\left(\left(\frac{-1}{n}+\mathcal{O}\left(\frac{1}{n^3}\right)\right)^{2} \right) \right) \\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{2}}\right) \right) \\
&=1-\frac{1}{n^2}+\mathcal{O}\left( \frac{1}{n^{2}}\right)
 \end{align}
It should be
\begin{align}
 \tan\left(\frac{\pi}{4}+\frac1n\right)&=\left(1+\tan(1/n)\right)\left(1-\tan(1/n)\right)^{-1}\\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1-\left(\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\right)^{-1} \\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1+\left(\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)+\mathcal{O}\left(\left(\frac{1}{n}+\mathcal{O}\left(\frac{1}{n^3}\right)\right)^{2} \right) \right) \\
&= \left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{3}}\right)\right)\left(1+\frac{1}{n}+\mathcal{O}\left( \frac{1}{n^{2}}\right) \right) \\
&=1+\frac{2}{n}+\mathcal{O}\left( \frac{1}{n^{2}}\right)
 \end{align}
That is, you effectively wrote
\begin{align}
{1+x\over1-x}&=(1+x)(1-x)^{-1}\\
&=(1+x)(1-x+x^2+\cdots)
\end{align}
instead of
\begin{align}
{1+x\over1-x}&=(1+x)(1-x)^{-1}\\
&=(1+x)(1+x+x^2+\cdots)
\end{align}
(It looks like you also omitted the exponent $-1$ when changing from $(1-\tan(1/n))$ to its Taylor expansion, but I think that was just a typo.)
A: Without digging into asymptotics, the original series is simply convergent by Dirichlet's test, since $\{(-1)^n\}$ has bounded partial sums and
$$ n^{-\tan\left(\frac{\pi}{4}+\frac{1}{n}\right)} = \frac{1}{n^{\frac{1+\tan(1/n)}{1-\tan(1/n)}}}$$
is decreasing towards zero for any $n\geq 3$.
