viewtopic.php?f=33&t=519852
Table Lookup for tanh() versus other solutions
- KVRAF
- 2637 posts since 3 Dec, 2008
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.2DaT wrote: ↑Fri Nov 19, 2021 8:34 amStraightforward relative err. minmax is very viable strategy for tanh approximations. Check out this version: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.
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.
The Glue, The Drop - www.cytomic.com