A Brief Introduction to Mathematica
There are two types of environments in which the Mathematica application
can be used:
Windows Notebook Interface:
If you are using Mathematica on a Mac, in PC Windows, or the X Windows
System under UNIX, you can start Mathematica by double clicking on the
Mathematica icon. A blank notebook page will be opened into which you
can enter your Mathematica commands. To execute the commands you have
entered, press shift-Enter; if you are using this interface, you should
interpret "enter" in the text which follows as meaning "press
shift-enter". File, Edit, Cell, Graph, Action, Style, Options, Window,
and Help menus are available at the top of the screen to assist you in
performing operations within Mathematica.
Command line interface:
To start Mathematica, enter math at the system prompt. After the
Mathematica kernel loads, the "IN[1]:=" prompt will appear indicating
that Mathematica has started and is waiting for you to enter commands.
SYNTAX
Mathematica is case sensitive (e.g., "a" is different from "A").
Mathematica built-in commands and functions begin with capital letters.
It is recommended that you use all lower case letters for names of
variables and functions you define. Alternatively in graphical
environments, you can use symbols to represent variables in your
Mathematica expressions by selecting the character from the Palettes
submenu of the File menu or by entering a keyboard equivalent of the
symbol, e.g., enter \[Beta] or Esc-b-Esc to obtain the character beta.
Parentheses are used to indicate grouping of terms.
Spaces between numbers or variable names indicate multiplication; other
spaces can be added for readability between numbers, variables, and
functions, but are not required. Use parentheses to specify the order
of calculations, otherwise the default order of mathematical precedence
is:
Raise to a power x^2 e.g., 250000 is 2.5 10^5
Negation -x
Divide x/y
Multiply x y or x*y or x * y
Addition x+y
Note: a number preceding a variable name indicates that the
variable
is to be multiplied by that number, e.g., 3x indicates that the value
assigned to x is to be multiplied by 3.
Square braces ( [ and ] ) are used to enclose arguments of Mathematica
functions. Double square brackets are used for indexing, e.g., x[[i]]
Curly braces ( { and} ) are used for lists, e.g., {x,y,z}. Arrays are
represented as "lists of lists", e.g. {{1,2,3},{4,5,6}}
To reduce typing, use the percent (%) symbol to represent the last
result.
Multiple Mathematica statements can be included on the same line by
separating statements from one another with semicolons, e.g.: x=4; y=6;
w=7; z=x*y+w
To suppress the output display, include a semicolon at the end of a
line, e.g., a=b=0;
USAGE
You can now type in Mathematica commands or equations. For example if
you enter "2*3+5" as the first command, the "Out[1]=" response will
display the value 11 as the result of this computation.
You can assign a value to a variable by entering the variable name
followed by an equal sign and a numeric value or function, e.g., "a =
2*3+5" or "z = x / y".
A value may be assigned to more than one variable by a single statement,
e.g., to assign zero to a, b, and c, enter: a=b=c=0
If you enter the name of a defined variable at the Mathematica prompt,
it will display the value assigned to the variable.
Assuming all variables within it have been
defined and an exact result can be computed, entering a function or the
name of a variable to which a function has been assigned, will result in
the display of the computed result of the function, e.g., 2
will be displayed when Log[10,100] is entered. If an exact result cannot be
computed, Mathematica will simply redisplay the function, e.g.,
Log[10] will be displayed when Log[10] is entered.
Note: To display an approximate (typically 6 digits of
precision)
numeric evaluation of a non-exact function, enclose the function in
square brackets and precede it by a capital N, e.g., N[Log[10]]
To change the precision of the displayed result, include a comma and the
number of digits within the square brackets after the function to be
evaluated, e.g., N[Log[10],12]
To remove a definition assigned to a variable or function, enter: x=.
or Clear[x], where "x" is the name of the variable or function you which
to deassign. It is recommended that one deassign variables once you no
longer need them.
Mathematica supports a variety of Mathematical operations, e.g., use
Solve to obtain the solution to equations or Integrate to perform
integration. A variety of graphics capabilities are also included
within Mathematica through the Plot or Plot3D commands.
HELP
If you are using a Windows based environment, you can obtain assistance
using the Help menu included at the top of the Mathematica window.
Internal help can be obtained using a question mark. For help with the
function Log, enter: ?Sqrt
To display extended help about a topic, precede the name with two
questions marks, e.g., ??Sqrt
To obtain a listing of all commands and functions beginning with the
letter S, enter: ?S*
SAVING Stored Values
The Save Command can be used to save values of variables and functions
to a file. For example, to save previous definitions of x and y in the
file "filename", enter: Save["filename",x,y]
You can retrieve values saved in "filename" by entering:
<<filename
SYSTEM COMMANDS Within Mathematica
To issue a command to the operating system from within the Mathematica
environment, precede the system command with an exclamation point (!),
e.g., in the UNIX environment, to issue the ls command to list files in
the current directory, enter: !ls
EXITing from Mathematica
To interrupt a command in progress, try entering Control-C or Command-.
Note that it may take some time for the Mathematica kermel to interrupt
the process.
To exit from Mathematica, select Exit from the File menu of a Windows
based environment; in command line environments, enter Quit or press
Ctrl-D.
|