(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 7323, 219] NotebookOptionsPosition[ 6477, 185] NotebookOutlinePosition[ 6863, 202] CellTagsIndexPosition[ 6820, 199] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Too many definitions", "Title", CellChangeTimes->{{3.3918893128898463`*^9, 3.3918893187482705`*^9}, { 3.392049033699301*^9, 3.392049040819539*^9}}], Cell["\<\ The notion that you must define something before you can use it is ingrained \ deeply into the brains of most science folk! If you program in C or Fortran \ you will know what problems you can encounter if you use undefined things. \ This creates a culture in which many people start their work with a whole \ bunch of assignments to variables. This is unfortunate for at least two \ reasons: Leaving things undefined can produce many interesting results. For example, \ using an undefined function, f (say) you can obtain a wealth of interesting \ results, such as:\ \>", "Text", CellChangeTimes->{ 3.392017412229861*^9, {3.3920174467995696`*^9, 3.3920175125140624`*^9}, { 3.392017618326213*^9, 3.3920176463364897`*^9}, 3.392049104831584*^9, 3.39204914528976*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Series", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", "^", "2"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "5"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.392049155414318*^9, 3.3920491683929806`*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{ RowBox[{"f", "[", "0", "]"}], "+", RowBox[{ RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "[", "0", "]"}], " ", SuperscriptBox["x", "2"]}], "+", RowBox[{ FractionBox["1", "2"], " ", RowBox[{ SuperscriptBox["f", "\[Prime]\[Prime]", MultilineFunction->None], "[", "0", "]"}], " ", SuperscriptBox["x", "4"]}], "+", InterpretationBox[ SuperscriptBox[ RowBox[{"O", "[", "x", "]"}], "6"], SeriesData[$CellContext`x, 0, {}, 0, 6, 1], Editable->False]}], SeriesData[$CellContext`x, 0, { $CellContext`f[0], 0, Derivative[1][$CellContext`f][0], 0, Rational[1, 2] Derivative[2][$CellContext`f][0]}, 0, 6, 1], Editable->False]], "Output", CellChangeTimes->{3.3920491716576753`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"f", "[", RowBox[{"Sin", "[", "x", "]"}], "]"}], "]"}], ",", "x"}], "]"}]], "Input",\ CellChangeTimes->{{3.3920492282690783`*^9, 3.392049239795653*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Cos", "[", "x", "]"}], " ", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "[", RowBox[{"f", "[", RowBox[{"Sin", "[", "x", "]"}], "]"}], "]"}], " ", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "[", RowBox[{"Sin", "[", "x", "]"}], "]"}]}]], "Output", CellChangeTimes->{3.3920492423493247`*^9}] }, Open ]], Cell["\<\ These results are, of course, true for an arbitrary repeatedly diferentiable \ function f. Undefined functions and variables also help you explore the operation of many \ Mathematica operations. For example:\ \>", "Text", CellChangeTimes->{ 3.392017412229861*^9, {3.3920174467995696`*^9, 3.3920175125140624`*^9}, { 3.392017618326213*^9, 3.3920176463364897`*^9}, 3.392049104831584*^9, 3.39204914528976*^9, {3.392049190134243*^9, 3.3920492064376864`*^9}, { 3.3920492530647326`*^9, 3.3920492656828766`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Map", "[", RowBox[{"f", ",", RowBox[{"{", RowBox[{"a", ",", "b", ",", "c"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{ 3.392017412229861*^9, {3.3920174467995696`*^9, 3.3920175125140624`*^9}, { 3.392017618326213*^9, 3.3920176463364897`*^9}, 3.392049104831584*^9, 3.39204914528976*^9, {3.392049190134243*^9, 3.3920492064376864`*^9}, { 3.3920492530647326`*^9, 3.392049292831915*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"f", "[", "a", "]"}], ",", RowBox[{"f", "[", "b", "]"}], ",", RowBox[{"f", "[", "c", "]"}]}], "}"}]], "Output", CellChangeTimes->{3.3920493084844227`*^9}] }, Open ]], Cell["\<\ Often it is better to work with expressions with undefined variables and \ functions and use /. to replace them with numeric values only when required. \ What is the point of going to the trouble to discover the notation for \ Planck's constant, only to define it away:\ \>", "Text", CellChangeTimes->{ 3.392017412229861*^9, {3.3920174467995696`*^9, 3.3920175125140624`*^9}, { 3.392017618326213*^9, 3.3920176463364897`*^9}, 3.392049104831584*^9, 3.39204914528976*^9, {3.392049190134243*^9, 3.3920492064376864`*^9}, { 3.3920492530647326`*^9, 3.3920493531486464`*^9}}], Cell[BoxData[ RowBox[{"\[HBar]", "=", RowBox[{"1.0545715964207856", " ", SuperscriptBox["10", RowBox[{"-", "34"}]]}]}]], "Input", CellChangeTimes->{{3.3920493619112463`*^9, 3.3920494487661376`*^9}}], Cell["\<\ Any output from Mathematica involving this constant will be reduced to a \ meaningless number. Think of the way you would probably perform a hand \ calculation. This brings me to the second \[Section]Emphasise[\"big problem\"] with an \ over-use of definitions. Variable definitions have a habit of hanging around \ while you use Mathematica on an unrelated calculation. This can be extremely \ dangerous (the type of danger obviously depends on your area of \ application!). Suppose you have inadvertently set x=10 as part of some \ calculation and you then move on to something else. The chances are high that \ you will use the variable x again, but it will be immediately replaced by its \ 'value': 10. \ \>", "Text", CellChangeTimes->{ 3.392017412229861*^9, {3.3920174467995696`*^9, 3.3920175125140624`*^9}, { 3.392017618326213*^9, 3.3920176463364897`*^9}, 3.392049104831584*^9, 3.39204914528976*^9, {3.392049190134243*^9, 3.3920492064376864`*^9}, { 3.3920492530647326`*^9, 3.3920493531486464`*^9}, {3.3920494588706675`*^9, 3.3920494631568303`*^9}}] }, Open ]] }, WindowSize->{868, 750}, WindowMargins->{{Automatic, 89}, {Automatic, -73}}, ShowSelection->True, ShowCellLabel->False, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (March 26, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 156, 2, 83, "Title"], Cell[749, 27, 785, 15, 119, "Text"], Cell[CellGroupData[{ Cell[1559, 46, 263, 7, 28, "Input"], Cell[1825, 55, 831, 25, 40, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[2693, 85, 239, 7, 28, "Input"], Cell[2935, 94, 404, 12, 27, "Output"] }, Open ]], Cell[3354, 109, 528, 11, 65, "Text"], Cell[CellGroupData[{ Cell[3907, 124, 432, 9, 28, "Input"], Cell[4342, 135, 214, 6, 27, "Output"] }, Open ]], Cell[4571, 144, 589, 10, 47, "Text"], Cell[5163, 156, 212, 5, 28, "Input"], Cell[5378, 163, 1083, 19, 137, "Text"] }, Open ]] } ] *) (* End of internal cache information *)