Introduction

First Steps

You can execute Mathematica commands by pressing SHIFT-ENTER.
A simple RETURN just brings up a new line. Try it:

2+2

2+3
3+4

Mathematica consists of a "frontend" and a "kernel". What you see right now is the frontend; the kernel which starts when you execute your first command usually works in the background.
You type a command on an input line. Pressing SHIFT-ENTER sends the command to the kernel, which executes the command, and then returns the output to the frontend below the input.

Clicking on a bracket let's you see more of the content.
Try it for the next closed bracket!

Command Structure

All commands are capitalized; their arguments are enclosed in "[ ]" brackets. This is consistent throughout Mathematica. Square brackets are used exclusively to delimit the input to a command.

Sin[Pi/4]

Integrate[x^2,x]

Numbers and other "Atomic Expressions"

Numbers come in four different flavors:

2.1

Head[2.1]

2

Head[2]

23/13

Head[23/13]

2-3I

Head[2-3I]

There are also symbols and strings:

Head[Pi]

Head[x]

Head[teacher]

Head["teacher"]

Strings are enclosed by "..."; if you forget the quotations marks, the expression will be considered a symbol just like x or π.

Symbolic and Numerical Computation

Expressions are left in symbolic form unless you compute with real numbers.

Sin[Pi/3]

Pi^2

Pi^2.

In the last example the exponent of the expression is a real number; thus Mathematica will give a numerical answer. Do you see the difference between the last two commands:

Head[2]
Head[2.]

You can always see the numerical value if you preface the expression with the command "N".

Pi^3

N[Pi^3]

Exp[2+I]

N[Exp[2+I]]

N[Pi,100]

The "100" at the end tells Mathematica to compute the first 100 significant digits of the expression.

Internal Storage, Tracking Execution

Expressions are stored internally according to their "FullForm":

FullForm[2x+3]

p/2+Sqrt[p^2/4-q]

FullForm[%]

Aside: the Symbol "%" refers to the previous input.

FullForm[Exp[1+I]]

You can trace the excution of  a command by "Trace":

Trace[(2+3*4)/5]

You can compare different approaches to a problem by the "Timing" command:

Timing[FactorInteger[385743723672372458354523545235232]]

In this example Mathematica factors
385743723672372458354523545235232
=(2^5)*11398171*1057581200068119641614331.

Comments

You can add comments enclosed by "(*  *)":

2+(* a silly comment*)3

Try It Yourself !

1. Predict the exact form of the output of the following expressions before you evaluate the command:

2-6

2.-6

2-1/3

2-1./3

4/3-1/2+1/6

2 Pi

(2+I)*3.6

Sqrt[4]

2. Compute the first 50 digits of the sqare root of 3.

3. How long does it take to compute the first 10,000 digits of the square root of 2?