Skip to content

CC() fails on Mathematica output #4325

@dandrake

Description

@dandrake

Using 3.1.2 on sage.math:

sage: mathematica.eval('N[BesselK[1+I, 2+ 3*I], 20]')
         -0.105203133241753451256 + 0.017589014615189905553 I

Now say I want to get a CC element out of that:

sage: CC(mathematica.eval('N[BesselK[1+I, 2+ 3*I], 20]'))
------------------------------------------------------------
   File "<string>", line 1
     -RealNumber('0.105203133241753451256')+RealNumber('0.017589014615189905553')I
                                                                                 ^
SyntaxError: unexpected EOF while parsing

It's confused because Mathematica uses a space between the number and I; a workaround is to put in an asterisk:

sage: CC(mathematica.eval('N[BesselK[1+I, 2+ 3*I], 20]').replace(' I', '*I'))
-0.105203133241753 + 0.0175890146151899*I

I understand that this kind of parsing can get difficult and complicated, but it seems like something we should aim for.

Component: interfaces

Keywords: mathematica

Issue created by migration from https://trac.sagemath.org/ticket/4325

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions