Table Lookup for tanh() versus other solutions

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

mystran wrote: Fri Nov 19, 2021 12:17 pm Also I feel someone (Vadim?) posted some derivative matched approximation a while ago too.. but I don't have a link 'cos I just use either the super-cheap approximations or 2DaT's approx depending on how much I happen to care at any given moment.
viewtopic.php?f=33&t=519852

Post

2DaT wrote: Fri Nov 19, 2021 8:34 am
andy-cytomic wrote: Fri Nov 19, 2021 6:30 am If you don't want to use a fast reciprocal sqrt with 1 Newton Raphson step then a straight out rational approximation can also be good, but then you have to tidy up the endpoints by matching the derivative(s) at the endpoints to keep things smooth. If anyone is interested in some regular rational approximations please let me know.
Straightforward relative err. minmax is very viable strategy for tanh approximations. Check out this version:
viewtopic.php?p=7503081#p7503081

Derivatives are not as big of a concern for precise approximations - if function is approximated within few ulps, derivatives are going to be approximated decently aswell.

On modern processors single precision division is way better than rcpss+NR. In some cases it can be as cheap as usual arithmetics as long as you mix divs with other operations.
I was just pointing out the decent coefficients for the recip sqrt method of higher order, and that the relative error is better to minimise, I use a regular rational approximation with matched derivatives for my own stuff. Also minimax isn't good unless you have a high enough order of polynomial to get a high accuracy. For lower order polynomials a minimax solution will not have the correct derivative of 1 at x = 0, and there can be discontinuities at the endpoints as well.
The Glue, The Drop - www.cytomic.com

Post Reply

Return to “DSP and Plugin Development”