# How should I go about calculating sines or cosines without the errors introduced solely by the transcendence of pi?

This may be irrelevant for many people but I'm asking this question because I don't need to do these things in real time, I don't care if modifying a 1-minute sound recording takes 5 minutes to process. My question has two parts.

#1. Conventional implementations of sine or cosine functions expect the argument to be in radians, which has one serious drawback. Many people will tell me to first reduce the range of the argument. But $$\pi$$ is transcendental, right? Therefore, if I try to represent $$5 \pi$$ in IEEE doubles as accurately as I can and if I then try to represent $$\pi$$ in IEEE doubles as accurately as I can, dividing the two approximations will not give me $$5$$. So I can hardly subtract $$2 \pi$$ twice without introducing further errors by doing this. Also, if I wanted to output the sine or cosine values themselves as IEEE doubles, I'd like the algorithm to be able to calculate them in such a way that the error would be unmeasurable with IEEE doubles. But this requirement can never be met if the approximation of $$\frac{\pi}{3}$$ divided by the approximation of $$\frac{\pi}{9}$$ differs from $$3$$ so much that the error is noticeable in IEEE doubles.

#2. Let's say that I only want to find sines or cosines of some rational parts of $$\pi$$. For this, it might be meaningful to use Chebyshev polynomials and calculate some insanely precise lookup tables (maybe some double-doubles or whatever) before launching any actual signal processing code. But let's say I want to find $$2 \sin \left( \frac{\pi}{9} \right)$$ and the corresponding equation goes like this:

$$3 x - x^{3} = \sqrt{3} \tag{1} \label{1}$$

Even if I knew about an excellent algorithm for finding cube roots, I could not use it here because that algorithm would most probably be meant for finding cube roots of real numbers, not of complex numbers. And if I were supposed to convert the complex numbers to polar form and back again, I would be introducing even more errors into this. So my idea would be to somehow find roots of Chebyshev polynomials without involving the conversion to polar form. But so far I only know about one person who seems to have described a similar approach in great detail and I'm not sure if anyone else has (if you're interested, I can post the link to the paper).

So my question is: What approach[es] would you suggest me to take if I only care about accuracy and don't care about the time taken? I mean, as I've said, I don't need to store the final data with an accuracy of some $$100$$ decimal digits, but IEEE doubles would be good.

• Have you tried with math software like Mathematica ? 5×π-2×π-2×π, 5×π/π , 2×sin(π/9). Jul 20, 2023 at 7:44
• I believe your question in best suited for Computational Science SE (scicomp.stackexchange.com). They are dealing with such issues there and they are better suited to answer your question. There might be some people from CompSci in Signal Processing SE, but I do believe you'll have better chances over there. Jul 20, 2023 at 9:15