hide random home http://www.dap.csiro.au/localguide/mathematica.html (Einblicke ins Internet, 10/1995)

Mathematica -- Local Guide Next: Splus Prev: Mathematics Up: Mathematics Top: Top

7.1. Mathematica

You probably spend a great deal of time performing mathematical calculations and manipulations by hand. Many of these calculations can be handled by Mathematica.

As computer power and memory have increased, so has the capacity of software developers to write programs that assist people with time-consuming tasks. Mathematica is such a program. It works on problems that are impractical to do by hand, freeing your time for your own work. Mathematica is a useful tool for those who do quantitative analysis, symbolic calculations and manipulations, as well as for those who want to visualise functions or data. With it you can calculate, model, prototype and analyse results.

Mathematica performs three basic types of computation: numerical, symbolic, and graphical. It works with numbers of arbitrary magnitude and precision, as well as with polynomials, power series expansions, matrices, and graphs. Mathematica provides standard symbolic operations of algebra and calculus, including integration and differentiation. It can also plot functions and data in two or three dimensions.

Mathematica is an interpreted language---it reads an expression, evaluates the result, and then prints it out. Being interactive makes it easier to use than compiled languages such as C, FORTRAN, or Pascal.

Mathematica was designed to be extensible by including its own programming language. It is flexible and extremely useful software for anyone who regularly performs complicated mathematical computations.

Using Mathematica is like having a conversation. Ask a question and Mathematica responds with a result. Mathematica assigns a number in sequence for each input output pair or exchange. The nth user input in a Mathematica session is labelled In[n] and the corresponding computer output is labelled Out[n]. You can refer to earlier inputs and output with these labels.

Mathematica is started with the command math (or mathematica for X terminal users) entered at the Unix prompt. In the following `conversation' we ask Mathematica for the value of 5 to the power of 10 .

The number assigned to an `exchange' can be used to reference any previous result. You can check the result by taking the 10th root of the result, Out[1], which is abbreviated %1.

You most commonly wants to refer to your most recent result. The character % refers to the previous result. In the following example, % is replaced by the last result computed, i.e., 5.

You can refer to a previous result by using one or more percent signs; that is, % refers to the last result, %% refers to the second to last result and so on. You can refer to a particular result with %n, where n is the number of the output line.

If you assign a name to a result, you can later reference that result with the assigned name. The command boatLength = 3 causes the interpreter to associate the value 3 with the name boatLength.

Once the name boatLength has been defined to be the number 3, you can refer to the value 3 by name.

You can also perform operations by using the name or variable.

To exit Mathematica type ctrl-d.

The above examples show the interface when using a character based terminal. Users with X terminals have access to an interactive graphical interface. To use this interface type the command mathematica at the Unix prompt. A tutorial document on using this interface is available from the computing section.

As an alternative, Mathematica can be run from the editor Emacs. (See Emacs.) A special `mode' of the editor is available for this purpose where editing and execution of expressions occur `seamlessly'.

The library has reference material and tutorials on Mathematica.

Hard copy graphics output

First method:

To save a graphics plot in a file and to produce hard-copy, use something similar to this sequence:

The last line in the above example uses a ! to escape temporarily to Unix to do the required psfix on the file myfile and printing commands.

The raw graphics in myfile can printed out anytime when at the Unix prompt by the command,

If you do not specify a graphics object such as `myplot' in the above example, use the symbol % in line 3 above,

If you want to produce a PostScript file that can be imported into text formatting packages such as LaTeX @LaTeX{} or WP it needs to be `psfixed':

Second method:

To produce hard-copy directly---

Before starting Mathematica type,

then start Mathematica and proceed:

This will print out the graphic on the designated printer.

To save typing `setenv PRINTER 4' each time before you start Mathematica, you can enter the line into your `.cshrc' file. This file is read on login.