The "sum-of-divisors" function, defined as $\sigma(n)=\sum_{d\,\mid\,n}d$, can be expressed as $$\sigma(n)=\sum_{i=1}^n\sum_{j=1}^i\cos\Big(2\pi n \frac{j}{i}\Big)$$This expansion makes logical sense. However, while looking through the wolfram page regarding the divisor function, I found the following expansion (equation 26):
$$ \begin{align} \sigma(n) = \frac{1}{6}n\pi^2\left[\left(1+\frac{(-1)^n}{2^2}\right) + \frac{2\cos\left(\frac{2}{3}n\pi\right)}{3^2} \right. \\[8pt] {} + \frac{2\cos\left(\frac{1}{2} n\pi\right)}{4^2} & \left. {} + \frac{2\left[\cos\left(\frac{2}{5}n\pi\right) + \cos\left(\frac{4}{5}n\pi\right)\right]}{5^2} + \cdots\right] \end{align} $$
Is there an obvious link I am missing between the first and second expression? If not, how is this second expression derived?