Talk:SIN

From C64-Wiki
Jump to navigationJump to search

Yes, the polynomial resembles the Taylor series. But the difference does not appear to be due to roundoff error. The polynomial coded in ROM is actually more accurate, within the desired interval, than the Taylor polynomial with the same degree. (It does diverge rapidly outside that interval.)

The polynomial appears to have come from some kind of interpolation. I have tried interpolation on the Chebyshev nodes, and the resulting polynomial is "good enough", at least for the SIN function, but it does not match the one in ROM.

The better place to deal with this topic might be the POLY1 article, as it applies to all the polynomials used in the C64 BASIC.--Ray Chason (talk) 23:24, 25 February 2019 (CET)


How did you get the C64 calculation results visible or comparable for comparison with a reference (high accuracy computations)? I hope you took into account that the C64 makes a bug afflicted difference between a variable printout via the PRINT command and the true variable value stored in RAM (those 5 Bytes for floating point variables)! If you just compared printout values all charts become meaningless! Please document this issue!

I wrote a small 6502 emulator and linked it to code that could load a BASIC ROM, set up a floating point value in the zero page, invoke SIN or another floating point function and retrieve the result. With this, I could actually call the BASIC function from a C program. I could then compare the results of the BASIC function to those coming from a corresponding C standard library function. Maybe I should put that up on GitHub and link it here.--Ray Chason (talk) 02:08, 15 October 2022 (CEST)