How many triplets $(p,q,r)$ of integers between $1$ and $1000$ satisfy $p^2\sin^2x+q\sin2x+r^2\cos^2x>1$, if $\sin x$ and $\cos x$ are non-zero? 
We have an inequality of the form 
  $$p^2\sin^2 x + q\sin2x + r^2\cos^2x > 1$$
  for integers $p$, $q$, $r$ with $1\leq p,q,r \leq 1000$, and such that $x$ cannot be any value that makes $\sin x$ or $\cos x$ equal to $0$.
How many triplets of the form $(p,q,r)$ satisfy the above inequality?   

Note. I actually need a pseudo code for this, but I was stuck in the mathematical approach itself so I came here.

My approach: 
I tried finding an upper bound by breaking $q\sin2x$ as $2q\sin x\cos x$ and clubbing it with the remaining two terms to get something of the form of
$$A\sin x + B\cos x > 1$$
The maximum value of LHS can $\sqrt{A^2+ B^2}$. 
But I haven't made any progress after this. 

We must find a condition on $p,q,r$ such that, for all $\theta \in \mathbb{R}$ :
$$f(\cos \theta,\sin \theta):=p^2\sin^2 \theta + 2q\sin \theta \cos \theta + r^2\cos^2 \theta \ \color{red}{> 1}\tag{1}$$ 
(1) can be transformed into the following issue :
$$\begin{cases}\text{minimization of } \ f(x,y):=r^2 x^2 + 2qxy + p^2 y^2  \ \ \ (a)\\
\text{under constraint : } \ g(x,y):=x^2+y^2=1 \ \ (b) \end{cases} \ \tag{2}$$
with the imposed $\color{red}{condition}$ that the minimum is $>1$.
Let us use the following proposition :
"The set of values taken by a quadratic form $ax^2+2bxy+cy^2$ with constraint (2)(b) is interval $[\lambda_{min},\lambda_{max}]$ (all values between the smallest and the highest eigenvalue of the associated symmetric matrix", which is here:
$$M:=\begin{pmatrix}r^2&q\\ q&p^2\end{pmatrix}\tag{3}$$
(see reference to a proof in Remark 1 below).
The characteristic equation of $M$ is 
$$\lambda^2-(p^2+r^2)\lambda+(p^2r^2-q^2)=0\tag{4}$$
Therefore the $\color{red}{condition}$ is that the smallest root:
$$\lambda_{min}=\dfrac12\left((p^2+r^2)-\sqrt{\Delta}\right) \ \color{red}{> 1} \ \ \text{with} \ \ \Delta:=(p^2+r^2)^2-4(p^2r^2-q^2)$$
This condition is equivalent to :
$$p^2+r^2-2 \ > \ \sqrt{\Delta}$$
itself equivalent, after squaring, expanding and reducing, to the "closed form" condition

$$(p^2-1)(r^2-1) \ > \ q^2$$

We find back in this way the underlying condition in the solution by @lab bhattacharjee.
Remarks : 
1) See for example slides 12/13 of https://see.stanford.edu/materials/lsoeldsee263/15-symm.pdf
Sometimes, this result is expressed under the form of a so-called "Rayleigh quotient".
2) $f(x,y)=X^TMX$ with $X=\binom{x}{y}$.
3) One could have expressed (2) using Lagrange multipliers (proportionnality $\vec{grad}(f)=\lambda \ \vec{grad}(g)$, $\lambda$ being in fact an eigenvalue of $M$). But the way we have taken is more straightforward.
