OS/2 is a natural home for multithreading Mathematica 2.2
Doug Tamasanis
Mathematica has become an indispensable software tool for quantitative analysis. That's partly because it so effectively joins sophisticated computational and graphical capabilities under one roof, making it easier to visualize and predict the behavior of complex systems. With Mathematica's interpreted programming language, R&D, engineering, and business professionals can quickly work out solutions to highly customized problems that don't warrant the time commitment needed to develop simulations using C or FORTRAN.
Wolfram Research has ported Mathematica from its Macintosh origins to a wide range of platforms, including PCs (MS-DOS, Windows, and Windows NT), Unix workstations (Sun Solaris, SGI IRIS, and IBM AIX), and several larger syste
ms. The latest port of Mathematica 2.2 is to OS/2 Warp. Now OS/2 users don't have to rely on the Windows version of the Mathematica kernel, which only simulates multithreading. The new release takes full advantage of the OS/2 preemptive scheduler, threading, and 32-bit flat memory structure to both improve performance and to greatly increase the size of the problems Mathematica can handle. We found the OS/2 version indeed faster than the Windows version and also more stable.
The OS/2 port still relies on the Windows graphical front end, however, which is fine. Mathematica's standard user interface is a command-line interface. Type in a Mathematica command, and it prints or displays the result. The Windows graphical front end is to the command-line interface what a word processor is to a line editor--a much easier way to achieve the same result. The Windows front end attaches to the OS/2 kernel using MathLink, Mathematica's communications protocol.
Unfortunately, the OS/2 version of MathLink wasn
't out of beta when we tested the product, though it should be now. We couldn't link the graphical front end directly to the OS/2 kernel. For convenience, we developed our models to test OS/2 kernel performance with the Windows version of Mathematica, a somewhat less direct version of how you will use the product anyway. Wolfram Research will provide a free upgrade including OS/2 MathLink and the Windows front end.
No Pencil, No Paper
For such a powerful program, Mathematica's user interface (both command line and graphical) has surprisingly few elements cluttering up the main window. The interface is a little clunky because of Mathematica's client/server architecture. You type in a command, and the kernel interprets it and then opens one or more output cells containing numerical, symbolic, or graphical output, and any error messages.
For complex projects, Mathematica lets you create document files called
notebooks
, which can contain any mixture of text, graphic
s, and Mathematica input and output. Within a notebook, information resides in cells that you can move or copy within or between notebooks. With the Windows front end, you can also nest cells to create neat hierarchical structures, a great help in managing large reports with complex analyses. Brackets in the right margin indicate cells and their place in the hierarchy (
see the screen
). As with an outline processor, you can hide the contents of a group of cells by double-clicking on the grouping brackets in the right margin, collapsing several layers of work so that only the contents of the head cell are visible.
Mathematica's capabilities fall into three main classes--numerical, symbolic, and graphical--but there are other features that add to its richness. If your computer is sound capable, for example, you can express wave forms as sounds to gain insights that are visually hard to discriminate. Mathematica also has a control language for running external programs and processes, an
d it can serve as an embedded system that other programs can call.
At its basic level, Mathematica functions much like a calculator, returning an answer when you type in a calculation. However, the sheer number of available functions (over 800) beats any calculator and rivals the math libraries available for such programming languages as FORTRAN and C. There are functions for statistical analysis, Fourier analysis, numerical integration, and many other processes. Additionally, Mathematica handles objects such as matrices, performing matrix inversion and eigen systems.
On the symbolic front, Mathematica manipulates algebraic formulas. The program is handy for checking calculations involving factoring, expanding, and simplifying polynomials and for solving systems of equations. Mathematica can also check derivations involving derivatives and integrals and find solutions to ordinary differential equations. It is particularly useful in deriving power series approximations and limits (and quicker tha
n thumbing through your favorite mathematical standards and tables books).
Mathematica's outstanding graphics capabilities let you produce 2-D and 3-D plots, contour plots, and density plots. You can embed keywords in the plotting calls to control shading, color, lighting, viewpoints, and other parameters. For demonstrating time-dependent functions, Mathematica can produce animated graphics. Mathematica generates all graphics in standard PostScript format, making it easy to transfer output to other programs.
Creating Functions
Because Mathematica is based on an interpreted programming language, it has great power and flexibility. You can add an unlimited number of extensions to an already impressive list of functions. It's also far quicker and simpler than using FORTRAN or C with such external math libraries as IMSL or AMOSLIB.
Mathematica stores less frequently used functions in files called packages (e.g., Calculus, Graphic, and Number Theory) that you load as n
eeded. You can load individual functions or an entire package.
An added prize is MathSource, a library of programs that you can download free of charge. MathSource includes 1700 items developed by Mathematica users and Wolfram Research: function packages, notebooks, research papers, examples, and programs written in Mathematica. Items of interest available in MathSource include a signal-processing package, neural network analysis routines, microeconomics analysis routines, a symbolic control system analysis package, and a 2-D animation of Schroedinger's equation. A CD version of MathSource ($45) contains all files available on-line.
Once Wolfram Research provides MathLink communications protocol support for the OS/2 Mathematica, you'll be able to access Mathematica remotely over TCP/IP and use the Windows front end. The OS/2 version of the MathLink libraries will let you integrate Mathematica with programs written in C and FORTRAN. Also available are MathLink extensions for other applications (s
ome free from MathSource, some not) that allow exchange of data and expressions between a Mathematica kernel and other applications. Because of the newness of Mathematica for OS/2, however, there isn't the same selection as with other versions.
Version Variance
We compared performance between the Windows and OS/2 Warp versions of Mathematica 2.2 on a 90-MHz Pentium with 16 MB of RAM and a 1-GB hard drive. We used several common functions, some exotic functions, and several complex Mathematica programs downloaded from the MathSource repository. In particular, testing consisted of calculating and plotting special functions (e.g., Bessel, gamma, and zeta); loading and manipulating large (200 by 200) and small (10 by 10) matrices; performing signal analysis and Fourier transforms; and executing several large programs (icosahedral sphere, five octahedra inscribed, and other exotic and common programs). We performed and timed all calculations with the Windows and OS/2 versions of Mat
hematica, and we also ran the Windows version under OS/2's Win32 emulation mode.
As expected, the OS/2 Warp version ran faster than the Windows version, although Warp's speed wasn't apparent for many of the codes we tested. A few performed much faster, but on average, we realized only about a 25 percent decrease in execution time with the OS/2 version. For example, the generation of a 65,536-point time-domain noise signal and subsequent transformation into the frequency domain via a Fourier transform took 8 minutes and 29 seconds in the Windows version and only 7 minutes and 54 seconds in the Warp version. The calculation and plotting of Bessel, gamma, and zeta functions had essentially identical results.
When we spawned multiple instances of the same test, execution times for codes running under Windows suffered significant performance degradation relative to the number of processes. The OS/2 version suffered far less performance degradation when multiprocessing. This is an expected result due
to the nature of OS/2 Warp and Windows for WorkGroups.
One Mathematica program that crashed under the Windows version ran successfully with the OS/2 version (the program came from MathSource). The Windows version of Mathematica ran faster overall in Win32 emulation under OS/2 Warp than it did under Windows for Workgroups 3.11. Additionally, the code that crashed under Windows for WorkGroups ran in the Win32 emulation mode under Warp. OS/2 is impressive.
Calculating the Sum
Laudably, Wolfram Research discusses Mathematica's limitations frankly in the manual with the intent of helping the user solve a problem. During testing, for example, we got a wrong result from a numerical integration calculation of a function with a singularity. Mathematica issued a warning that there was an error involving a singularity, oscillatory integrand, or insufficient precision. Apparently, the integration scheme can only search for singularities at the end points of the integration region, a
nd the presence of other singularities results in reporting erroneous data. The manual, however, contained a detailed discussion of the algorithm, and when we explicitly identified the location of the singularity and restarted the program, we got the correct results.
Mathematica is a superior tool for analysis of complex systems. The OS/2 Warp version of Mathematica 2.2 proved itself stable and fast. Although Warp's 25 percent overall performance gain over Windows isn't tremendously significant, it is welcome. If you need high-level programming for quick development, a large repository of application programs, numerical and symbolic manipulation, compatibility with C and FORTRAN, and visualization tools all in one package, Mathematica for OS/2 is a good choice.
PRODUCT INFORMATION
Mathematica 2.2 for OS/2 $995
Wolfram Research, Inc.
Champaign, IL
(800) 441-6284
(217) 398-0700
fax: (217) 398-07
47
E-mail:
info@wri.com
screen_link (102 Kbytes)
The new OS/2 kernel for Mathematica 2.2 still uses the Windows front end shown here. The important part is that the OS/2 kernel runs faster than the Windows kernel. The screen demonstrates Mathematica's notebook document file, a nice feature for packaging complex projects.
Doug Tamasanis is a BYTE senior technical editor with a BS and MS in radiation physics and an MS in systems engineering. You can reach him on BIX as "dtam" or on the Internet at
dtam@bix.com
.