Ticket #6421 (closed defect: fixed)

Opened 14 months ago

Last modified 3 months ago

[with patch, positive review] make a symbolic arctan2 function

Reported by: burcin Owned by: kcrisman
Priority: major Milestone: sage-4.1
Component: symbolics Keywords:
Cc: Author(s): Karl-Dieter Crisman
Report Upstream: N/A Reviewer(s): Burcin Erocal
Merged in: sage-4.1.rc0 Work issues:

Description

From sage-devel:

> On Thu, Jun 25, 2009 at 11:31 PM, Nick
> Alexander<ncalexander@gmail.com> wrote:
> >
> > Can someone verify that this is a bug?  Any hope a fix?  (This is
> > with sage-4.0.2 on sage.math.)
> >
> > {{{
> > sage: complex_plot((x^2 + I).sqrt().real_part(), (-2, 2), (-2, 2))
> > ---------------------------------------------------------------------------
> ...
> > RuntimeError: cannot find SFunction in table
> > }}}
> 
> It seems, its not just complex_plot issue. It is happening for other
> plots. For example,  the following works fine in 3.4 but fails with
> the same error in 4.0.2
> -----
> sage: x,y=var('x,y'); plot3d( log(x+I*y).imag(), (x,-2,2), (y,-2,2))
> ...
> RuntimeError: cannot find SFunction in table
> -----

sage: %debug
> /home/burcin/sage/sage-4.0.2.rc0/expression.pyx(3115)sage.symbolic.expression.Expression.operator
> (sage/symbolic/expression.cpp:15268)()

ipdb> u
> /home/burcin/sage/sage-4.0.2.rc0/local/lib/python2.5/site-packages/sage/symbolic/expression_conversions.py(206)__call__()
    205 
--> 206         operator = ex.operator()
    207         if operator is None:

ipdb> print ex
arctan2(real_part(y) + imag_part(x), real_part(x) - imag_part(y))


Both of these fail because Sage doesn't define a symbolic arctan2
function. There is instead a simple wrapper around arctan in
sage/functions/trig.py:

sage: arctan2(x,y)
arctan(x/y)

It's possible that this worked on 4.0, and I broke it with #6244.

Attachments

trac_6421-arctan2.patch Download (2.5 KB) - added by kcrisman 14 months ago.
trac_6421-arctan2_doctest_fixes.patch Download (1.6 KB) - added by burcin 14 months ago.
minor doctest fixes in sage.symbolic.random_tests

Change History

Changed 14 months ago by kcrisman

Changed 14 months ago by kcrisman

  • owner set to kcrisman
  • status changed from new to assigned
  • summary changed from make a symbolic arctan2 function to [with patch, needs review] make a symbolic arctan2 function

Okay, this seems to fix everything and passes tests on trig.py and symbolic/expression.py and /function.py. I made the function consistent with Maxima, Pynac, and Python math. Only issue, which I would really appreciate some insight on but should not prevent it from going in, is the following:

sage: latex(arctan2)
\arctan
sage: var('y')
y
sage: latex(arctan2(y,x))
\mbox{atan2}\left(y,x\right)

Of course, this doesn't fix the question about plotting, but now the failure on that will be clearer.

Changed 14 months ago by burcin

minor doctest fixes in sage.symbolic.random_tests

Changed 14 months ago by burcin

  • reviewer set to Burcin Erocal
  • summary changed from [with patch, needs review] make a symbolic arctan2 function to [with patch, positive review] make a symbolic arctan2 function
  • author set to Karl-Dieter Crisman

Looks good, thanks for this.

I added a small patch with doctest fixes in sage/symbolic/random_tests.py.

Changed 14 months ago by rlm

  • status changed from assigned to closed
  • resolution set to fixed
  • merged set to sage-4.1.rc0

Changed 3 months ago by bascorp2

  • upstream set to N/A
Note: See TracTickets for help on using tickets.