<div dir="ltr">Note: From skimming your readme it is worth noting that log1p _is_ in base now (alongside expm1, log1pexp, and log1mexp). We added them all a couple of years back as a result of the very thread linked in your README.<div><br></div><div>You need to `import Numeric` to see them, though.</div><div><br></div><div>Switching to more accurate functions for doubles and floats for asinh, atanh, etc. to exploit this sort of functionality at least seems to make a lot of sense.</div><div><br><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">That can be done locally without any user API impact as the current definitions aren't supplied as defaults, merely as pointwise implementations instance by instance. Things will just become more accurate.</div><br></div><div>In that same spirit, we can probably crib a better version for complex numbers from somewhere as well, as it follows the same general simplistic formula right now, even if it can't be plugged directly into the equations you've given. For that matter, the log1p definition we're using for complex numbers was the best I could come up with, but there may well be a more accurate version you can find down in the mines of libm or another math library written by real analysts.</div><div><pre style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span> </span><a name="local-8214565720323819416"></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Float.html#log1p" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">log1p</span></a><span> </span><a name="local-6989586621679304820"></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304820" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">x</span></a><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">@</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><a name="local-6989586621679304821"></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304821" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">a</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#%3A%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">:+</span></a><span> </span><a name="local-6989586621679304822"></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304822" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">b</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span><span>
</span><a name="line-200"></a><span> </span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">|</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#abs" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">abs</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304821" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">a</span></a><span> </span><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)"><</span><span> </span><span class="gmail-hs-number" style="color:rgb(38,139,210)">0.5</span><span> </span><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">&&</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#abs" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">abs</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304822" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">b</span></a><span> </span><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)"><</span><span> </span><span class="gmail-hs-number" style="color:rgb(38,139,210)">0.5</span><span>
</span><a name="line-201"></a><span> </span><span class="gmail-hs-special" style="color:rgb(220,50,47)">,</span><span> </span><a name="local-6989586621679304823"></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304823" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">u</span></a><span> </span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)"><-</span><span> </span><span class="gmail-hs-number" style="color:rgb(38,139,210)">2</span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2A" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">*</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304821" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">a</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304821" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">a</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2A" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">*</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304821" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">a</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304822" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">b</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2A" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">*</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304822" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">b</span></a><span> </span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">=</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Float.html#log1p" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">log1p</span></a><span> </span><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304823" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">u</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Real.html#%2F" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">/</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-number" style="color:rgb(38,139,210)">1</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Float.html#sqrt" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">sqrt</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304823" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">u</span></a><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a><span class="gmail-hs-number" style="color:rgb(38,139,210)">1</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#%3A%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">:+</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Float.html#atan2" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">atan2</span></a><span> </span><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-number" style="color:rgb(38,139,210)">1</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304821" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">a</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304822" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">b</span></a><span>
</span><a name="line-202"></a><span> </span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">|</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html#otherwise" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">otherwise</span></a><span> </span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">=</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Float.html#log" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">log</span></a><span> </span><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-number" style="color:rgb(38,139,210)">1</span><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Num.html#%2B" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a><span> </span><a href="https://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.Complex.html#local-6989586621679304820" class="gmail-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">x</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span></pre></div><div><br></div><div>So, here's a +1 from the libraries committee side towards improving the situation.</div><div><br></div><div>From there, it's a small matter of implementation. </div><div><br></div><div>Here's where I'd usually get Ben involved. Hi Ben!</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 2, 2018 at 1:23 AM, Matt Peddie <span dir="ltr"><<a href="mailto:mpeddie@gmail.com" target="_blank">mpeddie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi devs,<br>
<br>
I tried to use asinh :: Double -> Double and discovered that it's<br>
inaccurate compared to my system library (GNU libm), even returning<br>
-Infinity in place of finite values in the neighborhood of -22 for<br>
large negative arguments. `atanh` is also inaccurate compared to the<br>
system library. I wrote up a more detailed description of the problem<br>
including plots in the README file at<br>
<a href="https://github.com/peddie/ghc-inverse-hyperbolic" rel="noreferrer" target="_blank">https://github.com/peddie/ghc-<wbr>inverse-hyperbolic</a> -- this repository is<br>
package that can help you examine the error for yourself or generate<br>
the plots, and it also contains accurate pure-Haskell translations of<br>
the system library's implementation for these functions. What's the<br>
next step to fixing this in GHC?<br>
<br>
Cheers<br>
<span class="HOEnZb"><font color="#888888"><br>
Matt Peddie<br>
______________________________<wbr>_________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
</font></span></blockquote></div><br></div>