You are here

Constructing Mathlets using JavaMath - Services to Augment a Computer Algebra System

Author(s): 
Alan Cooper, Stephen A. Linton, and Andrew Solomon

Instead of interacting with web pages, it is often preferable to use the familiar interface of our favourite computer algebra system (for instance Maple or GAP) to perform a mathematical computation. This means that the mathematical software developer has to choose between writing a piece of software once making it available in a web page (thus creating a less convenient product), or writing it separately for each computer algebra system in use by the target audience.

With JavaMath there is a "middle road", to wit, one can construct an internet service accessed via a computer algebra system using the HTTP protocol, requiring only a light-weight interface between the computer algebra system and the internet service.

Ralph Freese's LatDraw applet renders a Hasse diagram in 3-space when presented with a file in a special input format. We have used LatDraw as a starting point to create the internet service Hasse. [The project link no longer exists. Contact the authors  for more information. Ed., 12/13/04. ]  In addition to the original functionality, Hasse provides a Web service enabling users of Maple and GAP to visualize Hasse diagrams with a single command. For example, executing the following Maple code, opens a browser window in which the Hasse diagram is displayed.

read("om-lite.mpl");

# a basic hasse diagram
h := [[0,[a,b]],[a,[1]],[b,[1]],[1,[]]];
DrawHasse(h);

One might wonder why this needs to be a web service rather than installing it as a Java application on the client's machine. The answer is twofold. As a web service, it is automatically updated when improvements are made, and due to the use of OpenMath/XML (see below) it would require quite a complicated Java installation on the client machine.

The reason we had to move from using the special file format above to the XML/OpenMath standard is that vertex names generated by a computer algebra system will often fall outside the range of those permissible in the special file format. But then, an XML/OpenMath parsing package is required to deal with the input to the applet. This is both difficult to install (making it infeasible to distribute) and too large to include in an applet's jar.

The solution we were forced to construct appears rather gymnastic, but the steps below are quite straightforward when using JavaMath.

  • client (e.g Maple) displays the Hasse diagram (as OpenMath) in a web page for the user to inspect and assign a name to the diagram;
  • when the user submits the form, the diagram is sent to a servlet on the server. This servlet:
    • generates a cookie, k;
    • interprets the XML/OpenMath into a Java object representing the Hasse diagram;
    • serializes and stores this object on the server in an RMI accessible hash table with key k;
    • generates a page embedding the applet with argument k and returns this to the browser on the client machine.
  • the applet in the client machine then contacts the server to load the java object representing the diagram, as indexed by the cookie k.

The code for this solution may also be inspected at the Sourceforge CVS repository.

Alan Cooper, Stephen A. Linton, and Andrew Solomon, "Constructing Mathlets using JavaMath - Services to Augment a Computer Algebra System," Convergence (December 2004)