Stephen Wolframstephenwolfram.com
Publications by Stephen Wolfram * Articles * Technical Computing * Mathematics by Computer (1988)
Mathematics by Computer (1988)


Main Text

I have been involved in a practical problem that is going to have important consequences for the future of physics. This practical problem is the development of a computer program called Mathematica. Mathematica is a comprehensive system for doing mathematical computation. It runs on a variety of computers and does a whole range of mathematics. Mathematica is useful for many kinds of users, ranging from math professors or physics professors to engineers and down to college and even high school students. Our idea in developing Mathematica is to produce a mathematical tool that is as generic as the calculator but provides much broader coverage of mathematics.

The most elementary way to think about Mathematica is as an enhanced calculator---a calculator that does not only numerical computation but also algebraic computation and graphics. Mathematica can function much like a standard calculator: you type in a question, you get back an answer. But Mathematica goes further than an ordinary calculator. You can type in questions that require answers that are longer than a calculator can handle. For example, Mathematica can give you the numerical value of Pi to a hundred decimal places, or the exact result for a numerical calculation as complicated as the result of 3^1000, (see Fig. 1). Mathematica has a big collection of mathematical functions built into it. Even a standard calculator has sines, cosines, and logarithms built in, but Mathematica allows you to ask the value of a function like a Bessel function or the Riemann zeta function to 40 decimal places, (see Fig. 2). Such special functions in mathematical physics are built into Mathematica. In fact, Mathematica has built in virtually all of the functions found in standard handbooks of mathematical functions. Our goal was to make obsolete all the tables of mathematical functions that you find filling up a lot of space in physics libraries.



[ Figure 1 ] Mathematica as a calculator. Pi and 3^1000 to 100 significant digits.




[ Figure 2 ] Numerical results for the Bessel function and the Riemann zeta function .

But Mathematica does much more than numerical computation. Another major kind of computation handled by Mathematica is symbolic algebraic computation. If we type in the algebraic expression (1 + x)^5, at first Mathematica just echoes back the same expression, (see Fig. 3). But we can tell Mathematica to perform various mathematical operations on the expression. For example, we can tell it to expand the expression out, or to factor it. Mathematica will recognize that the expression of that standard form can be reduced back to the original expression. And Mathematica can do much more complicated operations than that. It will remember that an expression that goes on for several screens actually simplifies back down to the original product of a few terms.



[ Figure 3 ] Algebraic expansion and factoring of (x + 
1)^5.

As an example of an algebraic computation, if you try to solve a simple quadratic equation like

x^2 + 2x -1 =0

for x, you will get a symbolic result of the solution of this equation in terms of the symbolic parameter x, (see Fig. 4). If you ask Mathematica to solve an equation like

x^5 + 3x + 1 = 0

for which there is no analytical solution, Mathematica will give you the symbolic representation of the results that cannot be found. In addition, Mathematica can give you the numerical result. Even though it may not be mathematically possible to obtain a result in algebraic form, Mathematica will give you a numerical result in terms of complex numbers, (see Fig. 5).



[ Figure 4 ] Algebraic solution of x^2 + 2x -1 =0.





[ Figure 5 ] Numerical solution of x^5 + 3x + 1 =0.

Another thing Mathematica can do is symbolic integration. Let's start off with a very simple one. If you ask Mathematica to integrate with respect to , i.e. you get the result

But Mathematica is capable of more complicated integrals. If you ask Mathematica to integrate

it will produce an expression involving arc tangents and some logarithms, and so on. We can check the result by asking Mathematica to differentiate. (See Figure 6).



[ Figure 6 ] Analytical solution of and subsequent differentiation of the answer.

In addition to numerical and algebraic calculations, Mathematica is capable of sophisticated graphics. Mathematica does graphics by using a "postscript page description language." This is the kind of graphics control language that's used, for example, by the Apple Laserwriter, and is being increasingly used on many different kinds of computers. Using this language, Mathematica allows you to take a picture and actually see the Postscript form of the picture. This Postscript form lies behind the original picture that Mathematica produced. Postscript is a much more obscure language than Mathematica, but if you know Postscript well enough, you can edit the Postscript that Mathematica actually produced. For example, when you originally plot a curve you can tell Mathematica to make it blue, but by editing the Postscript, you can change the color of the curve to red.

An advantage of Postscript is that it provides a very portable description of the graphics. You can, for example, take a graphical image that you produce in Mathematica and paste it into a document that you're making up with Pagemaker or any other desktop publishing system. The graphics that you produce will be rendered in the highest resolution that's available on the kind of printer that you have.

Mathematica will also allow you to do three-dimensional graphics. You can ask it to plot the Sin(xy) as a function of x and y, with x running from 0 to 3 and y running from 0 to 3. The result is shown in Figure 7. If you want to, you can, for example, ask Mathematica to show you the plot as it would appear if you simulated shining a light onto the surface from one side, (see Figure 8). You can also alter the viewpoint, or display the surface with different parameters.



