Description of the Xmath/Mathematica Interface
______________________________________________
This Readme file is valid for the preliminary version that is available from
MathSource. To install the interface, copy the 3 files - "makefile",
"xmathlink.c" and this "Readme" file to your directory, edit the makefile to
point to the correct locations of your Xmath, Mathematica & C-Compiler,
and run the makefile. This should create a file "math.lnx". From now on, from
within Xmath, you should be able to invoke the "math" function.
Please report all problems to sanjay@isi.com
Overview
________
Xmath was developed with a very open architecture, which makes it
straightforward to interface or communicate with other programs and
processes. This openness is evidenced by the interface between Xmath
and Mathematica, which uses the Xmath LNX (LiNked eXternal) facility.
Mathematica is a powerful symbolic manipulation program from Wolfram Research,
Inc. (WRI). It allows the user to perform operations such as differentiation
and integration symbolically, to achieve exact general solutions to many
problems. This capability, coupled with Xmath's powerful numerical
analysis and design capabilities, make a very strong joint analysis tool.
The interface from Xmath to Mathematica was developed by WRI, and debugged
and tested with ISI's help. It allows an Xmath user to enter Mathematica
commands and automatically invoke a separate Mathematica process that then
computes and returns a result to Xmath. It also allows the transfer of
matrices to and from Mathematica from within Xmath.
All Mathematica warnings and other textual output is transmitted to Xmath
and displayed in the Xmath message window.
The interface uses the Mathematica Mathlink facility. This allows it to
establish a process running Mathematica the first time it is invoked, and
to maintain a link to that process for all subsequent call from the same
Xmath session, thereby allowing the use of intermediate variables in
Mathematica. Furthermore, the Mathlink facility allows Mathematica to be
invoked on a different computer than Xmath is running on, completely
transparently to the user.
Syntax
------
The syntax of the supported Xmath to Mathematica interface commands is shown
below:
1) sending a command to Mathematica
math("any valid Mathematica command")
2) transfering a matrix from Xmath to Mathematica
math("X2math", "name_in_Mathematica", matrix_in_Xmath)
3) transfering a matrix from Mathematica to Xmath
Xmath_result = math("math2X", "name_in_Mathematica")
4) closing a Mathematica session
math("quit")
Examples
--------
Figure 1 shows part of an Xmath session in which the user is interacting with
Mathematica.
The following is a diary of the Xmath commands and Mathematica responses
for the complete session.
math("$Version")
ans (a string) = SPARC 2.2 (February 5, 1994)
math("N[EulerGamma,40]")
ans (a string) = 0.5772156649015328606065120900824024310422
math("X2math", "hilly", hilbert(8))
ans (a string) = hilly
math("{Dimensions[hilly], Det[hilly]}")
ans (a string) =
-33
{{8, 8}, 2.73705 10 }
math("exactHilly = Table[1/(i+j-1), {i,20}, {j,20}];")
ans (a string) = Null
math("Det[exactHilly]")
ans (a string) = 1 / 23774547167685345090916442434276164401754198377534864930331853312\
> 3441975931064458518758576681657377344056575986726555897176563841\
> 9710793303386582324149811241023554489166154717809635257797836800\
> 000000000000000000000000000000000
math("N[Det[exactHilly],40]")
ans (a string) =
-226
4.206178956624722655882045573396941339798 10
math("invHilly=Inverse[hilly];")
ans (a string) = Null
result = math("math2X", "invHilly")
result (a square matrix) =
64 -2016 20160 -92400 221760 -288288 192192 -51480
-2016 84672 -952560 4.65696e+06 -1.16424e+07 1.55676e+07 -1.05946e+07 2.88288e+06
20160 -952560 1.14307e+07 -5.8212e+07 1.49688e+08 -2.04324e+08 1.41261e+08 -3.89189e+07
-92400 4.65696e+06 -5.8212e+07 3.0492e+08 -8.00415e+08 1.10991e+09 -7.76936e+08 2.16216e+08
221760 -1.16424e+07 1.49688e+08 -8.00415e+08 2.13444e+09 -2.99675e+09 2.11892e+09 -5.94594e+08
-288288 1.55676e+07 -2.04324e+08 1.10991e+09 -2.99675e+09 4.24994e+09 -3.03005e+09 8.56216e+08
192192 -1.05946e+07 1.41261e+08 -7.76936e+08 2.11892e+09 -3.03005e+09 2.17542e+09 -6.18378e+08
-51480 2.88288e+06 -3.89189e+07 2.16216e+08 -5.94594e+08 8.56216e+08 -6.18378e+08 1.76679e+08
math("quit")