I am given a curve C with polar equation $r = 4\cos2\theta$,
$-\frac{\pi}{4}\leq \theta \leq\frac{\pi}{4}$, $\frac{3\pi}{4}\leq \theta \leq\frac{5\pi}{4}$
I am also given that the lines PQ, QR, RS and SP are tangents to C, where QR and SP are parallel to the initial line and PQ and RS are perpendicular to the initial line.
This is how it looks:
Now, I want to find the distance ON. Clearly, if I put $\theta=0$ in my equation I get $4$ which is correct. The issue I have is that when I try another method I don't get the same answer. So, it is known that in order to find a tangent perpendicular to the initial line $\frac{dx}{d\theta}$ needs to equal $0$. Using this method I try to find the $x$ coordinate of N, which should be the distance ON, however, I get completely different answer. Here is my working out
$x = r\cos\theta = 4\cos2\theta\cos\theta$
$\frac{dx}{d\theta} = -4\sin\theta\cos2\theta - 8\cos\theta\sin2\theta$
Then
$-4\sin\theta\cos2\theta = 8\cos\theta\sin2\theta$
$-\sin\theta\cos2\theta = 4\sin\theta\cos^2\theta$
$-\cos2\theta =4\cos^2\theta$
$-(2\cos^2\theta - 1) = 4\cos^2\theta$
$6\cos^2\theta = 1$
$\cos\theta = \pm\sqrt{\frac{1}{6}}$ Which already leads to completely different answer when subbed in.
I would like to know what I am doing wrong. Thanks in advance!

From $$-\sin \theta \cos 2 \theta = 4 \sin \theta \cos^2 \theta$$
$$\sin \theta (-\cos 2 \theta - 4 \cos^2 \theta)=0$$
It is possible to have $\sin \theta=0$ which would include when $\theta=0$ and $\theta = \pi$.
Also note that $\frac{\pi}{4}<\cos^{-1}\left(\frac1{\sqrt6} \right)\le \frac{3\pi}{4}.$