Thanks, All.  I&#39;ll look forward to the changes percolating through.<div><br></div><div>Cheers--</div><div> Greg</div><div><br></div><div><br><div class="gmail_quote">On Thu, Mar 25, 2010 at 2:41 PM, Richard B. Kreckel <span dir="ltr">&lt;<a href="mailto:kreckel@ginac.de">kreckel@ginac.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi!<div class="im"><br>
<br>
Jens Vollinga wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 25.03.2010 00:17, schrieb G B:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I stumbled upon this using Sage, but developers there have traced it to<br>
a problem in GiNaC by running the following in ginsh:<br>
<br>
 &gt; atan2(-Pi,0);<br>
<br>
The response is:<br>
power::eval(): division by zero<br>
<br>
atan2 appears to work for other values, including (positive) (Pi,0), but<br>
(-Pi,0) fails.<br>
</blockquote>
<br>
thanks for the bug report. I fixed that bug in the repository.<br>
Finally it is time to make a new release ... :-)<br>
</blockquote>
<br></div>
Wait a minute, I think your fix is wrong. It assumes that if <a href="http://y.info" target="_blank">y.info</a>(info_flags::real) and not <a href="http://y.info" target="_blank">y.info</a>(info_flags::positive) and not y.is_zero(), then y must be negative. But that&#39;s not correct, because info returns true if the predicate is known to be true and false if it os known to be false or if it is unknown. Consider, for instance, positive symbols a and b and ex x = a-b. So, the patch introduces actually a new bug.<br>

<br>
What&#39;s really wrong is the last part in atan2_eval, where atan(real, real) -&gt; atan(y/x) +/- Pi. Ironically, it is suffering from the same mistake as your patch. This ought to fix it:<br>
<br>
@@ -877,10 +877,13 @@ static ex atan2_eval(const ex &amp; y, const ex &amp; x)<br>
        if (<a href="http://y.info" target="_blank">y.info</a>(info_flags::real) &amp;&amp; <a href="http://x.info" target="_blank">x.info</a>(info_flags::real)) {<br>
                if (<a href="http://x.info" target="_blank">x.info</a>(info_flags::positive))<br>
                        return atan(y/x);<br>
-               else if (<a href="http://y.info" target="_blank">y.info</a>(info_flags::positive))<br>
-                       return atan(y/x)+Pi;<br>
-               else<br>
-                       return atan(y/x)-Pi;<br>
+<br>
+               if (<a href="http://x.info" target="_blank">x.info</a>(info_flags::negative)) {<br>
+                       if (<a href="http://y.info" target="_blank">y.info</a>(info_flags::positive))<br>
+                               return atan(y/x)+Pi;<br>
+                       if (<a href="http://y.info" target="_blank">y.info</a>(info_flags::negative))<br>
+                               return atan(y/x)-Pi;<br>
+               }<br>
        }<br>
<br>
        return atan2(y, x).hold();<br>
<br>
It appears that this bug has been latent until Vladimir&#39;s patch c7299e51d5ecf6. The bad news is that with my patch atan2(-Pi,0) isn&#39;t simplified at all any more. One could argue that GiNaC should evaluate ex(-Pi).info(info_flags::negative) -&gt; true. This would make atan2(-Pi,0) evaluate to -Pi/2 again.<br>

<br>
  -richy.<br><font color="#888888">
-- <br>
Richard B. Kreckel<br>
&lt;<a href="http://www.ginac.de/~kreckel/" target="_blank">http://www.ginac.de/~kreckel/</a>&gt;</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
GiNaC-devel mailing list<br>
<a href="mailto:GiNaC-devel@ginac.de" target="_blank">GiNaC-devel@ginac.de</a><br>
<a href="https://www.cebix.net/mailman/listinfo/ginac-devel" target="_blank">https://www.cebix.net/mailman/listinfo/ginac-devel</a><br>
</div></div></blockquote></div><br></div>