Jacobi sn

85 views
Skip to first unread message

Rafael

unread,
Sep 15, 2012, 8:10:10 PM9/15/12
to sage-s...@googlegroups.com
Hello,

I am encountering an error when checking numerically the imaginary period of the Jacobi sn function:

sage: u=1.2
sage: m=0.5
sage: jacobi('sn',u,m)
0.887715488619
sage: jacobi('sn',u+2*I*elliptic_kc(1-m),m)
jacobi_sn(1.2 + 3.7081493546*I, 0.500000000000000)
sage: n(jacobi('sn',u+2*I*elliptic_kc(1-m),m))
WARNING: Output truncated!  
<html><a target='_new' href='/home/admin/0/cells/61/full_output.txt' class='file_link'>full_output.txt</a></html>

The result should be the same as for jacobi('sn',u,m).

I am running Sage 5.3 on a macbook air under OS 10.7.4. Thanks!

kcrisman

unread,
Sep 15, 2012, 11:26:23 PM9/15/12
to sage-s...@googlegroups.com

On Saturday, September 15, 2012 8:10:11 PM UTC-4, Rafael wrote:
Hello,

I am encountering an error when checking numerically the imaginary period of the Jacobi sn function:

sage: u=1.2
sage: m=0.5
sage: jacobi('sn',u,m)
0.887715488619
sage: jacobi('sn',u+2*I*elliptic_kc(1-m),m)
jacobi_sn(1.2 + 3.7081493546*I, 0.500000000000000)
sage: n(jacobi('sn',u+2*I*elliptic_kc(1-m),m))
WARNING: Output truncated!  
<html><a target='_new' href='/home/admin/0/cells/61/full_output.txt' class='file_link'>full_output.txt</a></html>

The result should be the same as for jacobi('sn',u,m).


There are two problems here, actually.  One is that we return something we can't really evaluate with this "jacobi_sn" - such a function is not defined in Sage, only the jacobi('sn', ...)  The other is the one you comment on.  It managed to completely drain my Sage instance - I had to close the terminal!

I don't have access to a Maxima instance right now - can someone try to recreate this there?  My guess is that it's there, since MaximaFunction would use stuff at http://hg.sagemath.org/sage-main/file/d06cf4b2215d/sage/functions/special.py#l485 to do this.  Maybe 

Robert Dodier

unread,
Sep 16, 2012, 2:08:43 AM9/16/12
to sage-s...@googlegroups.com
On 2012-09-16, kcrisman <kcri...@gmail.com> wrote:

> I don't have access to a Maxima instance right now - can someone try to
> recreate this there?

For the record, here's what I get w/ Maxima 5.28.0 (current release).

(%i1) u : 1.2 $
(%i2) m : 0.5 $
(%i3) jacobi_sn (u, m);
(%o3) .8877154886192781
(%i4) jacobi_sn (u + 2 * %i * elliptic_kc (1 - m), m);
(%o4) 0.88771548861928 - 1.884363664625109E-15 %i

I don't know what version of Maxima Sage is using, and I would have to
look at the revision log to see if the elliptic functions have changed
since then.

best,

Robert Dodier

Rafael

unread,
Sep 20, 2012, 8:31:05 AM9/20/12
to sage-s...@googlegroups.com
Thank you for your reply.

I get:

sage: maxima.version()
'5.26.0'

I searched the Maxima change logs at:


(and also for 5.28) and did not see any direct changes to elliptic functions.  
But I am glad to see that they seem to be working better in 5.28.

Is there any chance that Maxima 5.28 will be included in the next version of Sage ?
In February, I will be teaching a course (at AIMS in Cape Town) using Sage, where I plan
to introduce the elliptic functions; and it would be nice to have this working by then.

Thanks again! 

Rafael.

Jan Groenewald

unread,
Nov 20, 2012, 1:36:22 AM11/20/12
to sage-s...@googlegroups.com
Hi

(should this thread be on sage-devel?)

On 16 September 2012 08:08, Robert Dodier <robert...@gmail.com> wrote:
On 2012-09-16, kcrisman <kcri...@gmail.com> wrote:

> I don't have access to a Maxima instance right now - can someone try to
> recreate this there?

For the record, here's what I get w/ Maxima 5.28.0 (current release).

(%i1) u : 1.2 $
(%i2) m : 0.5 $
(%i3) jacobi_sn (u, m);
(%o3)                          .8877154886192781
(%i4) jacobi_sn (u + 2 * %i * elliptic_kc (1 - m), m);
(%o4)             0.88771548861928 - 1.884363664625109E-15 %i


