Maximum point of a polar function

I have a curve C with polar equation $$r^2 = a^2\cos{2\theta}$$

And I am looking to find the length $x$ when $r=max$

Judging from the equation: $$r = \sqrt{a^2\cos{2\theta}}$$

R will be maximum at $\cos{2\theta}=1$

So the maximum value of $r$ is:

$$r = \sqrt{a^2} =a$$

However the derivative disagrees as: $$x^2=r^2\sin^2{\theta}=a^2\cos{2\theta}\,\sin^2{\theta} \\ \frac{d}{d\theta}\left (a^2\cos{2\theta}\,\sin^2{\theta} \right )=a^2(2\sin{\theta}\cos{\theta}-8\sin^3{\theta}\cos{\theta}) \\ \sin{\theta}=\frac{1}{2} \\ \theta= \frac{\pi}{6} \\ r= \frac{a}{\sqrt{2}}$$

What am I doing wrong?

-
Do you want the $x$ at maximum $r$ or do you want the maximum $x$? – user17762 Jun 21 '12 at 21:37
From the point $O$ to the point where $\theta = 0$ I want that length on the x-axis. Isn't that the maximum value of $r$? – εν οίδα ότι ουδέν οίδα Jun 21 '12 at 21:39
$x^2 = r^2 \cos^2(\theta) = a^2 \cos(2 \theta) \cos^2(\theta) \implies \dfrac{d x^2}{d \theta} = a^2 (-2\sin(2 \theta) \cos^2(\theta) - \cos(2\theta) \cos(\theta) \sin(\theta))$ – user17762 Jun 21 '12 at 21:43
Ohh, I mixed up $r$ and $y$ right there. So $\frac{d}{d\theta}\left (a^2 \cos{2 \theta} \cos^2{\theta} \right )=0$ will end up giving me $r=a$ right? – εν οίδα ότι ουδέν οίδα Jun 21 '12 at 21:48

Differentiating $r$ wrt to $\theta$ gives $\theta \mapsto |a|\frac{\sin 2 \theta}{\cos 2 \theta}$, which is zero when $\cos 2 \theta = \pm 1$. No disagreement there!
From this compute $x = r \cos \theta$. Since $\theta = 0$ maximizes $r$, the corresponding $x = |a|$.