Prove $4\sin^{2}\frac{\pi}{9}-2\sqrt{3}\sin\frac{\pi}{9}+1=\frac{1}{4}\sec^{2}\frac{\pi}{9}$. While attempting to algebraically solve a trigonometry problem in (Question 3535106), I came across the interesting equation

$$
4\sin^{2}\frac{\pi}{9}-2\sqrt{3}\sin\frac{\pi}{9}+1=\frac{1}{4}\sec^{2}\frac{\pi}{9}
$$

which arose from the deduction that $\frac{1}{4}\sqrt{\frac{256\sin^{4}40^{\circ}-80\sin^{2}40^{\circ}+12-\ 8\sqrt{3}\sin40^{\circ}}{\left(16\sin^{4}40^{\circ}-4\sin^{2}40^{\circ}+1\right)}}=\cos50^{\circ}$. Despite the apparent simplicity of the relationship, it seems quite tricky to prove. I managed to prove it by solving the equation as a quadratic in $(\sin\frac{\pi}{9})$ and then using the identity $\sqrt{\sec^2 x-1}=|\tan x|$, the double angle formulae and finally that $\frac{\sqrt{3}}{2}\cos x-\frac{1}{2}\sin x$ can be written in the form $\sin\left(x+\frac{2\pi}{3}\right)$.
But it seems like quite a neat problem. So, does anyone have a better way of proving it?

Evaluate
$$
\begin{aligned}
4\cos ^2\frac{π}{9}&\left( LHS-RHS \right) \\
= \ &16\sin ^2\frac{π}{9}\cos ^2\frac{π}{9}-8\sqrt{3}\sin \frac{π}{9}\cos ^2\frac{π}{9}+4\cos ^2\frac{π}{9}-1\\
=\ &4\sin ^2\frac{2π}{9}-4\sqrt{3}\sin \frac{2π}{9}\cos \frac{π}{9}+2\left( 1+\cos \frac{2π}{9} \right) -1 \\
= \ &2\left( 1-\cos \frac{4π}{9} \right) -2\sqrt{3}\left( \frac{\sqrt3}2+\sin \frac{π}{9} \right) +2\cos \frac{2π}{9}+1\\
= \ &2\cos \frac{2π}{9}-2\cos \frac{4π}{9}-2\sqrt{3}\sin \frac{π}{9}\\
= \ &4\sin \frac{π}{3}\sin \frac{π}{9}-2\sqrt{3}\sin \frac{π}{9}=0
\end{aligned}
$$
where $\sin\fracπ3 = \frac{\sqrt3}2$ is used.
