Find the values of $\theta$ for which the tangent line to the given curve is parallel to $x$ ,$y$ axis Given the curve $$r(\theta):=\sec\left(\theta\right)+a\cos\left(\theta\right) \tag{$a \in \mathbb R$}$$
Find the values of $\theta$ for which the tangent line to the curve is parallel to the $x$ and $y$ axis.


*

*The points for which the tangent line to the curve is parallel to the $y$ axis is given by :

$$\frac{dx}{d\theta}=0$$$$\left(\sec\left(\theta\right)\tan\left(\theta\right)-a\sin\left(\theta\right)\right)\cos\left(\theta\right)-\sin\left(\theta\right)\left(\sec\left(\theta\right)+a\cos\left(\theta\right)\right)=0$$
$$\tan\left(\theta\right)-a\sin\left(\theta\right)\cos\left(\theta\right)-\tan\left(\theta\right)-a\sin\left(\theta\right)\cos\left(\theta\right)=0$$
Assuming $a\ne0$:
$$\sin\left(\theta\right)\cos\left(\theta\right)=0$$
$$\theta=\frac{k\pi}{2}\tag{$k \in \mathbb Z$}$$
On the other hand duo the existence of $\sec$ function we see that the acceptable $\theta$'s are :
$$\theta=\frac{2k\pi}{2}=k\pi\tag{$k \in \mathbb Z$}$$
Implies the points $\left(x,y\right)=\left(r\cos\left(\theta\right),r\sin\left(\theta\right)\right)$ are all in the form:
$$\left(\color{red}{\left(\sec\left(k\pi\right)+a\cos\left(k\pi\right)\right)\cos\left(k\pi\right)},\color{blue}{\left(\sec\left(k\pi\right)+a\cos\left(k\pi\right)\right)\sin\left(k\pi\right)}\right)$$
We see that the curves with $a\ne 0$ do have such tangent lines parallel to the $y$ axis.(Moreover for $a=0$ we have the line $x=1$ and the tangent line to the line (curve $r=\sec(\theta)$) parallel to the $y$ axis is the line itself.)

*

*The points for which the tangent line to the curve is parallel to the $x$ axis is given by :

$$\frac{dy}{d\theta}=0$$$$\left(\sec\left(\theta\right)\tan\left(\theta\right)-a\sin\left(\theta\right)\right)\sin\left(\theta\right)+\cos\left(\theta\right)\left(\sec\left(\theta\right)+a\cos\left(\theta\right)\right)=0$$
$$\frac{1}{\cos^{2}\left(\theta\right)}+2a\cos^{2}\left(\theta\right)-a=0$$
$$2a\cos^{4}\left(\theta\right)-a\cos^{2}\left(\theta\right)+1=0$$
$$\cos^{2}\left(\theta\right)=\frac{a\pm\sqrt{a^{2}-8a}}{4a}$$
Which is true whenever $$0\le\frac{a\pm\sqrt{a^{2}-8a}}{4a}\le1$$
Since $a^{2}-8a \ge 0$,we see that the curves with $0<a<8$ does not have such tangent lines parallel to the $x$ axis,moreover $\frac{a\pm\sqrt{a^{2}-8a}}{4a}$ is never between $0$ and $1$ and the inequality is not even sharp,so based on this information,such tangents lines parallel to the $x$ axis don't exist,but this is not true.
So where was I wrong?
 A: 
So where was I wrong?

It is wrong that "$\frac{a\pm\sqrt{a^{2}-8a}}{4a}$ is never between $0$ and $1$".
This answer proves the following two claims :
Claim 1 : $$0\le \frac{a+\sqrt{a^2-8a}}{4a}\le 1\iff a\ge 8$$
Claim 2 : $$0\le \frac{a-\sqrt{a^2-8a}}{4a}\le 1\iff a\le -1\quad\text{or}\quad a\ge 8$$

Claim 1 : $$0\le \frac{a+\sqrt{a^2-8a}}{4a}\le 1\iff a\ge 8$$
Proof :
It follows from $a\not=0$ and $a^2-8a\ge 0$ that $a\lt 0$ or $a\ge 8$.
For $a\lt 0$, we have
$$\begin{align}0\le \frac{a+\sqrt{a^2-8a}}{4a}\le 1&\iff 0\ge a+\sqrt{a^2-8a}\ge 4a
\\\\&\iff \sqrt{a^2-8a}\le -a\quad\text{and}\quad \sqrt{a^2-8a}\ge 3a
\\\\&\iff a^2-8a\le (-a)^2
\\\\&\iff a\ge 0\end{align}$$
where note that $\sqrt{a^2-8a}\ge 3a$ holds for $a\lt 0$ since RHS is negative.
For $a\ge 8$, we have
$$\begin{align}0\le \frac{a+\sqrt{a^2-8a}}{4a}\le 1&\iff 0\le a+\sqrt{a^2-8a}\le 4a
\\\\&\iff -a\le \sqrt{a^2-8a}\quad\text{and}\quad \sqrt{a^2-8a}\le 3a
\\\\&\iff a^2-8a\le (3a)^2
\\\\&\iff a\ge -1\end{align}$$
where note that $-a\le \sqrt{a^2-8a}$ holds for $a\ge 8$ since LHS is negative.
So, we get
$$0\le \frac{a+\sqrt{a^2-8a}}{4a}\le 1\iff a\ge 8$$

Claim 2 : $$0\le \frac{a-\sqrt{a^2-8a}}{4a}\le 1\iff a\le -1\quad\text{or}\quad a\ge 8$$
Proof :
For $a\lt 0$, we have
$$\begin{align}0\le \frac{a-\sqrt{a^2-8a}}{4a}\le 1&\iff 0\ge a-\sqrt{a^2-8a}\ge 4a
\\\\&\iff \sqrt{a^2-8a}\ge a\quad\text{and}\quad \sqrt{a^2-8a}\le -3a
\\\\&\iff a^2-8a\le (-3a)^2
\\\\&\iff a\le -1\end{align}$$
where note that $\sqrt{a^2-8a}\ge a$ holds for $a\lt 0$ since RHS is negative.
For $a\ge 8$, we have
$$\begin{align}0\le \frac{a-\sqrt{a^2-8a}}{4a}\le 1&\iff 0\le a-\sqrt{a^2-8a}\le 4a
\\\\&\iff \sqrt{a^2-8a}\le a\quad\text{and}\quad \sqrt{a^2-8a}\ge -3a
\\\\&\iff a^2-8a\le a^2
\\\\&\iff a\ge 0\end{align}$$
where note that $\sqrt{a^2-8a}\ge -3a$ holds for $a\ge 8$ since RHS is negative.
So, we get
$$0\le \frac{a-\sqrt{a^2-8a}}{4a}\le 1\iff a\le -1\quad\text{or}\quad a\ge 8$$
