# Testing $\sin\theta$ and $\cos\theta$ without referring to the trigonometric functions

This is very much not my area so apologies if this is an obvious no.

Suppose values have been calculated for $\sin\theta$ and $\cos\theta$. Is it possible to test their correctness, without referring to the trigonometric functions, imaginary numbers, or performing an infinite number of operations?

• How have these values been calculated? (The method in which they were calculated can give insight on how to test for correctness) Jul 4, 2013 at 14:58
• There are "well known" formulas for trigonometric functions of multiplied angles. So, for example, if you are given $\sin \theta$ and $\cos \theta$, you can compute $\cos k \theta$ in a very elementary way. If $\theta$ is a rational multiple of $\pi$, say $\theta = \frac{a}{b} \pi$, then you can use this to compute, say $\cos a \pi$ and $\sin a \pi$. A possible test is to verify if these values come out right ($\pm 1$ and $0$ respectively). Jul 4, 2013 at 14:59
• @anorton: if I understand correctly, the idea is that $\sin \theta$ and $\cos \theta$ are provided by some "black box" that we don't know much about, and the objective is to verify if the answers the "box" produced are correct. Alec: is my understanding correct? Jul 4, 2013 at 15:01
• @Feanor Yep, you are correct.
– Max
Jul 4, 2013 at 15:02
• Do we also know the angle in question? Jul 4, 2013 at 15:03

1. Assign $t\leftarrow\frac{2\theta}\pi$, $s\leftarrow\sin\theta$, $c\leftarrow\cos\theta$
2. Test if $s^2+c^2=1$ (within desired precision).
3. Let $r= \lfloor t \rfloor$. If $r\equiv 0\pmod 4$, verify that $s\ge 0, c\ge 0$. If $r\equiv 1\pmod 4$, verify that $s\ge 0, c\le 0$. If $r\equiv 2\pmod 4$, verify that $s\le 0, c\le 0$. If $r\equiv 3\pmod 4$, verifiy that $s\le 0,c\le 0$.
4. Assign $t\leftarrow 2t$, $s\leftarrow 2sc$, $c\leftarrow 2c^2-1$ and go back to step 3