but the summary is:
-------------------
atan2(3,0) --> 1/2*pi
atan2(-3,0) --> -1/2*pi
atan2(pi,0) --> 1/2*pi
atan2(-pi,0) --> RuntimeError: power::eval(): division by zero
--------------------
Thanks--
Greg
In the convention atan2(y, x):
atan2(-pi, 0) = 2*atan(-pi/pi) = -pi/2 = -1.57079...
Python agrees too:
In [1]: from math import atan2, pi
In [2]: atan2(-pi, 0)
Out[2]: -1.5707963267948966
More info here:
http://certik.github.com/theoretical-physics/book/src/math/other.html#argument-function-atan2
Ondrej
I opened a ticket for this:
http://trac.sagemath.org/sage_trac/ticket/8565
We use the atan2 function from GiNaC which also has this problem:
ginsh - GiNaC Interactive Shell (ginac V1.5.6)
__, _______ Copyright (C) 1999-2009 Johannes Gutenberg University
Mainz, (__) * | Germany. This is free software with ABSOLUTELY
NO WARRANTY. ._) i N a C | You are welcome to redistribute it under
certain conditions. <-------------' For details type `warranty;'.
Type ?? for a list of help topics.
> atan2(-Pi,0);
power::eval(): division by zero
Cheers,
Burcin
Now that I've managed to divide the discussion between two groups, I
should try to help organize the mess I made.
Ondrej mentioned in the sage-support discussion that he's opened
ticket 8564. Unfortunately I don't understand the plumbing well
enough to know if 8564 and 8565 are addressing the same or different
problems. As you mention, Sage seems to import atan2 from GiNaC.
8564 looks to be improving the import of the functionality from Sympy.
From a user perspective, it would be best if the default flavor worked
without needing to learn the unique syntax of a sub-package, but
beggars can't be choosers. =)
I'm happy to try and help if given some guidance. I'm a reasonably
capable programmer, but I'm completely unfamiliar with Sage and a
touch intimidated by the complexity of it.
Thanks again to everyone for following up on this.
Cheers--
Greg
On Mar 20, 3:38 am, Burcin Erocal <bur...@erocal.org> wrote:
> Hi Greg,
>
> On Fri, 19 Mar 2010 16:41:58 -0700 (PDT)
>
> G B <g.c.b.at.w...@gmail.com> wrote:
> > I raised this in sage-support, and am now reasonably convinced this is
> > a bug. Guidelines say the next step is to raise it here. The full
> > thread is at:
> >http://groups.google.com/group/sage-support/browse_thread/thread/02f3...
You have to fix ginac, it's in the pynac spkg package, I guess it
should be fairly easy --- just find the atan2 function, figure out why
it doesn't work and try to fix it.
Ondrej
On Mon, 22 Mar 2010 15:47:54 -0700 (PDT)
G B <g.c.b....@gmail.com> wrote:
> Burcin--
>
> Now that I've managed to divide the discussion between two groups, I
> should try to help organize the mess I made.
>
> Ondrej mentioned in the sage-support discussion that he's opened
> ticket 8564. Unfortunately I don't understand the plumbing well
> enough to know if 8564 and 8565 are addressing the same or different
> problems. As you mention, Sage seems to import atan2 from GiNaC.
> 8564 looks to be improving the import of the functionality from Sympy.
They are unrelated issues.
> From a user perspective, it would be best if the default flavor worked
> without needing to learn the unique syntax of a sub-package, but
> beggars can't be choosers. =)
Yep, we really need to fix the atan2 in Sage.
> I'm happy to try and help if given some guidance. I'm a reasonably
> capable programmer, but I'm completely unfamiliar with Sage and a
> touch intimidated by the complexity of it.
I can help with the first steps. Although the fix doesn't seem so
obvious to me (I don't have time to start debugging properly), it should
still be a good project to start with.
The code for evaluating atan2 lives in the c++ library pynac [1], which
is based on GiNaC.
[1] http://pynac.sagemath.org/
There are two approaches to fix this problem,
- one can either look into the "automatic evaluation" [2, 3] function
of atan2 in GiNaC [4],
[2] http://www.ginac.de/tutorial/Symbolic-functions.html
[3] http://www.ginac.de/tutorial/Automatic-evaluation.html
[4]
http://pynac.sagemath.org/hg/file/9ff767fb0c18/ginac/inifcns_trans.cpp#l971
You can also just report the problem to the GiNaC developers by
writing to the ginac-list mailing list:
http://www.ginac.de/Lists.html
- or override the automatic evaluation function with a python function
(I implemented this recently in pynac.) by defining an _eval_()
method in the class sage.functions.trig.Function_arctan2.
If you choose to fix the c++ code here is a short guide to get started
with pynac development:
http://wiki.sagemath.org/pynac/start
Feel free to ask more questions. Especially the symbolics subsystem and
the pynac interface really needs documentation. I find that answering
questions is way easier than writing manuals.
Thank you.
Burcin
On Mar 23, 2:06 am, Burcin Erocal <bur...@erocal.org> wrote:
> Hi Greg,
>
> On Mon, 22 Mar 2010 15:47:54 -0700 (PDT)
>
> [4]http://pynac.sagemath.org/hg/file/9ff767fb0c18/ginac/inifcns_trans.cp...
> I don't seem able to edit my previous message to add this information,
> but the GiNaC team seems to have picked up the bug report and patched
> it:
> http://www.cebix.net/pipermail/ginac-devel/2010-March/001724.html
Great! Thanks for following this up.
I will create an updated pynac package with the fix in the weekend.
The current patch leaves atan2(-Pi, 0) unevaluated, maybe there will be
a better solution by then.
Cheers,
Burcin
It looks like the GiNaC update has been released as GiNaC 1.5.7:
http://www.cebix.net/pipermail/ginac-devel/2010-March/001732.html
Cheers--
Greg
On Mar 26, 2:36 am, Burcin Erocal <bur...@erocal.org> wrote:
> On Thu, 25 Mar 2010 17:08:30 -0700 (PDT)
>