Solutions of $\frac{1}{\cos \theta} = a \sin \theta - b$ One of my math professors and I are working on a physics problem involving spinning a chain, and we decided to go as simple as possible and work out the solution explicitly for that case (a long rod hanging from a hinge rotating in a horizontal circle). Then we could hopefully work up from there. In the end, we boiled it down to the point where we had an equation of this form:
$$\frac{1}{\cos \theta} = a \sin \theta - b$$
Depending on the values of $a$ and $b$, there are $0$, $1$, $2$, $3$, or $4$ solutions for $\theta$ in this equation. What I'm curious about is whether there are formulas in terms of $a$ and $b$ that will give these solutions. As an aside, this situation actually reminds me of quadratics - they have $0$, $1$, or $2$ solutions, the solutions are given by the quadratic formula, and the value of $b^2-4ac$ indicates how many real-valued solutions there are. I'm looking for something similar for the equation I've given above, and WolframAlpha is being no help (gasp!).
 A: You can see why you have up to 4 solutions because you can rearrange the equation to produce a quartic in $\cos{\theta}$:
$$a^2 \cos^4{\theta} + (b^2-a^2) \cos^2{\theta} + 2 b \cos{\theta} + 1 = 0$$
Is there a formula for the roots of this polynomial in terms of $a$ and $b$?  Sure, but I imagine it is nasty.
EDIT
I played around with the exact roots in Mathematica, which I can tell you is not the most enlightening exercise I have taken up in this space.  That said, there was this square root term that occurred throughout, the radicand of which I imagine acts as a discriminant.  That is, the discriminant must be greater than zero for there to be real roots.  In case you're curious, the expression for this discriminant is 
$$-a^4 \left(a^6-a^4 \left(3 b^2+8\right)+a^2 \left(3 b^4-20
   b^2+16\right)-b^6+b^4\right)$$
A: If we put $t=\tan \frac\theta2,\sin\theta =\frac{2t}{1+t^2},\cos\theta=\frac{1-t^2}{1+t^2}$
Then, 
$$ \frac1{\cos\theta}=a\sin\theta-b--->(1)$$
 becomes $$(b-1)t^4-2at^3-2t^2+2at-(b+1)=0--->(2)$$ which is  a quartic equation in $t$ hence will definitely have exactly four finite roots if $b-1\ne0$ .
$(1)$  If $b=1,$ the equation reduces to $2at^3+2t^2-2at+2=0--->(3)$
We can make use of this to identify the number of real roots of $(3)$ 
Clearly, each real root of $(3)$  will correspond to one real of root of of $(1)$ the reason being:
We know, $\tan A=\tan B\implies A=n\pi+B,$ so $\tan(\pi+\frac\theta2)=\tan\frac\theta2$  i.e., or $\tan\left(\frac{2\pi+\theta}2\right)=\tan\frac\theta2$
So, the periods  of $\cos\theta,\sin\theta(=2\pi)$ and $\tan \frac\theta2$ are same. 
Hence, in each $\in[2n\pi,2(n+1)\pi)$ there will be one-one correspondence between $\cos\theta,\tan \frac\theta2$  and  $\sin\theta,\tan \frac\theta2$ 
$(2)$ If $b\ne1,$ we can write  $$t^4-\frac{2a}{b-1}t^3-\frac2{b-1}t^2+\frac{2a}{b-1}t+\frac{b+1}{b-1}=0--->(4)$$
Now, we eliminate the $t^3$ term by putting $y=x-\lambda\implies x=y+\lambda$
$$(y+\lambda)^4-\frac{2a}{b-1}(y+\lambda)^3-\frac2{b-1}(y+\lambda)^2+\frac{2a}{b-1}(y+\lambda)+\frac{b+1}{b-1}=0--->(5)$$
The coefficient of  $y^3$ is $4\lambda-\frac{2a}{b-1}$
If we set this to $0,\lambda=\frac a{2(b-1)}\implies y=x+\frac a{2(b-1)}$
Now, we can utilize this to identify the number of real roots of $(5),$ hence of $(4)$ 
Clearly, each real root of $(4)$ i.e. of $(2)$ will correspond to one real of root $(1)$
