<div dir="ltr">On Mon, Nov 18, 2013 at 3:24 AM, Ross Paterson <span dir="ltr"><<a href="mailto:R.Paterson@city.ac.uk" target="_blank">R.Paterson@city.ac.uk</a>></span> wrote:<br><div class="gmail_extra"><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 Sun, Nov 17, 2013 at 08:20:21PM -0800, jared simpson wrote:<br>
> Prelude Data.Complex> 0**2<br>
> 0.0<br>
> Prelude Data.Complex> 0**2 :: Complex Double<br>
> NaN :+ NaN<br>
</div>> [...]<br>
<div class="im">><br>
> So Complex uses the default implementation of **. Then when 2*(-inf :+ 0) is<br>
> evaluated. We do (2 * -inf - 0*0) :+ (2*0 + -inf*0). Which because of -inf*0<br>
> sets the imaginary part to NaN.<br>
><br>
> Then exp (-inf :+ NaN) = exp x cos y :+ exp x sin y which becomes 0 * cos NaN<br>
> :+ 0 * sin NaN. So we end up with NaN :+ NaN.<br>
><br>
> So is there a library I should be using, or is this a bug?<br>
<br>
</div>I would say the default implementation of (**) is wrong: to match the<br>
Float/Double instances it should be<br>
<br>
         x ** y  =  if x == 0 then 0 else exp (log x * y)<br>
_______________________________________________</blockquote><div><br></div><div>Bug filed thanks.</div><div> </div></div></div></div>