OR/MS Today - October 2007

Software Review

Mathematica 6

'Major' upgrade to popular computational system includes many new features and enhanced ease of use.

By ManMohan S. Sodhi

In the December 2003 issue of OR/MS Today, I reviewed Mathematica 5 from an operations research professional's viewpoint [1]. I wrote how version 5 is compelling for O.R. professionals who may have been intrigued by Mathematica software in the past but did not consider it useful for their profession over the numerical and statistical packages they already use. Version 5 introduced advanced numerical analysis, linear programming — interior point as well as simplex method variants — and sparse matrix manipulation with fast algorithms that compete with dedicated numerical software tools.

In the December 2004 issue, I reviewed Version 5.1 that had a long list of enhancements for numerical computation, symbolic computation, language system, etc [2]. I focused on the added Internet, GUI and data handling features. The GUIKit allowed a user to create a GUI running on top of Mathematica for other users to do specific things. Mathematica 5.1 gave access to Web services offered by other providers (e.g., Amazon) as a Mathematica function. It also allowed better access to spreadsheets (MS Excel) and databases.

Now we have a major upgrade 6.0 (or more specifically, that I tested on Windows XP; it is available for 32-bit and 64-bit versions of Windows variants up to Vista, MacOS 10.4 (Intel and PPC), Linux and various Unix flavors. When I say "major," I really mean that. Installation for 6.0 takes much longer than it did for 5.1 — as you quickly find out when you start installing, because the program and the accompanying files are much bigger as is the functionality. The benefit is not only a lot more functionality but also an increase in the ease of use of many of the features introduced in 5.1, for instance by making some GUIs and getting some kinds of financial data transparent without you having to explicitly invoke Web services. Not all functions in notebooks you created will work without modification — in fact, Mathematica 6 analyzes any notebook file created by older versions when you try to open to diagnose which function calls need to be modified.

The new features are too many to list. I would recommend going to the Wolfram Web site to check these out (www.wolfram.com/products/mathematica/newin6/). Pay special attention to the following new features for operations research professionals: combinatorial optimization, constrained nonlinear optimization, exploratory data analysis, symbolic statistical computing and extended array operations.

My review does not cover these; instead it intends to provide a feel of the new version as distinct from its worthy predecessor.

Documentation Center. The first thing to notice is "help" has been replaced by the "Documentation Center." As with Web search engines, you now get multiple results for any query you have rather than, as before, having to search among different sources, patterned after the folder structure in NeXT computers (remember those!).

Manipulate to Explore. A rather neat feature is a GUI call whereby you can put parameters for a plot in slider bars and just play with these slider bars to see how the plot changes. It is amazing how easily this can be done — all it takes is a single function call — and how wonderful it can be for teaching purpose or for building intuition.

Consider this example. You want to show students how three different two-parameter probability distributions change as you change the two parameters. To vary the two parameters continuously using slider bars, all you need is the following Manipulate call around the usual Plot call that draws the probability distribution. Here we have three parameters for the Manipulate call: the first parameter m, the second parameters s and the distribution itself — Normal, Gamma and LogNormal. Figure 1 shows the output: For the continuously varying parameters (2 to 4 for the first parameter and 0.0001 to 2 for the second), we get slider bars and for the third discrete parameter, i.e., the type of distribution, we get tabs.


Operations Research / Management Science Today

Figure 1: Slider bars and tabs as a result of the Manipulate call to view different probability distributions.

Data Visualization. One new thing is color schemes such as "PlumColors," "RoseColors," "SolarColors," "SouthwestColors," "StarryNightColors," "SunsetColors" and "ThermometerColors." Rather than choose every color in a multi-color graph, why not choose only a color scheme?

Consider the following contour plot of z = x + y*y using the following call:

ContourPlot[x + y^2, {x, -3, 3}, {y, -2, 2}, ColorFunction -> "PlumColors", ContourLabels -> True]

This produces the results in Figure 2 and if you replace PlumColors by the ThermometerColors scheme, you get Figure 3.

Operations Research / Management Science Today

Figure 2: Contour plot of function x+y^2 using PlumColors.

Operations Research / Management Science Today

Figure 3: Contour plot of x+y^2 using ThermometerColors.

Data Sets. One feature that stands out, something that business school researchers may appreciate even more than their science colleagues, is access to various kinds of data. The data resides on data servers at Wolfram Research so you have to be connected to the Internet for access. For instance, you can get Microsoft's closing stock prices from Jan. 1, 2004 simply by invoking Financial Data with the parameters "MSFT" and "Jan. 1, 2004." Then plot it as follows to obtain the graph in Figure 4 (note also that Mathematica 6 allows you to notate the graph as illustrated in Figure 4):

"Jan. 1, 2001"],Joined→True]

