Gauss's Digamma Theorem

Theorem
Let $\dfrac p q$ be a positive rational number with $p < q$.

Then:


 * $\ds \map \psi {\dfrac p q} = -\gamma - \ln 2 q - \dfrac \pi 2 \map \cot {\dfrac p q \pi} + 2 \sum_{n \mathop = 1}^{\ceiling {q / 2} - 1} \map \cos {\dfrac {2 \pi p n} q} \map \ln {\map \sin {\dfrac {\pi n} q} }$

where:
 * $\psi$ is the digamma function
 * $\cot$ is the cotangent function
 * $\ln$ is the natural logarithm.