Hi!
spiff wrote:
Chromatix wrote:
In a BASIC ROM, you need to have subroutines implementing multiply and divide anyway. So from a code size perspective, it costs very little to make use of them. Using a Taylor series (which has a regular structure, so you can loop its generator code) might well end up as smaller code (albeit slower) than implementing CORDIC, and still results in acceptable accuracy if you stick to a reasonable input domain.
True. Code size was probably a more important priority than execution speed back then.
BigEd wrote:
The usual approach is polynomials: rational polynomials (or continued fractions) in the faster implementations, and Chebyshev or some other tweaked Taylor-like series in the slower implementations. A pure Taylor series is, I think, not the wisest tactic - it just happens to be the simplest approach which most people come across first. The derivation of the 'best' coefficients is rather deep, as far as I can tell. We had a bit of a look into this
over here.
Thanks for sharing your insights. I know you have spent some time looking at different implementations.
I will try to look further into this and do some experiments of my own...
For derivation of coefficients of rational/polynomial interpolations, I found that
http://sollya.gforge.inria.fr/ is very good. It allows to specify the target floating point format in number of bits, so you can use it to generate polynomials appropriate for your specific implementation.
Using it I derived best polynomials for my SIN / COS implementation in FastBasic, see
https://github.com/dmsc/fastbasic/blob/ ... os.asm#L38 . As an optimization of code space, I also fixed the last coefficient to exactly PI/2, this works as I'm calculating SIN( PI/2 * y ). It is very fast as it only uses 6 multiplications and produces relative error < 1.23*10^-8