Operations Research / Management Science Today

Figure 4: Microsoft share prices since Jan. 1, 2001 as obtained and plotted within Mathematica 6. Freehand tools allow notation.

Your science colleagues will get more data as there are data on quite a few properties of different chemicals. You could look for the list of all chemicals in the dataset that begin with "Kryp," invoking:


gives you a list ("Kryptopyrrole,", "Kryptocyanine," "Krypton") but not Kryptonite for Superman fans. (Although Krypton is an inert gas, it can form certain compounds that are stable at very low temperatures.) Data residing on Wolfram's data server means they can keep these datasets current. Searches can also be analyzed to figure out which databases are more useful. Of course, you have to live with the unhappy consequence that any search on the Internet for data with a U.S.-based company at least is subject to U.S. government scrutiny — recall Google having to share its search data — so it would be best to avoid certain kind of chemicals. (Unfortunately, the above three chemicals are suspect from this regard.)

Interestingly, there are text "data sets" as well such as the U.N. Human Rights in many languages including English. Calling ExampleData["Text"] lists various text data sets (these reside on the Wolfram data server) and then you can invoke:

ExampleData[{"Text", "UNHumanRights

to see all 30 articles of human rights in a separate notebook. The software allows you to obtain all the words as separate elements in a list (or vector) so you can count occurrence of words or do other analysis. I did not test these features, but Wolfram's Web site ("what's new in version 6") promises integrated algorithmic functions for string metrics; nearest-neighbor finding and cluster analysis; integrated HTML import; built-in natural language dictionary lookup; and word properties and connections for "sophisticated natural language analysis."

Linear Programming and the Constraint Matrix. Linear programming now has integer programming. As with 5.1, you can call up MPS format files and several MPS datasets for testing can be found by invoking:


A number of NETLIB datasets are listed but in my tests, only the afiro data appears to be available on the server (this is the dataset referred to in the software's examples). For this particular data, I was able to import the data, convert to Mathematica's internal (sparse) matrix representation and solve or plot the constraint matrix (Figure 5) to visualize the sparse structure. The documentation center was not very helpful on how to deal with MPS datasets, given that the calls and the procedure have changed since version 5.1.

{c, A, b, d} = Import[ "ExampleData/afiro.mps" , "LinearProgrammingData"];
xopt = LinearProgramming[c, A, b];

where c is a (dense) cost vector, A is a sparse coefficient matrix, b is the (dense) right hand side, and d are the bounds for the primal variables.

Operations Research / Management Science Today

Figure 5: Sparse structure of the coefficient matrix in the LP problem "afiro" using MatrixPlot.

Unlike MatrixPlot, all the elements of an array are checked with ArrayPlot. I invoked it to see all the non-zeros in A (Figure 6):


Operations Research / Management Science Today

Figure 6: Sparse structure of the coefficient matrix using ArrayPlot

I would like to be able to create the linear programming data using the kind of compact and clear notation that AMPL uses so I could avoid MPS format altogether. After all, Mathematica already has much of the notation and access to spreadsheets and databases built-in.

As an aside, linear programming within Mathematica can provide rational results if all the parameters are rational (I would suggest trying this feature only for small problems). Additionally, Mathematica can be asked to use interior point methods that the document centre claims to be faster than the extreme point method. Finally, the documentation centre has a nice example of generating Klee-Minty problems of any size and then solving these.

As regards integer programming, consider the following examples:

LinearProgramming[{1., 1.}, {{5., 2.}}, {3.}, Automatic, Integers]

This gives the integer solution {1,0}.

If only the first variable is integer (and the second as a real number), you can specify the problem as:

LinearProgramming[{1., 1.}, {{5., 2.}}, {3.}, Automatic, {Integers, Reals}]

to get the solution {1, 0.0}. There are new constrained non-linear optimization capabilities as well that I have not tested.

Word Processing and Typesetting. My experience with using Mathematica to create TeX files remains mixed, but my guess is that this aspect of Mathematica will get cleaned up sooner rather than later. You can use File-Save as (instead of File-Save as Special in previous versions) to generate the equivalent AMS-LaTeX file. For a large file, I could not get anywhere. For a small file with a single call, the ContourPlot call earlier, I did get the correct output using TrueTex, but the TeX compiler complained a lot so you will likely have to hand edit generated files before compiling.

I believe that Wolfram is serious about making word processing and typesetting easy to use in Mathematica itself. For one, many of its intended users publish scientific or mathematical articles and moving from Mathematica to LaTeX is still not straightforward. Second, Mathematica had introduced Publicon for publication but that product has been stuck in version 1.0 for a long time, and even with that using LaTeX, it was not as easy as GUI front-ends like MacKichan Software's Scientific Word. Of course, one could question why use LaTeX instead of MathML format, but most journals have a preference for LaTeX. I would be happy if Wolfram were to introduce Publicon's ease of use in future updates of version 6.0 to let me do my wordprocessing within Mathematica — this alone would make it easier for many users to work solely in a Mathematica environment — and then hand edit the generated LaTex files if necessary.

Overall Summary

Mathematica 6.0 is a very impressive upgrade. Many new features are intended to make it the environment of choice for its target users. Of special mention is access to data. I had written in my December 2004 review that version 5.1 is provides more reasons for staying within the Mathematica environment regardless of where the data resides. Version 6 makes a big leap in this direction. Besides the various sources of data — the Web, SQL databases, binary files of various types — you now have the data server at Wolfram Research to give you easy access to many different types of data sets including those for linear programming. True, I was not able to access many of the linear programming data sets listed, but I am sure it is simply a matter of time before the i's are dotted and the t's are crossed after the recent release of 6.0.

As with any other good thing, we always want more. At the top of my wish list for Mathematica 6.x or 7.y are two things: (1) wordprocessing/typesetting to extend the functionality and ease of use in Wolfram's Publicon software, and (2) being able to use the features it already has to create linear programming problems as with languages such as AMPL or OPL. Statistical analysis in Mathematica is already quite advanced, but you need to consider the ease of use of your current statistical package of choice for ease of use. Still, cluster analysis may be easier in Mathematica 6 than in your current package. The documentation center is quite impressive, but it needs to be more helpful regarding new features. [as regards?]

The rewards of using Mathematica 6 are even higher than the already plentiful benefits of earlier versions. However, it requires a large commitment and investment of time.

Product Information

Mathematica 6 is available from Wolfram Research, Inc.
Address: 100 Trade Center Drive, Champaign, IL 61820-7237
Phone: 217-398-0700, 800-WOLFRAM (965-3726) (U.S. and Canada only)
URL: www.wolfram.com

United Kingdom
Wolfram Research Europe Ltd.
10 Blenheim Office Park, Lower Road, Long Hanborough, Oxfordshire, OX29 8RY
Phone: 01993 883400
E-mail: info@wolfram.co.uk

U.S. Commercial Professional including 1-year Premier Service: $2,495
U.S. academic list price including 1-year Premier Service: $1,095
Student Version: $139.95
Semester and annual downloadable student version start from $44.95.
U.K. Commercial Professional, including 1-year Premier Service: 2035
U.K. academic list price, including 1-year Premier Service: 860
Student version: 80
Semester and annual downloadable student version start from 20.

Wolfram offers the Educational Unlimited Program for schools, community colleges and universities. It offers unlimited access to any eligible Wolfram Research products for an annual fee. Benefits include automatic upgrades, free faculty home-use access, multiple student-use options, free webMathematica Amateur and technical support.

Mathematica is as multi-platform as software can get. Wolfram's Web site sells it for a number of 32-bit and 64-bit platforms for Windows (up to Vista), MacOS 10.4 Intel and PowerPC (the latter for 32 bit only), Linux and various flavors of Unix (e.g., HP-UX, Solaris, and IBM AIX).

Vendor Comments

Editor's note: It is the policy of OR/MS Today to allow developers of reviewed software an opportunity to clarify and/or comment on the review article. Following are comments by Jon McLoone, senior developer, Wolfram Research.

We are pleased that Dr. Sodhi recommends the improvements in Mathematica 6. I should point out that the interactive interface building tools do not only apply to making interactive graphics but also allow the for real-time interactive computations or data mining and extend to the creation of entire user interfaces.

These are, for the first time, deployable through the new Mathematica Player application. This is a free download that allows you to use Mathematica powered applications and interactive documents without needing a full Mathematica. See www.wolfram.com/products/player/.

ManMohan S. Sodhi (M.Sodhi@city.ac.uk) heads the Operations Research group at Cass Business School in London.


  1. Sodhi, M., "Mathematica 5," OR/MS Today, December 2003, www.lionhrtpub.com/orms/orms-12-03/frswr.html.
  2. Sodhi, M., "Mathematica 5.1," OR/MS Today, December 2004, www.lionhrtpub.com/orms/orms-12-04/frswr.html.

  • Table of Contents
  • OR/MS Today Home Page

    OR/MS Today copyright 2007 by the Institute for Operations Research and the Management Sciences. All rights reserved.

    Lionheart Publishing, Inc.
    506 Roswell Rd., Suite 220, Marietta, GA 30060 USA
    Phone: 770-431-0867 | Fax: 770-432-6969
    E-mail: lpi@lionhrtpub.com
    URL: http://www.lionhrtpub.com

    Web Site Copyright 2007 by Lionheart Publishing, Inc. All rights reserved.