How can I put brackets under a certain equation like this?
This is not a duplicate of this because I've tried the solution and this is what I get:
This is my code:
\[\underbrace{\sqrt{2+\sqrt{2+\sqrt{2+...+\sqrt{2}}}}_\text{$n$ nested square roots}} = 2\cos({\frac{\pi}{2^{n+1}}})\]

