I was looking at one of those cool/nerdy clocks that has math expressions in place of numbers. For the number $3$, they had the expression $$79\tan\left(\frac{\pi}{8}-\frac{5}{2}\arctan\left(\frac{1}{7}\right)\right).$$ Then, for the number $5$, they had $$\frac{1}{\tan\left(\frac{\pi}{16}+\frac{1}{4}\arctan\frac{1}{239}\right)}.$$ Finally, for the number $9$, they had $$\left(\tan\left(\frac{\pi}{9}\right)\tan\left(\frac{2\pi}{9}\right)\tan\left(\frac{4\pi}{9}\right)\right)^{4}.$$ I'm curious as to how these were made. I noticed that the second is a rearrangement of the formula that Shanks used to calculate $\pi$ by hand $\frac{\pi}{4}=4\arctan\left(\frac{1}{5}\right)-\arctan\left(\frac{1}{239}\right)$, but I'm not sure where that formula comes from either.
I was wondering if anyone had some advice on how I could build my own expressions using these methods.