Improved Taylor/Padé approximation of cos/sin functions

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

2DaT wrote: Fri Dec 15, 2023 10:14 pm Use this one and don't bother with implementing "library" sin.
You are unlikely to write anything better.

viewtopic.php?p=8789508#p8789508

If it's for oscillator, you never ever need to do range-reduction, because phasors are limited by definition.

If it's for the wave shaper and need large ranges, you can do some bit-shifting trickery - ( viewtopic.php?p=7032074#p7032074). Something like this one and corresponding polynomials on defined on [-0.5,0.5].

All these "iteration" based formulas are total garbage. And I see 6 _mm_div_ps intrinsics which means you don't really understand the performance implication of using certain intrinsics (the division is much much slower than muls and adds).

And in general if simple function is more than 20 instructions it's probably garbage. Look at how the 2 functions from my post are constructed and do something similar. No loops, at most 1 division per function, polynomials of reasonable order, no branching, etc.
Probably aim of this thread is widely misunderstood ... it's about improved Taylor/Padé approximation method ... nothing more. Though I have couple extensions in mind to improve the total accuracy and usability. Also had Z1202 something in mind but, that discussion probably moved elsewhere.

Why I use fractional coefficients is just because of the original implementation uses those. One can calculate decimal coefficients to get rid of div calls but AFAIK, that speed increase hits the accuracy level a bit. Also, I ran 10 tests in your test procedure using my oldest, dual-core PC from 2007 to compare 6 FP multiplications against 6 FP divides (non-SSE) and those gave quite same rdtsc/val figures were mostly ~0.7 difference. If this is not correct result then you should fix your test procedure.

Post Reply

Return to “DSP and Plugin Development”