University of Southern California

ITS Information Technology Services

A division of the Office of the Chief Information Officer

Using Mathematica for UNIX

Starting in batch mode

The following is the method to run Mathematica as a batch job:

math -batchinput -batchoutputm < infile > outfile

( Here please note < , > )

Documentation and Help

There is a man page available for Mathematica. To read the manual page type:

man math

Mathematica does not provide help within the math command. There is a command called mathbook which will allow you to access a Mathematica reference of available functions.

Inside Mathematica you can use the following three methods to get information on functions.

?function Gives a brief description of the function
function Gives a extended description of the function
?Ab* Shows all functions starting with "Ab"
?* Shows all functions

Helpful Hints when using Mathematica

  1. Arguments to functions are given in square brackets.
  2. The first letter of build in functions are upper case
  3. Multiplication can also be represented by spaces.
  4. Powers are denoted by ^.
  5. Complex numbers
      x + Iy => The complex number (x+iy)
      Re[z], Im[z], Conjugate[z], Abs[z], Arg[z]
  6. Using previous results
      % => The last generated results
      %% => Next to last
      %n => The result of the n-th line
  7. Manipulating Variables
      x = value, x = y = value,
      x = . or Clear[x]
      x y means xy
      x^2y means (x^2)y not x^(2y)
  8. List:
    When you collect together a bunch of entries and treat them as a single entry, then it's named as a list.
      Ex: ln[1] := {3, 5, 1}
      Accessing or Manipulating a single elemnet
      Part[list,i], or list[[i]]

Algebraic Equations

Mathematica has the ability to handle both numeric and symbolic calculations. This allows users to enter algebraic formulas. This has the added advantage of being able to enter the values as they are read, and be able to evaluate results for different values.

Replacing variables with values

Some important functions to manipulate equations

More Important Functions

Derivatives

Intergration

Intergrate

Sums & Products

Solving Equations

Creating functions

Just as mathematica has built-in fuctions, users can also create their own functions.
The three transformation rules shown below transforms the expression differently.

Vectors and Matrices


Lists and lists of lists are used in mathematica to represent vectors and matrixes.

Useful functions

Graphics

Unlike some other programs, Mathematica allows it's users to plot actual algebraic functions. One can do 2-d and 3-d plots with a cutomized view port. Also, users have the freedom to change the settings in graphs to customize them accordingly.

Ploting functions (2-D)
Important options
Ploting functions (3-D)
Important Options
Ploting lists of Data

Mathematica External interface
    << name: Reads in a plaintext file.

    expr >> name: Outputs 'expr' to a file as plaintext.

    expr >>> name: DAappend 'expr' to file.

    !!name: Display content of plain text file.

    Save: Save[" name", f,g,...] save definition for variable


    Dump: In systems such as unix, one has the ability to save the complete state of mathematica.

    Dump[" namefile"]

    math -x < filename> to start from dump file.

    NOTE:

    1. Dump creates a huge binary file, therefore one may run out of quota, when trying to run Dump command
    2. For more information on generation of c,fortqran code, Tex input or spicing files please refer to page 182 through page 186 of Mathematica book.

Last updated:
February 04, 2011

Mathematica Documentation

The use of all USC computing resources is governed by the USC Computing Policies.