Introduction to Mathematica

Arithmetic

2 + 3

2*3

\(\(\( (*\ 
      Note\ that\ there\ is\ a\ space\ between\ the\ 2\ and\ the\ 3\ below\ *) \)\(
\)\(2\ 3\)\)\)

7!

1/3

21/102

N[1/3]

N[21/102, 25]

N[Pi, 100]

N[π, 100]

Sqrt[27]

N[Sqrt[27]]

N[(Sqrt[27])]

Algebra

Expand[(a + b)^3]

Factor[x^2 - x - 6]

Factor[x^2 - x + 6]

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

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

NSolve[x^5 - x^2 + 6 == 0, x]

Lists, Vectors, and Matrices

\(\(\( (*\ 
      The\ following\ are\ two\ "lists"\ of\ 3\ \(\(numbers\)\(.\)\)\ \ \ \ *) \)\(
\)\( (*\ 
      The\ lists\ has\ been\ given\ the\ name\ "v"\ and\ "w"\ \ *) \)\(
\)\(v = \ {5, 10, 11}

    w\  = \ {\(-1\), 4, 2}\)\)\)

MatrixForm[v]

v[[1]]

w[[3]]

v[[4]]

\(\(\( (*\ 
      The\ dot\ product\ is\ done\ with\ a\ period\ between\ *) \)\(
\)\( (*\ the\ vectors\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\(
\)\(v . w\)\)\)

\(\(\( (*\ 
      The\ following\ is\ a\ "list of lists"\ \ \ \ \ \ \ *) \)\(
\)\( (*\ The\ individual\ lists\ can\ be\ interpreted\ \ *) \)\(
\)\( (*\ 
      as\ rows\ of\ a\ \(\(matrix\)\(.\)\)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\(
\)\(m\  = \ {{1, 2}, {3, 4}}\)\)\)

MatrixForm[m]

MatrixForm[Inverse[m]]

MatrixForm[m . Inverse[m]]

MatrixForm[Transpose[m]]

Defining Functions

f[x_] :=  x*Sin[x]

f[1.1]

Graphics

Plot[f[x], {x, 0, 10}];

\(\(\( (*\ 
      The\ following\ two\ commands\ are\ repeats\ of\ the\ *) \)\(
\)\( (*\ 
      preceding\ two\ commands, \ 
      except\ that\ they\ now\ \ *) \)\(
\)\( (*\ 
      have\ names\ associated\ with\ them . \ \ The\ Show\ \ \ \ *) \)\(
\)\( (*\ combines\ the\ two\ \(\(graphs\)\(.\)\)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\)\)

graph1  =  Plot[ .1*x^2, {x, 1, 10}];
graph2  = Plot[f[x], {x, 0, 10}];
Show[graph1, graph2];

Integration

Integrate[x^3, x]

Integrate[x^3, {x, a, b}]

\(\(\( (*\ 
      The\ output\ from\ the\ last\ command\ was\ probably\ *) \)\(
\)\( (*\ 
      not\ \(\(comprehensible\)\(.\)\)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\(
\)\( (*\ 
      Try\ the\ following\ two\ command\ sequence, \ and\ \ *) \)\(
\)\( (*\ 
      see\ if\ you\ can\ figure\ out\ the\ difference\ in\ \ *) \)\(
\)\( (*\ \(output\)\(.\)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\)\)

Clear[x, a, b]
Integrate[x^3, {x, a, b}]

(∫_a^b) x^3 \[DifferentialD]x