14.11.3 Loading and saving

Mathematica has an excellent InputForm function, which makes saving and loading Mathematica objects possible. The first examples test saving and loading to strings.

sage: x = mathematica(pi/2)
sage: print x
         Pi
         --
         2
sage: loads(dumps(x)) == x
True
sage: n = x.N(50)
sage: print n
              1.5707963267948966192313216916397514420985846996876
sage: loads(dumps(n)) == n
True

OTHER Examples:

sage: def math_bessel_K(nu,x):
...       return mathematica(nu).BesselK(x).N(20).sage()
...
sage: math_bessel_K(2,I)
0.180489972066962*I - 2.592886175491197

Author Log:

Module-level Functions

clean_output( s)

mathematica_console( [readline=True])

reduce_load( X)

Class: Mathematica

class Mathematica
Interface to the Mathematica interpreter.
Mathematica( self, [maxread=100], [script_subdirectory=], [logfile=None], [server=None], [server_tmpdir=None])

Functions: chdir,$ \,$ console,$ \,$ eval,$ \,$ function_call,$ \,$ get,$ \,$ help,$ \,$ set,$ \,$ trait_names

chdir( self, dir)

Change Mathematica's current working directory.

sage: mathematica.chdir('/')          # optional
sage: mathematica('Directory[]')      # optional
"/"

get( self, var, [ascii_art=False])

Get the value of the variable var.

Author Log:

set( self, var, value)

Set the variable var to the given value.

Special Functions: __init__,$ \,$ _assign_symbol,$ \,$ _equality_symbol,$ \,$ _eval_line,$ \,$ _false_symbol,$ \,$ _install_hints,$ \,$ _keyboard_interrupt,$ \,$ _left_list_delim,$ \,$ _object_class,$ \,$ _read_in_file_command,$ \,$ _right_list_delim,$ \,$ _true_symbol

_install_hints( self)

Hints for installing mathematica on your computer.

Author: William Stein and Justin Walker (2006-02-12).

Class: MathematicaElement

class MathematicaElement

Functions: show,$ \,$ str

show( self, [filename=None], [ImageSize=600])

Show a mathematica plot in the Sage notebook.

sage: P = mathematica('Plot[Sin[x],{x,-2Pi,4Pi}]')   # optional
sage: show(P)                                        # optional
sage: P.show(ImageSize=800)                          # optional

Special Functions: __cmp__,$ \,$ __float__,$ \,$ __getitem__,$ \,$ __reduce__,$ \,$ __repr__,$ \,$ __str__,$ \,$ _latex_,$ \,$ _reduce

Class: MathematicaFunction

class MathematicaFunction

Special Functions: _sage_doc_

Class: MathematicaFunctionElement

class MathematicaFunctionElement

Special Functions: _sage_doc_

See About this document... for information on suggesting changes.