I get the same result in maxima 5.24, the stock version on Ubuntu 12.04.
0 jan@muizenberg:/var/autofs/misc/home/jan$maxima

Maxima 5.24.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (a.k.a. GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.

(%i1) u : 1.2 $
(%i2) m : 0.5 $
(%i3) jacobi_sn (u, m);
(%o3)                          0.88771548861928

(%i4) jacobi_sn (u + 2 * %i * elliptic_kc (1 - m), m);
(%o4)            0.88771548861928 - 1.7301614091485549E-15 %i
(%i5)

Either that was a regression specifric to maxima 5.26, or this problem is particular
to the sage interface to maxima. Original problem:

0 jan@muizenberg:/var/autofs/misc/home/jan$sage
----------------------------------------------------------------------
| Sage Version 5.4, Release Date: 2012-11-09                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------

sage: u=1.2                                  
sage: m=0.5                                  
sage: jacobi('sn',u,m)                       
0.887715488619
sage: jacobi('sn',u+2*I*elliptic_kc(1-m),m)  
jacobi_sn(1.2 + 3.7081493546*I, 0.500000000000000)
sage: n(jacobi('sn',u+2*I*elliptic_kc(1-m),m))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8886, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8886, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8886, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8886, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8886, 0))

^C
KeyboardInterrupt
sage:


 Can some one test this code on a sage which includes maxima 5.24?
From http://maxima.sourceforge.net/ looks like that might be sage 4.8.

And can someone test this code on a standalone maxima 5.26?

Regards,
Jan

--
  .~.
  /V\     Jan Groenewald
 /( )\    www.aims.ac.za
 ^^-^^


Justin C. Walker

unread,
Nov 20, 2012, 2:25:34 AM11/20/12
to sage-s...@googlegroups.com

On Nov 19, 2012, at 22:36 , Jan Groenewald wrote:

> On 16 September 2012 08:08, Robert Dodier <robert...@gmail.com> wrote:
>
>> On 2012-09-16, kcrisman <kcri...@gmail.com> wrote:

Using Mac OS X, 10.6.8. Sage 4.8 has maxima 5.23 (maxima-5.23.2.p3.spkg); 5.0-beta2 has maxima 5.26.

> Maxima 5.24.0 http://maxima.sourceforge.net
> using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (a.k.a. GCL)
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) u : 1.2 $
> (%i2) m : 0.5 $
> (%i3) jacobi_sn (u, m);
> (%o3) 0.88771548861928
> (%i4) jacobi_sn (u + 2 * %i * elliptic_kc (1 - m), m);
> (%o4) 0.88771548861928 - 1.7301614091485549E-15 %i

I get (maxima 5.26) 0.88771548861928 - 1.7919528880467195e-15 %i


> Either that was a regression specifric to maxima 5.26, or this problem is
> particular
> to the sage interface to maxima. Original problem:
>
> 0 jan@muizenberg:/var/autofs/misc/home/jan$sage
> ----------------------------------------------------------------------
> | Sage Version 5.4, Release Date: 2012-11-09 |
> | Type "notebook()" for the browser-based notebook interface. |
> | Type "help()" for help. |
> ----------------------------------------------------------------------
> sage: u=1.2
> sage: m=0.5
> sage: jacobi('sn',u,m)
> 0.887715488619
> sage: jacobi('sn',u+2*I*elliptic_kc(1-m),m)
> jacobi_sn(1.2 + 3.7081493546*I, 0.500000000000000)
> sage: n(jacobi('sn',u+2*I*elliptic_kc(1-m),m))

With sage-5.0-beta2, the above is duplicated, except that the last line has been going (and going, and ...) for several minutes now, with no signs of abating. It's adding small increments of memory, second by second...

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
-----------
Like the ski resort full of girls hunting for husbands
and husbands hunting for girls, the situation is not
as symmetrical as it might seem.
- Alan MacKay
--

Jan Groenewald

unread,
Nov 20, 2012, 3:21:49 AM11/20/12
to sage-s...@googlegroups.com
Hi

I can also do this (Note the only change I -> %i):

sage: maxima("jacobi_sn(1.2 + 3.7081493546*I, 0.500000000000000)")
jacobi_sn(3.7081493546*I+1.2,0.5)
sage: maxima("jacobi_sn(1.2 + 3.7081493546*%i, 0.500000000000000)")
.8877154886192803-9.851415480779732e-13*%i
sage:

