On 27 September 2011 10:12, Chad Versace <span dir="ltr"><<a href="mailto:chad@chad-versace.us">chad@chad-versace.us</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 09/26/2011 04:19 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The formula we were previously using for asinh:<br>
<br>
asinh x = ln(x + sqrt(x * x + 1))<br>
<br>
is numerically unstable: when x is a large negative value, the quantity<br>
<br>
x + sqrt(x * x + 1)<br>
<br>
is a small positive value (on the order of 1/(2|x|)). Since the<br>
logarithm function is very sensitive in this range, any error in the<br>
computation of the square root manifests as a large error in the<br>
result.<br>
<br>
This patch changes the formula to:<br>
<br>
asinh x = sign(x) * ln(abs(x) + sqrt(x * x + 1))<br>
<br>
which is only slightly more expensive to compute, and is numerically<br>
stable for all x.<br>
<br>
Fixes piglit tests<br>
spec/glsl-1.30/execution/<u></u>built-in-functions/[fv]s-<u></u>asinh-*.<br>
---<br>
src/glsl/builtins/ir/asinh | 40 ++++++++++++++++++++++++++++++<u></u>++++++----<br>
1 files changed, 36 insertions(+), 4 deletions(-)<br>
</blockquote>
<br></div>
I would mention in the commit message that the new formula is<br>
equivalent to the old. This isn't evident at first glance, and I<br>
first thought that the new was perhaps just a good, stable approximation<br>
of the old.<br></blockquote><div><br>Good point. I'll update the commit message. Thanks for the review.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Reviewed-by: Chad Versace <<a href="mailto:chad@chad-versace.us" target="_blank">chad@chad-versace.us</a>><br><font color="#888888">
<br>
-- <br>
Chad Versace<br>
<a href="mailto:chad@chad-versace.us" target="_blank">chad@chad-versace.us</a><br>
</font></blockquote></div><br>