next up previous contents
Next: Cosine Up: Trigonometric Functions Previous: Trigonometric Functions

Sine

The sine function is relatively simple to implement using the following approximation:

\begin{displaymath}
\sin(x) = \sum_{n=1}^\infty \frac{(-1)^{n-1} \!\cdot\!x^{2n-1}}{(2n-1)!}\end{displaymath}

Using this sum, we can easily construct a sequence S(x) such that $S_n(x) \rightarrow \sin(x)$ as $x \rightarrow \infty$. We by also computing a second sequence s(x), the current value of which can be computed as we generate the sequence when implementing this:

Observe that if x = 0, all terms of the sequence are zero. If x > 0, all even terms are greater than $\sin(x)$, and all odd terms less than it, and if x < 0, all even terms are less than $\sin(x)$, and all odd terms greater than it.

Using this information, it is extremely easy to generate a stream of nested intervals using two consecutive terms of the sequence of lower and upper bounds. Notice that the division is always by in integer. The integer division algorithm is simpler and quicker than algorithm for division of a real number by another real.



Martin Escardo
5/11/2000