(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.1' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 9288, 284] NotebookOptionsPosition[ 8736, 261] NotebookOutlinePosition[ 9081, 276] CellTagsIndexPosition[ 9038, 273] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[{ RowBox[{ RowBox[{"h", "=", "0.1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"c", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Tau]", "=", FractionBox["h", RowBox[{"2", " ", "c"}]]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"T", "=", "5"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Ceiling", "[", RowBox[{"20", "/", "h"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "=", RowBox[{"Ceiling", "[", RowBox[{"T", "/", "\[Tau]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"u0", "[", "x_", "]"}], ":=", TagBox[GridBox[{ {"\[Piecewise]", GridBox[{ {"25", RowBox[{"x", "\[LessEqual]", "0"}]}, { RowBox[{"25", "-", RowBox[{"25", "x"}]}], RowBox[{"0", "\[LessEqual]", "x", "\[LessEqual]", "1"}]}, {"0", RowBox[{"x", "\[GreaterEqual]", "1"}]} }, AllowedDimensions->{2, Automatic}, Editable->True, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.84]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}, Selectable->True]} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.35]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], "Piecewise", DeleteWithContents->True, Editable->False, SelectWithContents->True, Selectable->False]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"n", "+", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"m", "+", "1"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"-", "10"}], "+", RowBox[{"i", " ", "h"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", "n"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", " ", RowBox[{"i", "\[LessEqual]", RowBox[{"n", "+", "1"}]}], ",", " ", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "=", RowBox[{"u0", "[", RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}]}]}], "\[IndentingNewLine]", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"j", "=", "1"}], ",", " ", RowBox[{"j", "\[LessEqual]", "m"}], ",", " ", RowBox[{"j", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "2"}], ",", RowBox[{"i", "\[LessEqual]", "n"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", RowBox[{"[", RowBox[{"i", ",", RowBox[{"j", "+", "1"}]}], "]"}], "]"}], "=", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", RowBox[{"c", " ", RowBox[{"\[Tau]", "/", "h"}]}]}], ")"}], RowBox[{"y", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], "+", RowBox[{"c", " ", RowBox[{"\[Tau]", "/", "h"}], " ", RowBox[{"y", "[", RowBox[{"[", RowBox[{ RowBox[{"i", "-", "1"}], ",", "j"}], "]"}], "]"}]}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", RowBox[{"[", RowBox[{"1", ",", RowBox[{"j", "+", "1"}]}], "]"}], "]"}], "=", "25"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", RowBox[{"[", RowBox[{ RowBox[{"n", "+", "1"}], ",", RowBox[{"j", "+", "1"}]}], "]"}], "]"}], "=", RowBox[{"y", "[", RowBox[{"[", RowBox[{"n", ",", RowBox[{"j", "+", "1"}]}], "]"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}]}], "Input", CellChangeTimes->{{3.6729945350826855`*^9, 3.6729946326762676`*^9}, { 3.6729947141439276`*^9, 3.6729948038280573`*^9}, {3.6729948894419537`*^9, 3.6729949365006456`*^9}, {3.672996709863076*^9, 3.672996738751728*^9}}], Cell[BoxData[ RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"y", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"n", "+", "1"}]}], "}"}]}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"m", "+", "1"}], ",", "1"}], "}"}]}], "\[IndentingNewLine]", "]"}]], "Input", CellChangeTimes->{{3.6729948080743*^9, 3.672994872975012*^9}}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`j$$ = 100, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold[$CellContext`j$$], 1, 101, 1}}, Typeset`size$$ = { 360., {113., 117.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`j$969$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`j$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`j$$, $CellContext`j$969$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> ListPlot[ Table[{ Part[$CellContext`x, $CellContext`i], Part[$CellContext`y, $CellContext`i, $CellContext`j$$]}, \ {$CellContext`i, 1, $CellContext`n + 1}]], "Specifications" :> {{$CellContext`j$$, 1, 101, 1}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{409., {172., 177.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"y", "[", RowBox[{"[", "2", "]"}], "]"}]], "Input", CellChangeTimes->{{3.672994882975584*^9, 3.67299488395264*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"u0", "[", "0.01`", "]"}], ",", RowBox[{ RowBox[{"5000.`", " ", RowBox[{"u0", "[", "0.`", "]"}]}], "-", RowBox[{"4999.`", " ", RowBox[{"u0", "[", "0.01`", "]"}]}]}]}], "}"}]], "Output", CellChangeTimes->{3.672994884215655*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData["\[Tau]"], "Input", CellChangeTimes->{{3.672999850566706*^9, 3.67299985080472*^9}}], Cell[BoxData["0.05`"], "Output", CellChangeTimes->{3.6729998510257325`*^9}] }, Open ]] }, WindowSize->{1920, 998}, WindowMargins->{{-8, Automatic}, {Automatic, -8}}, FrontEndVersion->"8.0 for Microsoft Windows (64-bit) (November 7, 2010)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[558, 20, 5125, 151, 442, "Input"], Cell[5686, 173, 725, 21, 92, "Input"], Cell[6414, 196, 1620, 35, 366, InheritFromParent], Cell[CellGroupData[{ Cell[8059, 235, 142, 3, 31, "Input"], Cell[8204, 240, 303, 9, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8544, 254, 97, 1, 31, "Input"], Cell[8644, 257, 76, 1, 30, "Output"] }, Open ]] } ] *) (* End of internal cache information *)