On 03/10/2010 12:36 AM, Felix Lawrence wrote:
Hi David,

I haven't looked into these since #3587 rewrote
MathematicaElement._sage_() for mathematica objects, but I did a bit
of work getting the generic ExpectElement._sage_() to work with
mathematica lists.  Mathematica does return different results
depending on whether it's running in 32-bit or 64 bit modes.  This was
on a mac.

Furthermore I recall seeing complex numbers from mathematica commonly
printed with the imaginary part first.  Futhermore for particularly
long outputs from mathematica, it would seemingly randomly intersperse
'\n' new line characters with '\r\n' new line characters, which would
mess up any sage_eval()s.

So don't expect mathematica to give consistent, well-behaved output!

BTW
sage: def math_bessel_K(nu,x):
      ...       return mathematica(nu).BesselK(x).N(20).sage()
      ...
      sage: math_bessel_K(2,I)

now gives me an error: NotImplementedError: Unable to parse
Mathematica output:
-2.5928861754911969781676606702635284285719718407749199115289`20.149465350282203
+

0.1804899720669620266296208808560650432663536549483055754141`18.99213497581376*i

Does this work on anyone else's machine?  I think #3587 may be
responsible for the breakage.  I'll look into this.



I'm probably missing something here, but I'm curious why we are not just converting Mathematica output to FullForm and parsing that, which would make the output much more consistent. For example:

In[3]:= -2.5928861754911969781676606702635284285719718407749199115289`20.149465350282203+0.1804899720669620266296208808560650432663536549483055754141`18.99213497581376*I//FullForm

Out[3]//FullForm=

>   Complex[-2.59288617549119697816766067026352842857217277043626160947\

> 21`20.149465350282203, 0.18048997206696202662962088085606504326635365\

>      49483055754141`18.99213497581376]

Parsing Complex[real_part, imaginary_part] seems much easier than trying to guess what comes first, etc. I guess I'm commenting on the strategy in #3587 (though it admits that it uses a super-simple strategy).

Thanks,

Jason

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to