(* 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[ 4275, 137] NotebookOptionsPosition[ 3664, 111] NotebookOutlinePosition[ 4004, 126] CellTagsIndexPosition[ 3961, 123] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "x_", "]"}], " ", ":=", " ", RowBox[{ RowBox[{"3", "x"}], "+", "2"}]}]], "Input", CellChangeTimes->{{3.423223665390625*^9, 3.423223737828125*^9}, { 3.42322400846875*^9, 3.423224010046875*^9}, {3.423229289390625*^9, 3.423229289921875*^9}, {3.423229780875*^9, 3.423229784203125*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"f", "[", "2", "]"}]], "Input", CellChangeTimes->{{3.423223665390625*^9, 3.42322370696875*^9}}], Cell[BoxData["8"], "Output", CellChangeTimes->{{3.423223725109375*^9, 3.423223741125*^9}, { 3.423224013375*^9, 3.423224042875*^9}, 3.42322573596875*^9, 3.423226085484375*^9, 3.4232292941875*^9, 3.423229879125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"TTrap", "[", RowBox[{"n_", ",", "a_", ",", "b_"}], "]"}], " ", ":=", " ", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"h", " ", "=", " ", RowBox[{ RowBox[{"(", RowBox[{"b", "-", "a"}], ")"}], " ", "/", "n"}]}], ";", "\[IndentingNewLine]", RowBox[{"sum", " ", "=", " ", "0"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", " ", RowBox[{"i", "\[LessEqual]", " ", RowBox[{"n", "-", "1"}]}], ",", " ", RowBox[{"i", "=", RowBox[{"i", "+", "1"}]}], ",", "\[IndentingNewLine]", " ", RowBox[{"sum", " ", "=", " ", RowBox[{"sum", " ", "+", " ", RowBox[{"f", "[", RowBox[{"a", " ", "+", " ", RowBox[{"i", " ", "h"}]}], "]"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"TT", " ", "=", " ", RowBox[{ RowBox[{"h", "/", "2"}], " ", RowBox[{"(", RowBox[{ RowBox[{"f", "[", "a", "]"}], " ", "+", " ", RowBox[{"f", "[", "b", "]"}], " ", "+", RowBox[{"2", "sum"}]}], ")"}]}]}]}], ")"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.4232237480625*^9, 3.4232239113125*^9}, 3.4232241805*^9, 3.423225566171875*^9, {3.42322561221875*^9, 3.423225635390625*^9}, 3.423229302125*^9, 3.423229334578125*^9, {3.423229643546875*^9, 3.423229643984375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"TTrap", "[", RowBox[{"2", ",", "0", ",", "2"}], "]"}]], "Input", CellChangeTimes->{{3.42322944921875*^9, 3.423229452234375*^9}, { 3.4232294871875*^9, 3.423229493546875*^9}, {3.423229937828125*^9, 3.423229964*^9}}], Cell[BoxData["10"], "Output", CellChangeTimes->{3.423229511109375*^9, 3.423229669546875*^9, 3.42322990678125*^9, 3.423229966515625*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"NIntegrate", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "2"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.423229910328125*^9, 3.423229928421875*^9}}], Cell[BoxData["10.000000000000012`"], "Output", CellChangeTimes->{3.423229930265625*^9}] }, Open ]] }, WindowSize->{1272, 905}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (June 19, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 337, 7, 31, "Input"], Cell[CellGroupData[{ Cell[930, 32, 119, 2, 31, "Input"], Cell[1052, 36, 221, 3, 30, "Output"] }, Open ]], Cell[1288, 42, 1579, 39, 192, "Input"], Cell[CellGroupData[{ Cell[2892, 85, 246, 5, 31, "Input"], Cell[3141, 92, 139, 2, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[3317, 99, 240, 6, 31, "Input"], Cell[3560, 107, 88, 1, 30, "Output"] }, Open ]] } ] *) (* End of internal cache information *)