I have been thinking about why the results for my calculations of sin(x) using the well published Taylor series have been inaccurate for values of ‘x’ between PI and 2PI.

I think, reading between the lines of many, many posts on the subject, I have an answer.

The series appears to be accurate between -PI and PI. I cannot find a definitive statement to this effect, but it certainly appears to be the case based on a lot of discussion, questions and answers, and ‘chatter’.

By now I’ve tested the algorithm using single precision (on my Ubuntu linux box), double precision, and even swapping out my coded ‘power’ method for a library method. In all cases, the results were the same. Between PI and 2PI, results diverged from ‘actual’.

Note: PL/I on the Z80 does not have a ‘pow’ method which is why I had to write one. Having written in for the PL/I program, I kept it in my C programs (single and double precision) for comparative equality between the C and PL/I verions.

I recoded the program to calculate between -PI and PI, and also added a difference output (calc – actual) to see the actual divergence. Using -Pi to PI, the results are all much closer for the entire range.

My conclusion, barring new information, is that the published Taylor series for calculating values of sin(x) for ‘x’ in radians is accurate in the range of ‘x’ between -PI and PI.

An interesting observation… I wrote some Basic to explore. I think I see what’s happened. I’ve posted over on the retrocomputingforum dot com.