(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 9.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 3417, 106] NotebookOptionsPosition[ 3173, 93] NotebookOutlinePosition[ 3518, 108] CellTagsIndexPosition[ 3475, 105] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{"implicitEuler", "[", RowBox[{"f_", ",", "u0_", ",", "h_", ",", "t0_", ",", "T_"}], "]"}], ":=", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Ceiling", "[", RowBox[{ RowBox[{"(", RowBox[{"T", "-", "t0"}], ")"}], "/", "h"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"t", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"i", " ", "h"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"y", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"n", "+", "1"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", RowBox[{"[", "1", "]"}], "]"}], "=", "u0"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", RowBox[{"i", "<", RowBox[{"n", "+", "1"}]}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"initialGuess", "=", RowBox[{ RowBox[{"y", "[", RowBox[{"[", "i", "]"}], "]"}], "+", RowBox[{"h", " ", RowBox[{"f", "[", RowBox[{ RowBox[{"t", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"y", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", RowBox[{"[", RowBox[{"i", "+", "1"}], "]"}], "]"}], "=", RowBox[{"yNew", "/.", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{"yNew", "==", RowBox[{ RowBox[{"y", "[", RowBox[{"[", "i", "]"}], "]"}], "+", " ", RowBox[{"h", " ", RowBox[{"f", "[", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"i", "+", "1"}], "]"}], "]"}], ",", "yNew"}], "]"}]}]}]}], ",", RowBox[{"{", RowBox[{"yNew", ",", "initialGuess"}], "}"}]}], "]"}]}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "y"}], "\[IndentingNewLine]", ")"}]}]], "Input", CellChangeTimes->{{3.6650422017309637`*^9, 3.6650422362093906`*^9}, { 3.669105454523644*^9, 3.669105492637824*^9}, {3.669105527378811*^9, 3.669105536954359*^9}, {3.6691056090624833`*^9, 3.6691056094355044`*^9}, { 3.669106677858615*^9, 3.6691067338428173`*^9}}] }, WindowSize->{1061, 896}, WindowMargins->{{17, Automatic}, {Automatic, 19}}, FrontEndVersion->"9.0 for Microsoft Windows (64-bit) (January 25, 2013)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[557, 20, 2612, 71, 232, "Input"] } ] *) (* End of internal cache information *)