#4325: CC() fails on Mathematica output
-------------------------+--------------------------------------------------
Reporter: ddrake | Owner: was
Type: defect | Status: new
Priority: major | Milestone: sage-3.2
Component: interfaces | Resolution:
Keywords: mathematica |
-------------------------+--------------------------------------------------
Comment (by jason):
In Mathematica, we can set the output to automatically be wrapped in a
certain function. We ought to just write a function that first calls
InputForm.
{{{
sage: CC(mathematica.eval('N[BesselK[1+I, 2+ 3*I],
20]//InputForm[#,NumberMarks->False]&'))
-0.105203133241753 + 0.0175890146151899*I
sage: CC(mathematica.eval('N[BesselK[I-1, I],
30]//InputForm[#,NumberMarks->False]&'))
-0.190193056011529 - 0.470313413807477*I
}}}
I put the NumberMarks->False option since Sage doesn't know how to deal
with the precision information returned from Mathematica. It would be
nice if there was a way to use that in constructing Sage objects. My
guess is it would be fairly easy in Mathematica to write a function that
generates Sage output, given that you easily have access to the full parse
tree of the function in Mathematica.
Another way to get rid of the precision information is to set $NumberMarks
= False:
{{{
sage: mathematica.eval('$NumberMarks=False')
False
sage: CC(mathematica.eval('N[BesselK[I-1, I],
30]//InputForm'))-0.190193056011529 - 0.470313413807477*I
}}}
We can automatically apply the InputForm to any printed output by setting
the $PrePrint hook:
{{{
sage: mathematica.eval('$NumberMarks=False')
False
sage: mathematica.eval('$PrePrint = InputForm')
InputForm
sage: CC(mathematica.eval('N[BesselK[I-1, I], 30]'))
-0.190193056011529 - 0.470313413807477*I
sage: CC(mathematica.eval('N[BesselK[1+I, 2+ 3*I], 20]'))
-0.105203133241753 + 0.0175890146151899*I
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4325#comment:2>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---