[ Figure 7 ] A 3-dimensional plot of Sin(xy).




[ Figure 8 ] A 3-dimensional plot of Sin(xy) with simulated illumination.

That's a capsule summary of Mathematica's capabilities in numerical computation, algebraic computation, and graphics. I would like to go on to describe how to program Mathematica, and how to create documents and things like live textbooks that make use of Mathematica.

Mathematica is a rather complete and powerful programming language that allows you to build on top of the large number---about 700---built-in functions. You can build in your own functions for a particular application using any of several different styles of programming. One such style of programming is writing a function in a standard structured programming fashion, as you would in a language like C or Pascal. It's somewhat easier to program in Mathematica than it would be to program directly in C or Pascal because Mathematica is an interactive system. Mathematica allows you to see exactly what your program does as soon as you've typed in pieces of it.

Because Mathematica is a symbolic system you don't have to worry about creating all the kinds of data structures that you might need. Mathematica's general expression data structures will hold anything that you have.

Another style of programming is perhaps more interesting. The idea of this second style is to use transformation rules to take textbook formulas and transcribe them almost directly into Mathematica. This is the way that Mathematica gets taught lots of mathematical information: you just take tables of rules like those for logarithm functions and enter them into Mathematica. Afterward Mathematica will automatically use them.

Another style of programming in Mathematica is to add to Mathematica's knowledge about graphics. For example, to teach Mathematica about polyhedras, you begin by reading definitions of polyhedra into the file. Let's see what happens if we wan t to show a tetrahedron as a three-dimensional graphical object. Mathematica takes the symbolic description of the graphics and actually renders it as a three-dimensional object, (see Figure 9).



[ Figure 9 ] A 3-dimensional plot of a tetrahedron.

If you ask Mathematica to render even more complicated graphical objects, it will follow the same procedure. Say, for example, that you ask Mathematica to show you a stellated dodecahedron. It will take the symbolic description of the dodecahedron, apply the operation of stellation, and then show the results, (see Figure 10). Because Mathematica uses Postscript graphics, you can expand the results to any size you want. In fact, you can even drag it out to eight feet wide, print it out, and glue it together to make a poster.



[ Figure 10 ] A 3-dimensional plot of a stellated dodecahedron.

The Mathematica program is broken into two pieces. The first piece is a kernel that actually does computations. This kernel runs exactly the same on many different kinds of computers. The kernel of Mathematica exists right now for the Macintosh and for work stations that run similar types of graphics---IBM RTs, various kinds of super computers, and other such things. Most of the operations that I've shown you today make use of the kernel of Mathematica. The kernel understands input expressions and produces either output expressions or Postscript graphics.

The second piece of the Mathematica program, the front end of the program, is responsible for interaction with the user. This piece takes advantage of whatever user capabilities exist on a particular kind of computer. It is possible for you to run the front end of the program on a Macintosh, and the kernel on a remote computer. In such a case, the calculations that we've been doing here would look essentially the same. However, we would see the results come back a bit more quickly.

You can use the front end of Mathematica to prepare documents based on Mathematica. You can, for example, make the examples we've illustrated today into a section of a book. When you type in the word "polyhedra," you will find under a menu called "styles" a list of possible styles in which you can show that text. You can type in information about polyhedra to annotate the work that you're doing.

You can also use Mathematica to prepare your own textbooks. On a machine like the Macintosh, you can use the front end of Mathematica as something that acts as a live textbook. You can provide texts to be read on the screen, imbed graphics into that text, and even input commands that can be executed to do computations.

There are a number of efforts underway to write textbooks in the kind of live form that Mathematica makes possible. Such efforts typically accompany a printed textbook with a Mathematica notebook. One of the more ambitious projects along these lines is a calculus book to be published by Addison-Wesley.

One thing you can do in a Mathematica textbook that you can't do in an ordinary textbook is take the formulas in the book, make changes to the examples that are given, and then reevaluate them and see what the results would be. This capability gives you a way to explore what the formula in the book really means.

You can also use Mathematica to produce animation in your textbook. First you tell Mathematica to compute a function that could be a collection of sine curves in two dimensions. Then you tell it to produce a sequence of these pictures. By running through the whole sequence of pictures, you'll produce a sort of animated movie, and after it's read into memory it will run reasonably quickly. The actual code necessary to generate such a sequence of frames is often quite short---only about 20 lines.

In the past we have distributed Mathematica by giving it away, but giving it away in a slightly unusual fashion. Our favorite method is to bundle it with hardware that computer manufacturers produce. We like Mathematica to be included as part of the standard system software that comes with the machine. This is the way we have distributed Mathematica on the NEXT Computer, and Mathematica will also be bundled as part of the standard system software on some other computers that are coming out later this year.

For other machines Mathematica is typically being sold by the hardware manufacturers who produce those machines. Mathematica is also being sold by IBM for the RT and by Sony Graphics.

To find out more about Mathematica, I refer you to my book, Mathematica [1], which provides a complete documentation and description of what Mathematica does.

next