Regards,
Jan






--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To post to this group, send email to sage-s...@googlegroups.com.
To unsubscribe from this group, send email to sage-support...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Burcin Erocal

unread,
Nov 20, 2012, 3:25:21 AM11/20/12
to sage-s...@googlegroups.com
On Mon, 19 Nov 2012 23:25:34 -0800
"Justin C. Walker" <jus...@mac.com> wrote:

>
Numerical evaluation for this function is done by the _evalf_()
function defined on line 489 of sage/functions/special.py. The last
line of that function is:

return parent(maxima("%s, numer"%self._maxima_init_evaled_(*args)))

Here is what happens:

sage: maxima("jacobi_sn(1.2000000000000000 + 3.7081493546027438*I,
0.50000000000000000), numer")
jacobi_sn(3.7081493546027438*I+1.2,0.5)


Trying to convert this to an element of RR, or whatever the chosen
parent for the numerical evaluation is, calls this function again.

The problem is with the conversion of the argument to maxima in the
_maxima_init_evaled_ function. I will open a ticket and try to provide
a patch today. Gotta run now.


Cheers,
Burcin

Burcin Erocal

unread,
Nov 20, 2012, 5:30:56 AM11/20/12
to sage-s...@googlegroups.com
Apparently, this was #7557 all along. I uploaded a patch. Please review.

http://trac.sagemath.org/sage_trac/ticket/7557


Cheers,
Burcin

Justin C. Walker

unread,
Nov 20, 2012, 3:02:54 PM11/20/12
to sage-s...@googlegroups.com
A quick follow-up:

On Nov 19, 2012, at 23:25 , Justin C. Walker wrote:
> On Nov 19, 2012, at 22:36 , Jan Groenewald wrote:
[snip]
> Using Mac OS X, 10.6.8. Sage 4.8 has maxima 5.23 (maxima-5.23.2.p3.spkg); 5.0-beta2 has maxima 5.26.
[snip]
>
>> sage: n(jacobi('sn',u+2*I*elliptic_kc(1-m),m))
>
> With sage-5.0-beta2, the above is duplicated, except that the last line has been going (and going, and ...) for several minutes now, with no signs of abating. It's adding small increments of memory, second by second...

This blew chunks, after a fairly long delay, as follows:

Traceback (most recent call last):
File "<ipython console>", line 1, in <module>
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/misc/functional.py", line 1275, in numerical_approx
return x._numerical_approx(prec)
File "expression.pyx", line 4082, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:18084)
File "expression.pyx", line 841, in sage.symbolic.expression.Expression._convert (sage/symbolic/expression.cpp:5122)
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/functions/special.py", line 510, in _evalf_
return parent(maxima("%s, numer"%self._maxima_init_evaled_(*args)))
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/rings/complex_field.py", line 277, in __call__
return Parent.__call__(self, x)
File "parent.pyx", line 1058, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7886)
File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3344)
File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3247)
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/rings/complex_field.py", line 305, in _element_constructor_
return x._complex_mpfr_field_( self )
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/interfaces/maxima_abstract.py", line 1291, in _complex_mpfr_field_
return C(self._sage_())
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/rings/complex_field.py", line 277, in __call__
return Parent.__call__(self, x)
File "parent.pyx", line 1058, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7886)
File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3344)
File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3247)
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/rings/complex_field.py", line 305, in _element_constructor_
return x._complex_mpfr_field_( self )
File "expression.pyx", line 933, in sage.symbolic.expression.Expression._complex_mpfr_field_ (sage/symbolic/expression.cpp:5556)
File "expression.pyx", line 792, in sage.symbolic.expression.Expression._eval_self (sage/symbolic/expression.cpp:4969)
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/functions/special.py", line 510, in _evalf_
return parent(maxima("%s, numer"%self._maxima_init_evaled_(*args)))
File "lazy_import.pyx", line 199, in sage.misc.lazy_import.LazyImport.__call__ (sage/misc/lazy_import.c:1509)
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 198, in __call__
return cls(self, x, name=name)
File "/Users/Sage/sage-5.0.beta2/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 625, in __init__
raise TypeError, x
TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the memory limits before executing the program again.

Justin

--
Justin C. Walker, Curmudgeon-at-Large
() The ASCII Ribbon Campaign
/\ Help Cure HTML Email



Reply all
Reply to author
Forward
0 new messages