In[203]:=

x = 2

Out[203]=

2

In[204]:=

x

Out[204]=

2

In[205]:=

x ;

In[209]:=

x = {3, 2, 1}

Out[209]=

{3, 2, 1}

In[211]:=

x[[3]]

Out[211]=

1

In[212]:=

m = {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}} ; MatrixForm[m]

Out[212]//MatrixForm=

( {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}} )

In[214]:=

m . x

Out[214]=

{2, 1, 3}

In[215]:=

Transpose[m]

Out[215]=

{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}

In[216]:=

MatrixForm[%]

Out[216]//MatrixForm=

( {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}} )

In[220]:=

mr = Table[Random[Real, {0, 1}], {i, 3}, {j, 3}] ; MatrixForm[mr]

Out[220]//MatrixForm=

( {{0.253637, 0.840661, 0.353858}, {0.80996, 0.388095, 0.483886}, {0.407379, 0.0993056, 0.728834}} )

In[225]:=

b = Table[Random[Real, {0, 10}], {i, 3}]

Out[225]=

{8.03906, 4.9736, 2.9939}

In[226]:=

mr . b ; ColumnForm[%]

Out[226]=

8.03906
4.9736
2.9939

In[227]:=

x = Inverse[mr] . b

Out[227]=

{0.597172, 8.26824, 2.64743}

In[228]:=

mr . x - b

Out[228]=

{0., 0., -4.44089*10^-16}

In[229]:=

v = {1, 2, 3}

Out[229]=

{1, 2, 3}

In[230]:=

v + 1

Out[230]=

{2, 3, 4}

In[231]:=

v * 3

Out[231]=

{3, 6, 9}

In[232]:=

Sum[v[[i]], {i, 1, 3}]

Out[232]=

6

In[233]:=

Table[Sum[mr[[i]][[j]], {j, 1, 3}], {i, 3}]

Out[233]=

{1.44816, 1.68194, 1.23552}

In[234]:=

Sum[Sum[mr[[i]][[j]], {j, 1, 3}], {i, 1, 3}]

Out[234]=

4.36562

In[235]:=

Range[1, 3]

Out[235]=

{1, 2, 3}

In[236]:=

Table[1, {i, 3}]

Out[236]=

{1, 1, 1}

In[246]:=

f[x_, y_] := x * y

In[248]:=

A = Outer[f, Table[1, {i, 3}], Range[1, 3]] ; MatrixForm[%]

Out[248]//MatrixForm=

( {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}} )

In[251]:=

A * Transpose[A] ; MatrixForm[%]

Out[251]//MatrixForm=

( {{1, 2, 3}, {2, 4, 6}, {3, 6, 9}} )

In[255]:=

Table[Mod[A[[i, j]], Transpose[A][[i, j]]], {i, 3}, {j, 3}] ; MatrixForm[%]

Out[255]//MatrixForm=

( {{0, 0, 0}, {1, 0, 1}, {1, 2, 0}} )

In[274]:=

AA = Table[ If[ Mod[ A[[i, j]], Transpose[A][[i, j]] ] == 0, 1, 0], {i, 3}, {j, 3}] ; MatrixForm[AA]

Out[274]//MatrixForm=

( {{1, 1, 1}, {0, 1, 0}, {0, 0, 1}} )

In[276]:=

Table[Sum[AA[[i, j]], {i, 1, 3}], {j, 3}]

Out[276]=

{1, 2, 2}

In[277]:=

Table[If[Sum[AA[[i, j]], {i, 1, 3}] == 2, 1, 0], {j, 3}]

Out[277]=

{0, 1, 1}

In[279]:=

Position[Table[Sum[AA[[i, j]], {i, 1, 3}], {j, 3}], 2]

Out[279]=

{{2}, {3}}

A = Outer[f, Table[1, {i, 100}], Range[1, 100]] ;

In[282]:=

Position[Table[Sum[If[Mod[A[[i, j]], Transpose[A][[i, j]]] == 0, 1, 0], {i, 1, 100}], {j, 100}], 2]

Out[282]=

{{2}, {3}, {5}, {7}, {11}, {13}, {17}, {19}, {23}, {29}, {31}, {37}, {41}, {43}, {47}, {53}, {59}, {61}, {67}, {71}, {73}, {79}, {83}, {89}, {97}}

In[283]:=

x

Out[283]=

{0.597172, 8.26824, 2.64743}

In[284]:=

x . x

Out[284]=

75.7293

In[287]:=

Inner[f, x, x]

Out[287]=

75.7293

In[286]:=

Outer[f, x, x] ; MatrixForm[%]

Out[286]//MatrixForm=

( {{0.356614, 4.93756, 1.58097}, {4.93756, 68.3637, 21.8896}, {1.58097, 21.8896, 7.00891}} )

In[310]:=

v

Out[310]=

{}

In[313]:=

For[i = 1, i≤10, i ++, v = Insert[v, i * i, i]]

In[314]:=

v

Out[314]=

{1, 4, 9, 16, 25, 36, 49, 64, 81, 100}

In[315]:=

B = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} ; MatrixForm[B]

Out[315]//MatrixForm=

( {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} )

In[316]:=

B[[1, 1]]

Out[316]=

1

In[318]:=

B[[3, 3]]

Out[318]=

9

In[319]:=

B[[3, 1]]

Out[319]=

7

In[320]:=

Length[B]

Out[320]=

3

In[321]:=

Length[B[[1]]]

Out[321]=

3

In[322]:=

Dimensions[B]

Out[322]=

{3, 3}

In[323]:=

x

Out[323]=

{0.597172, 8.26824, 2.64743}

In[324]:=

Length[x]

Out[324]=

3

In[325]:=

Length[x[[1]]]

Out[325]=

0

In[326]:=

Dimensions[x]

Out[326]=

{3}

In[335]:=

x = Range[1, 100] ;

In[332]:=

ListPlot[Table[{x[[i]], x[[i]] * x[[i]]}, {i, Length[x]}], AxesLabel→ {"x", "x*x"}, PlotJoined→True, PlotStyle→Hue[0]]

[Graphics:HTMLFiles/Intro-Mathematica_98.gif]

Out[332]=

-Graphics -

In[334]:=

Plot[x^2, {x, 0, 100}, AxesLabel→ {"x", "x^2"}, PlotStyle→Hue[0]]

[Graphics:HTMLFiles/Intro-Mathematica_101.gif]

Out[334]=

-Graphics -

In[338]:=

HTMLSave["/Users/jmk/class/cs530/Intro-Mathematica.html", "Intro-Mathematica.nb"]

Out[337]=

/Users/jmk/class/cs530/Intro-Mathematica.html


Created by Mathematica  (August 29, 2007) Valid XHTML 1.1!