Mathematica  Lesson I

Physics 80301  Fall 2005

Arithmetic

2 + 3

2 + 3 + 4 + 5

4/16

2.5 + 6.33

2*3

2 3

2 3 4 5

2^3

2^100

Numerical Evaluation

N[2/3]

N[2/3, 40]

N[Pi]

(25 - 7) (2  +  3)

Functions

Sqrt[9]

Sqrt[7]

N[%]

Sin[Pi]

Sin[Pi/4]

Cos[1.6]

Tan[Pi/4]

Tan[Pi/2]

Exp[1]

N[E]

Exp[0]

Log[E]

N[Log[10, E]]

Log[10, 1000]

Abs[-1.3]

Round[%]

Assignments

a  =  7

a

Clear[a]

a

Manipulations

Factor[x^3 + 2  x^2 - 1]

Expand[(a x  +  b)^2 (x + c)]

Simplify[%]

D[x^4, x]

Sin'[x]

Integrate[Log[x], {x, 0, 1}]

Solving Equations

Solve[x^2 - 5 x  - 6  == 0, x]

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

a x^2  +  b x  +  c  /.  %

Simplify[a x^2 + b x  +  c  /.  %41]

Solve[{2 x  +  y  == 0,  2 x  -  y  ==  1}, {x, 
        y}]

x y  /.  %

FindRoot[Log[x],  {x, 2}]

Graphics

Plot[(Sin[x]/x)^2, {x, -2 Pi, 2 Pi}]

Plot[(Sin[x]/x)^2, {x, -2 Pi, 2 Pi}, 
      PlotStyle -> {Thickness[0.015], RGBColor[1, 0, 0]},  
      AxesLabel -> {X, Y}]

Plot3D[
      Sin[x]*Cos[y], {x, -Pi, Pi}, {y, -2 Pi, 2 Pi}]

Matrices

a  =  {{1, 2, 3}, {-1, 4, 2}, {0, 8, -4}}

b  =  {{2,  -7, 4}, {3, 5, -1}, {5, -2, 3}}

MatrixForm[a]

MatrixForm[b]

a  .  b

MatrixForm[a . b]

MatrixForm[Transpose[a]]

MatrixForm[Inverse[a]]

MatrixForm[Inverse[a]  .  a]

Det[a]

Det[b]

Eigenvalues[b]

Random Numbers and Tables

Random[]

Random[Real, {-1, 1}]

Table[Random[Real, {-1, 1}], {i, 1, 10}]

Table[1.5 i^2 + Random[Real, {-1, 1}], {i, 0, 9}]

ListPlot[%65, 
      PlotStyle -> {PointSize[ .03], RGBColor[0, 1, 1]}]