Taylor series for $\sin(x)$ and $\cos(x)$ around $0$ are well known and usually exercised in beginner calculus courses. However as we know Taylor series are very localized, ultimately fitting only one point and a series of limits of that one point (differentials of integer orders):
$$\begin{align}\sin(x) &= \sum_{k=0}^\infty \frac{(-1)^kx^{2k+1}}{(2k+1)!} \\\cos(x) &= \sum_{k=0}^\infty \frac{(-1)^kx^{2k}}{(2k)!}\end{align}$$
We also have rotation matrices, which provide a way to calculate angle doubling by matrix powers:
$$R_\phi = \left[\begin{array}{rr}\cos(\phi)&\sin(\phi)\\-\sin(\phi)&\cos(\phi)\end{array}\right] \hspace{0.5cm} R_{2\phi} = {R_{\phi}}^2 = \left[\begin{array}{rr}\cos(2\phi)&\sin(2\phi)\\-\sin(2\phi)&\cos(2\phi)\end{array}\right] ... et.c.$$
Is there anything to be gained in combining these? Either in speed of computation or precision of result.
Can we either derive or find a systematic approach to estimate intervals $a \subset \mathbb R$ where Taylor polynomials should be evaluated and $b \subset \mathbb R$ where a backwards doubling should be done to achieve that?
Attempt to clarify:
Can we by some method find for a Taylor expansion $T_p(x)$ of order $p$ and an integer $k$ the two intervals on $\mathbb R$:
- $\mathcal S_1 = \left[0,\frac \pi {2^k}\right[$,
- $\mathcal S_2 = \left[\frac \pi {2^k}, \frac \pi 2 \right]$
So that the number of multiplications required in total is minimized for the following recursive procedure:
- Until estimate is calculated:
- If $x_n \in \mathcal S_2$ perform a backwards look on $x_{n+1} = \frac {x_n} 2$ with help of matrix relation above.
- If $x_n \in \mathcal S_1$ calculate value from Taylor polynomial of order $p$. And so that $|\sin(x) - T_p(x)| \leq 2^{-54} \forall x \in \mathcal S_1$ i.e. the precision is sure to be sufficient for the mantissa of a double precision float on whatever set we will be calculating the estimate.
Computing $(\pi/2)^{22} / 22!,$ $(\pi/4)^{18}/18!,$ and $(\pi/8)^{14}/14!$ shows that halving the interval length allows chopping off only two terms from the Taylor polynomial; computing $(\pi/16)^{12}/12!$ shows that an additional halving of the interval length only allows chopping off one additional term of the Taylor polynomial. This means halving the interval can only eliminate at most two multiplications.
The double angle formula for $\cos(2x)$ from $\sin(x)$ and $\cos(x)$ requires two multiplications, plus the computation of both $\sin(x)$ and $\cos(x)$; the double angle formula for $\sin(2x)$ requires one multiplication and computation of both $\sin(x)$ and $\cos(x)$.
So if you need to compute both $\sin(x)$ and $\cos(x)$ at the same time, you could reduce the total number of multiplications by one if you compute $\sin(x/2)$ and $\cos(x/2)$ and then compute $\sin(x) = \sin(x/2)\cos(x/2) + \sin(x/2)\cos(x/2)$ and $\cos(x)=\cos(x/2)^2 - \sin(x/2)^2.$ On the other hand, if you only need to compute one of $\cos(x)$ or $\sin(x),$ it will be much more expensive to compute both $\sin(x/2)$ and $\cos(x/2)$ and use the double angle formula than it would be to compute $\cos(x)$ or $\sin(x)$ directly from the Taylor polynomial.