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
Any ideas how to get around this?
Thanks--
Greg
Here's the full traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_34.py", line 9, in <module>
open("___code___.py","w").write("# -*- coding: utf-8 -*-\n" +
_support_.preparse_worksheet_cell(base64.b64decode("YXRhbjIoLXBpLDAp"),globals())
+"\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/ol/olxcekVE2RWirE+1YxlblU+++TI/-Tmp-/
tmphh0DH2/___code___.py", line 3, in <module>
atan2(-pi,_sage_const_0 )
File "", line 1, in <module>
File "function.pyx", line 709, in
sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/
function.cpp:6394)
File "function.pyx", line 430, in
sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:
4448)
RuntimeError: power::eval(): division by zero
Sage 4.3.3
OS X 10.6.2
64bit Intel
MacBook Pro
On Mar 17, 9:11 pm, G B <g.c.b.at.w...@gmail.com> wrote:
> atan2(-pi,0) --> RuntimeError: power::eval(): division by zero
I got the same in the new 4.3.4.rc0 Sage version that I've just
installed.
Playing with that, I noticed also the following strange thing:
sage: n(atan2(-sqrt(2),0))
-1/2*pi
While it looks correct, it is not the answer that n should give.
Alec Mihailovs
> atan2(-pi,0) --> RuntimeError: power::eval(): division by zero
>
> Any ideas how to get around this?
A simple workaround is
sage: from sympy import atan2
sage: atan2(-pi,0)
-pi/2
Alec Mihaiovs
I get: AttributeError: 'atan2' object has no attribute '_sage_'
My original code had this for that second last line:
v_a(t)=atan2(dy(t),dx(t)).substitute(r=10,omega=(2*pi/60))
and it throws: AttributeError: 'atan2' object has no attribute
'substitute'
The code with the .substitute line seems to work for (t%30 <> 0) so I
think I've formatted my equations properly.
Apologies if I'm doing something horribly hackish-- I'm new to Sage.
Any other ideas?
Thanks--
Greg
This is a bug in sympy, I've fixed that in sympy, currently the
patches are waiting for a review. When we update the sympy package in
sage, here is what you'll get:
sage: var('omega,t,x,y,r,Theta')
(omega, t, x, y, r, Theta)
sage: Theta(t)=omega*t
sage: x(t)=r*cos(Theta(t))
sage: y(t)=r*sin(Theta(t))
sage: dx=diff(x,t)
sage: ddx=diff(dx,t)
sage: dy=diff(y,t)
sage: ddy=diff(dy,t)
sage: v_a(t)=atan2(dy(t),dx(t))
sage: v_a
t |--> arctan2(omega*r*cos(omega*t), -omega*r*sin(omega*t))
>
> My original code had this for that second last line:
> v_a(t)=atan2(dy(t),dx(t)).substitute(r=10,omega=(2*pi/60))
>
>
> and it throws: AttributeError: 'atan2' object has no attribute
> 'substitute'
in the above code, you are using sympy, and thus you have to use:
sage: atan2(dy(t),dx(t)).subs({r:10, omega:2*pi/60})
arctan2(1/3*pi*cos(1/30*pi*t), -1/3*pi*sin(1/30*pi*t))
and it should work. Note that this doesn't work in the current sage,
but it will work when we update sympy.
We are also facing some technical problem, that the latest mpmath in
sympy doesn't work with sage:
http://code.google.com/p/sympy/issues/detail?id=1865
so the newest sympy fails to import, but we'll fix it too.
Ondrej
Also a small fix to sage has to be done, I posted the patch here:
http://trac.sagemath.org/sage_trac/ticket/8564
Greg, could you please review it?
Thanks,
Ondrej
sage: atan(sin(1)/cos(1)).full_simplify()
arctan(sin(1)/cos(1))
while
atan(tan(1)).simplify()
1
Alec Mihailovs
Sorry to turn helpless, but I'm not sure how to apply the patch. I'm
working from a binary install for OS X. Would I need to rebuild from
source, or can I apply the patch to one of the implementation files in
the bundle? It looks like you've just changed a lookup table?
Thanks for following up.
Thanks--
Greg
On Mar 19, 7:32 pm, Ondrej Certik <ond...@certik.cz> wrote:
> On Fri, Mar 19, 2010 at 7:03 PM, Ondrej Certik <ond...@certik.cz> wrote:
On Mon, Mar 22, 2010 at 8:55 PM, Minh Nguyen <nguye...@gmail.com> wrote:
> Hi Greg,
>
> On Tue, Mar 23, 2010 at 9:35 AM, G B <g.c.b....@gmail.com> wrote:
>> Hi Ondrej--
>>
>> Sorry to turn helpless, but I'm not sure how to apply the patch. I'm
>> working from a binary install for OS X.
>
> Here is a quick-and-dirty way. I assume that you are using Sage 4.3.3
> or Sage 4.3.4. From the Sage command line, you could issue the
> following command to apply the relevant patch:
>
> sage: hg_sage.apply("http://trac.sagemath.org/sage_trac/raw-attachment/ticket/8564/sympy1.patch")
>
> After hitting the enter key, the relevant patch would be downloaded to
> your computer. A text editor would then load and you would be prompted
> to enter a "commit message". Just enter some text such as "fix atan2()
> conversions between Sage and SymPy", save your text, exit the text
> editor. If the editor is vi(m), enter the text, hit the ESC key, and
> type ":wq". If the editor is Emacs, enter the text, hold down the CTRL
> key, and type "xs" and "xc" in that order. Having exited the text
> editor, the relevant patch would be applied to your local copy of
> Sage. Now exit the Sage command line session. From the SAGE_ROOT
> directory of Sage, i.e. the Sage top-level directory, rebuild the Sage
> library as follows:
>
> $ ./sage -b main
>
> This would only rebuild the relevant parts that the patch changes.
> Most likely, the last command won't rebuild the whole Sage library.
>
>
>> Would I need to rebuild from
>> source,
>
> You don't need to rebuild Sage from source for this particular patch.
>
>
>> or can I apply the patch to one of the implementation files in
>> the bundle?
>
> Follow the direction as described above. If there is anything wrong,
> please let me know.
>
>
>> It looks like you've just changed a lookup table?
>
> The patch adds an entry to a dictionary, also known as a hash table or
> an associative array.
Thanks for all the detailed instructions. I also sent some patches
that we need to apply in sympy, fixing couple (related) bugs, so after
all is reviewed and in, I'll also update the whole sympy package and
ping you. But this patch above itself should imho fix the atan2 thing,
even with the current sympy in Sage.
Ondrej
TypeError: 'NoneType' object is unsubscriptable.
I did enter the entire URL, I didn't just paste the abbreviated URL
displayed in the post.
On Mar 23, 1:18 am, Ondrej Certik <ond...@certik.cz> wrote:
> Hi Minh!
>
>
>
>
>
> On Mon, Mar 22, 2010 at 8:55 PM, Minh Nguyen <nguyenmi...@gmail.com> wrote:
> > Hi Greg,
>
> > On Tue, Mar 23, 2010 at 9:35 AM, G B <g.c.b.at.w...@gmail.com> wrote:
> >> Hi Ondrej--
>
> >> Sorry to turn helpless, but I'm not sure how to apply the patch. I'm
> >> working from a binary install for OS X.
>
> > Here is a quick-and-dirty way. I assume that you are using Sage 4.3.3
> > or Sage 4.3.4. From the Sage command line, you could issue the
> > following command to apply the relevant patch:
>
> > sage: hg_sage.apply("http://trac.sagemath.org/sage_trac/raw-attachment/ticket/8564/sympy1....")
I've posted this to the dev list as well.
Cheers--
Greg