Finding an integer $n$ such that $\sin(n)$ is close to 1 Given some $\epsilon>0$, is there an efficient way to find an integer $n$ such that 
$$1-\sin(n)<\epsilon$$
We all know there is always one (and many), and so I can test all $n$ from $0$ until I find a good candidate, but I ask for some efficient algorithm that given some $\epsilon$, computes quickly such an $n$.
 A: Consider the Taylor series of $\sin(x)$ around $\left(2k + \frac{1}{2}\right) \pi$,
\begin{align*}
\sin\left(\left(2k + \frac{1}{2}\right)\pi + x\right) 
&= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \ldots \\
&\le 1 - \frac{x^2}{2}
\end{align*}
as it is reasonably clear that $\frac{x^4}{24} - \frac{x^6}{120} + \ldots > 0$ for a small $x$.
So if we want $1 - \sin(n) < \epsilon$ then consider $n = \left(2k + \frac{1}{2}\right)\pi + x$, we thus obviously require 
$$
\left| n - \left(2k + \frac{1}{2}\right)\pi \right| < \sqrt{2 \epsilon}.
$$
As pointed out above, this is equivalent to finding a rational approximation $\frac{2n}{4k + 1}$, which if furthermore is the convergent of a continued fraction approximation, we get
$$
\left| n - \left(2k + \frac{1}{2}\right)\pi \right| < \frac{1}{8k+2}
$$
for free.
Now, there are continued fraction formulae that do not require the knowledge of $\pi$, for example Stern's formula
$$
\frac{\pi}{2} = 1 - \frac{1}{3 - \frac{2\cdot 3}{1 - \frac{1\cdot 2}{3 - \frac{4\cdot5}{1 - \frac{3\cdot 4}{3 - \frac{6\cdot7}{1 - \cdots } } } }}},
$$
which can give you a sequence of rational approximations of $\frac{\pi}{2}$. The sequences of convergents and their numerators OEIS A001901 and denominators OEIS A046126 for this can be found, and effectively all you have to do now, as we are considering $\pi/2$ i.e. $2n$ doesn't matter any more, is find a denominator of the form $4k+1$ such that $\frac{1}{8k+2} < \sqrt{2\epsilon}$, and the corresponding $2n$ in the numerator gives our answer.
