<s>[INST] Regular Octagon Area Doing some maths homework I came across the area of a regular octagon on Google. This was given by:
$$ A=2(1+\sqrt{2})a^2 $$
I thought this looked rather ugly and slightly complicated and so began to look at regular octagons myself (Yes, I'm a nerd :)!). I managed to re-write the equation to
$$ A=\frac{x^2} {\sqrt{2}\cdot\sin^2(22.5)} $$
I could not find this equation anywhere on the internet so I don't know if it's correct. Has it been discovered before? Is it correct?
Thank you,
       Sam.

P.S. I could post the proof if you need it?
 [/INST] This result is known. More generally, a regular $n$-gon with side-length $x$ has area $\frac{n}{4}x^2\cot(\frac{\pi}{n})$.
To see this: by translating and rotating we can assume that the vertices of the regular $n$-gon are at  $(r\cos k\theta, r\sin k\theta)$ for $0 \le k < n$, where $\theta = \frac{2\pi}{n}$ and $r$ is the distance from the centre of the $n$-gon to its vertices.
Thus the area is $n$ times the area of the triangle with vertices $(0,0)$, $(r,0)$ and $(r\cos \theta, r\sin \theta)$. Thus
$$A = \frac{n}{2}r^2\sin \frac{2\pi}{n}$$
Now the side length is given by
$$x = \lVert (r\cos \theta, r\sin\theta) - (r,0) \rVert = \sqrt{(r\cos \theta-1)^2+\sin^2\theta} = r\sqrt{2-2\cos \theta}$$
So substituting for $r$ in the formula above gives
$$A = \frac{n}{4(1-\cos \frac{2\pi}{n})}x^2\sin \frac{2\pi}{n}$$
Finally we use $\cos 2\theta \equiv 1-2\sin^2 \theta$ and $\sin 2\theta = 2\sin \theta \cos \theta$ to get
$$A = \frac{n}{8\sin^2\frac{\pi}{n}}x^2 \cdot 2 \sin \frac{\pi}{n} \cos \frac{\pi}{n} = \frac{n}{4}x^2\cot\frac{\pi}{n}$$
Your expression is equivalent in the case when $n=8$.
</s>