Re: [Mesa-dev] [PATCH 1/2] glsl: Use a simpler formula for tanh

2016-12-09 Thread Kenneth Graunke
On Friday, December 9, 2016 9:41:51 AM PST Jason Ekstrand wrote: > The formula we have used in the past is a trivial reduction from the > definition by simply multiplying both the numerator and denominator of the > formula by 2. However, multiplying by e^x, you can further reduce it. > This allows

Re: [Mesa-dev] [PATCH 1/2] glsl: Use a simpler formula for tanh

2016-12-09 Thread Roland Scheidegger
Unsurprisingly, the formula looks great to me :-). I was actually wondering about accuracy. I believe the biggest issue (both with the original formula and this one) is probably values around zero - because that gets calculated as (~1 - 1) / 2 - so the closest values to zero you can get (other than

[Mesa-dev] [PATCH 1/2] glsl: Use a simpler formula for tanh

2016-12-09 Thread Jason Ekstrand
The formula we have used in the past is a trivial reduction from the definition by simply multiplying both the numerator and denominator of the formula by 2. However, multiplying by e^x, you can further reduce it. This allows us to get rid of one side of the clamp and two of exponential functions