(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 10084, 409] NotebookOptionsPosition[ 8196, 337] NotebookOutlinePosition[ 8562, 353] CellTagsIndexPosition[ 8519, 350] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Code for \"", ButtonBox["Taming Table in ", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://www.physic.ut.ee/~kkannike/english/prog/mathematica/index.\ html#table_taming"], None}], StyleBox[ButtonBox["Mathematica", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://www.physic.ut.ee/~kkannike/english/prog/mathematica/index.\ html#table_taming"], None}], FontSlant->"Italic"], ButtonBox[" 5", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://www.physic.ut.ee/~kkannike/english/prog/mathematica/index.\ html#table_taming"], None}], "\"\nKristjan Kannike, 2005" }], "Title", CellDingbat->None], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Array", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "[", "##", "]"}], "[", "x", "]"}], "&"}], ",", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"1", ",", "1"}], "]"}], "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", RowBox[{"1", ",", "2"}], "]"}], "[", "x", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"2", ",", "1"}], "]"}], "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", RowBox[{"2", ",", "2"}], "]"}], "[", "x", "]"}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Array", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "[", "##", "]"}], "[", "t", "]"}], " ", "&"}], ",", RowBox[{"{", "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "0", "]"}], "[", "t", "]"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"Unprotect", "[", "Array", "]"}], ";", RowBox[{ RowBox[{"Array", "[", RowBox[{"x_", ",", RowBox[{"{", "}"}]}], "]"}], "=", RowBox[{"First", "[", RowBox[{"Array", "[", RowBox[{"x", ",", "1", ",", "0"}], "]"}], "]"}]}], ";", RowBox[{"Protect", "[", "Array", "]"}], ";"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Array", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "[", "##", "]"}], "[", "t", "]"}], " ", "&"}], ",", RowBox[{"{", "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "0", "]"}], "[", "t", "]"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"iter", "=", RowBox[{"{", RowBox[{"i", ",", "1", ",", "3"}], "}"}]}], ";"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{"f", "[", "i", "]"}], ",", "iter"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Table", "::", "\<\"itform\"\>"}], RowBox[{ ":", " "}], "\<\"Argument \\!\\(iter\\) at position \\!\\(2\\) does not \ have the correct form for an iterator. \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\ \\\", ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \ ButtonData:>\\\"General::itform\\\"]\\)\"\>"}]], "Message"], Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{"f", "[", "i", "]"}], ",", "iter"}], "]"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"iter", "=", RowBox[{"{", RowBox[{"i", ",", "1", ",", "3"}], "}"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"f", "[", "i", "]"}], ",", RowBox[{"iter", "//", "Evaluate"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"f", "[", "1", "]"}], ",", RowBox[{"f", "[", "2", "]"}], ",", RowBox[{"f", "[", "3", "]"}]}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"dims", "=", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], ";"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"itervars", "=", RowBox[{"Apply", "[", RowBox[{"Sequence", ",", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"i", "[", "#", "]"}], " ", "&"}], ",", RowBox[{"Range", "[", RowBox[{"Length", "[", "dims", "]"}], "]"}]}], "]"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Sequence", "[", RowBox[{ RowBox[{"i", "[", "1", "]"}], ",", RowBox[{"i", "[", "2", "]"}]}], "]"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"iters", "=", RowBox[{"Apply", "[", RowBox[{"Sequence", ",", RowBox[{"MapIndexed", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"i", "[", RowBox[{"First", "[", "#2", "]"}], "]"}], ",", "1", ",", "#1"}], "}"}], " ", "&"}], ",", "dims"}], "]"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Sequence", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"i", "[", "1", "]"}], ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"i", "[", "2", "]"}], ",", "1", ",", "3"}], "}"}]}], "]"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{"Plus", "[", "itervars", "]"}], ",", RowBox[{"iters", "//", "Evaluate"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", "itervars", "]"}], "[", "x", "]"}], ",", RowBox[{"iters", "//", "Evaluate"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"1", ",", "1"}], "]"}], "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", RowBox[{"1", ",", "2"}], "]"}], "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", RowBox[{"1", ",", "3"}], "]"}], "[", "x", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"2", ",", "1"}], "]"}], "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", RowBox[{"2", ",", "2"}], "]"}], "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", RowBox[{"2", ",", "3"}], "]"}], "[", "x", "]"}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"dims2", "=", RowBox[{"{", "}"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"itervars2", "=", RowBox[{"Apply", "[", RowBox[{"Sequence", ",", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"i", "[", "#", "]"}], " ", "&"}], ",", RowBox[{"Range", "[", RowBox[{"Length", "[", "dims2", "]"}], "]"}]}], "]"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Sequence", "[", "]"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"iters2", "=", RowBox[{"Apply", "[", RowBox[{"Sequence", ",", RowBox[{"MapIndexed", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"i", "[", RowBox[{"First", "[", "#2", "]"}], "]"}], ",", "1", ",", "#1"}], "}"}], " ", "&"}], ",", "dims2"}], "]"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Sequence", "[", "]"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", "itervars2", "]"}], "[", "x", "]"}], ",", RowBox[{"iters2", "//", "Evaluate"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "]"}], "[", "x", "]"}]], "Output"] }, Open ]] }, Open ]] }, WindowSize->{1016, 681}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, CellLabelAutoDelete->True, FrontEndVersion->"7.0 for Mac OS X x86 (32-bit) (February 18, 2009)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 642, 20, 154, "Title"], Cell[CellGroupData[{ Cell[1234, 46, 211, 7, 33, "Input"], Cell[1448, 55, 538, 19, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[2023, 79, 186, 6, 33, "Input"], Cell[2212, 87, 83, 2, 33, "Output"] }, Open ]], Cell[2310, 92, 348, 10, 33, "Input"], Cell[CellGroupData[{ Cell[2683, 106, 186, 6, 33, "Input"], Cell[2872, 114, 83, 2, 33, "Output"] }, Open ]], Cell[2970, 119, 129, 4, 33, "Input"], Cell[CellGroupData[{ Cell[3124, 127, 113, 3, 33, "Input"], Cell[3240, 132, 361, 7, 23, "Message"], Cell[3604, 141, 114, 3, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[3755, 149, 256, 8, 33, "Input"], Cell[4014, 159, 170, 5, 33, "Output"] }, Open ]], Cell[4199, 167, 119, 4, 33, "Input"], Cell[CellGroupData[{ Cell[4343, 175, 318, 10, 33, "Input"], Cell[4664, 187, 143, 4, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[4844, 196, 364, 11, 33, "Input"], Cell[5211, 209, 268, 9, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[5516, 223, 156, 4, 33, "Input"], Cell[5675, 229, 191, 6, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[5903, 240, 183, 5, 33, "Input"], Cell[6089, 247, 740, 25, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[6866, 277, 71, 2, 33, "Input"], Cell[6940, 281, 45, 1, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7022, 287, 320, 10, 33, "Input"], Cell[7345, 299, 57, 1, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7439, 305, 366, 11, 33, "Input"], Cell[7808, 318, 57, 1, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7902, 324, 185, 5, 33, "Input"], Cell[8090, 331, 78, 2, 33, "Output"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)