# Mathematica Quick Reference

Extracted by Lyle Long (PSU Aerospace Eng.) from a Mathimatica notebook tutorial, written by Chris Duffy (PSU Civil Eng.)

### To Start

math or mathematica (notebooks) (typed at the Unix command prompt)

### To Stop

Quit (typed at the Mathematica command prompt)

### Parentheses and Brackets & Misc

( ) groups objects, ie (a+b)/(c+d)

[ ] function arguments, ie Sin[x]

{ } list elements { 1.2, 2.0, 3.0 }

% refers to previous output line

%% refers to second previous output line

Clear [ x ]

### Equal Signs

x = y set x = y right now

x == y test whether x and y are equal

x := y set delayed

### Help

?Plot gives help on Plot

??Plot gives detailed help on Plot

### Simple Arithmetic

(2.389 + 8.21)*(12^2 + 4 - 7)

2 Pi / 3

E^(I Pi)

N[E^(I Pi)]

### Plotting

Plot[ Cos[x], { x , -3 Pi, 3 Pi }]

Plot3D[ x^2 + y^2, {x,-10,10}, {y,-10,10}]

ContourPlot[ x^2+y^2, {x,-10,10}, {y,-10,10}]

Plot [ { f[x], g[x]}, { x, -3, 3} ]

ParametricPlot[{Cos[2 x], Sin[2 x]}, {t, 0, 2 Pi}]

Display [ "file.dat", Out[3] ]

### Symbolic Algebra

Expand [ (x+y) ( x^2 - x y + y^2 )]

Factor [ x^3 + y^3 ]

Simplify [ (x+y) ( x^2 - x y + y^2)]

Apart [ (a x + b) / ( (x-r) (x-s) ) ]

Together [ a/b + c/d ]

Numerator [ ( a + b ) / ( c + d ) ]

Denominator [ ( a + b ) / ( c + d ) ]

Cancel [ x ]

### Functions

f[x_,y_] := x^2 + y^2 + Sin[x]

f[1,2]

### Equations

Solve [ a x^2 + b x + c == 0, x]

Solve [ a x + b y == f, c x - d y == g},{x,y}]

FindRoot [ x^3 + x^2 + x + 1 == 0, {x,1}]

### Sums and Series

Sum [ x^i / i! , {i,0,5}]

Series [ Sin[x], {x,0,7} ]

### Complex Numbers

z = ( 4 + I ) / ( 1 - I )

Re[ z ]

Im [ z ]

Abs [ z ]

Conjugate [ z ]

Solve [ x^4 + x == 0, x ]

### Differentiation

D [ x^3, x ], first derivative

D [ x^3, {x, 2} ], second derivative

D [ Exp [ x^2 + y^2 ] , x ], partial derivative

f [ x_ ] := x / ( x^2 + 1 )

f ' [x]

D [ f[x], x ]

### Integration

Integrate [ Sin[ x + pi ], x ]

Integrate [ Sin[ x + pi ], {x, -Pi, Pi} ]

Integrate [ x^2 + y^2, x, y ]

### Matrices

A = { {1, 0, 2}, {7, 1, 6}, {9, 1, 3} }

Inverse [ A ]

Transpose [ A ]

Det [ A ]

B = { 1, 2, -1 }

LinearSolve [ A, B ]

x = Inverse[ A ].B

A.x

### Differential Equations

DSolve [ { y'[t] + y[t] == 1, y[0]==0}, y[t],t]

NDSolve [ { y'[t] + y[t] == 1, y[0]==0},y[t],{t,0,5}]

Save [ "file.dat", A, B, x, Out[3] ]

Display [ "file.dat", % ], where % is graphics

Dump [ "file.dat" ]

Write [ "file.dat", Out[1], Out[2] ]

### Packages

On Suns:

\$Path=Join[\$Path, {"/tmp_mnt/usr/apps/mathematica2.2/Packages/"}]

On IBM RS/6000:

\$Path=Join[\$Path, {"/usr/local/math/Packages/"}]

On SGI's:

\$Path=Join[\$Path, {"/tmp_mnt/usr/local/math/Packages/"}]

<<Trigonometry.m

<<VectorAnalysis.m

etc.

Abs

Erf

Exp

Sqrt

Sign

Log

Prime

Mod

N[Pi, 100]

ArcCos

ArcCosh

ArcCot

ArcSec

ArcSin

ArcSinh

ArcTanh

ArcTan

Cos

Cosh

Coth

Csc

Csch

Sec

Sech

Sin

Sinh

Tan

Tanh

E

Pi

I