Newer
Older
Lecture_repo / Lectures_my / NumMet / 2016 / Lecture10 / fixed-point.nb
@Danny van Dyk Danny van Dyk on 14 Nov 2016 15 KB Add missing files for lecture 10
(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 10.3' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     15417,        465]
NotebookOptionsPosition[     13779,        402]
NotebookOutlinePosition[     14115,        417]
CellTagsIndexPosition[     14072,        414]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"f", "[", 
    RowBox[{"x_", ",", " ", "y_"}], "]"}], " ", ":=", " ", 
   RowBox[{
    RowBox[{"-", "2.1"}], "y"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"h", " ", "=", " ", "0.5"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"x0", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"y0", " ", "=", " ", "1"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"yNextValues", " ", "=", " ", 
   RowBox[{"{", "}"}]}], ";"}]}], "Input",
 CellChangeTimes->{{3.688109047059428*^9, 3.6881091615507298`*^9}, {
  3.688109196246677*^9, 3.688109226023087*^9}, {3.6881093786779633`*^9, 
  3.688109383397826*^9}, {3.688110265128317*^9, 3.6881102693437967`*^9}, {
  3.688110342415762*^9, 3.6881103425034227`*^9}, {3.688110560365991*^9, 
  3.688110561005869*^9}}],

Cell["explicit Euler step with h 0.5", "Text",
 CellChangeTimes->{{3.688109042375373*^9, 3.688109081215054*^9}, 
   3.688109115526836*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{"x0", ",", " ", "y0"}], "]"}]}]}]}], "]"}]], "Input",
 CellChangeTimes->{{3.688109023442931*^9, 3.688109034352015*^9}, 
   3.6881090887992973`*^9, {3.688109133567192*^9, 3.6881092158464327`*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"-", "0.050000000000000044`"}], "}"}]], "Output",
 CellChangeTimes->{{3.6881092163858*^9, 3.6881092272861643`*^9}, 
   3.688109387188862*^9, 3.688110272361723*^9, {3.688110344468812*^9, 
   3.688110350385796*^9}, 3.688110565279694*^9}]
}, Open  ]],

Cell["implicit Euler step", "Text",
 CellChangeTimes->{{3.688109251600007*^9, 3.6881092747580843`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input",
 CellChangeTimes->{{3.688109281639778*^9, 3.688109302422203*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`"}], "}"}]], "Output",\

 CellChangeTimes->{3.688109302822234*^9, 3.688109390123254*^9, 
  3.688110272427383*^9, 3.688110350460581*^9, 3.6881105653414927`*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}]}], "}"}]], "Output",
 CellChangeTimes->{3.688109310311212*^9, 3.688109390988352*^9, 
  3.6881102724889593`*^9, 3.68811035053411*^9, 3.688110565396331*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}], ",", "1.11038125`"}], 
  "}"}]], "Output",
 CellChangeTimes->{3.6881093159400263`*^9, 3.688109392546154*^9, 
  3.688110272540285*^9, 3.6881103506078377`*^9, 3.688110565400127*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}], ",", "1.11038125`", ",", 
   RowBox[{"-", "0.16590031250000026`"}]}], "}"}]], "Output",
 CellChangeTimes->{3.688109473510303*^9, 3.6881102726069508`*^9, 
  3.688110350612899*^9, 3.6881105654640217`*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}], ",", "1.11038125`", ",", 
   RowBox[{"-", "0.16590031250000026`"}], ",", "1.1741953281250002`"}], 
  "}"}]], "Output",
 CellChangeTimes->{3.6881095000395107`*^9, 3.688110272668214*^9, 
  3.688110350675782*^9, 3.68811056553791*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}], ",", "1.11038125`", ",", 
   RowBox[{"-", "0.16590031250000026`"}], ",", "1.1741953281250002`", ",", 
   RowBox[{"-", "0.2329050945312503`"}]}], "}"}]], "Output",
 CellChangeTimes->{3.688109503620624*^9, 3.688110272735523*^9, 
  3.688110350738181*^9, 3.68811056561063*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}], ",", "1.11038125`", ",", 
   RowBox[{"-", "0.16590031250000026`"}], ",", "1.1741953281250002`", ",", 
   RowBox[{"-", "0.2329050945312503`"}], ",", "1.2445503492578127`"}], 
  "}"}]], "Output",
 CellChangeTimes->{3.68810950655245*^9, 3.688110272805271*^9, 
  3.688110350802301*^9, 3.6881105656837397`*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"AppendTo", "[", 
  RowBox[{"yNextValues", ",", " ", 
   RowBox[{"y0", " ", "+", " ", 
    RowBox[{"h", " ", "*", " ", 
     RowBox[{"f", "[", 
      RowBox[{
       RowBox[{"x0", " ", "+", " ", "h"}], ",", " ", 
       RowBox[{"yNextValues", "[", 
        RowBox[{"[", 
         RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}]}]}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"-", "0.050000000000000044`"}], ",", "1.0525`", ",", 
   RowBox[{"-", "0.10512500000000014`"}], ",", "1.11038125`", ",", 
   RowBox[{"-", "0.16590031250000026`"}], ",", "1.1741953281250002`", ",", 
   RowBox[{"-", "0.2329050945312503`"}], ",", "1.2445503492578127`", ",", 
   RowBox[{"-", "0.3067778667207035`"}]}], "}"}]], "Output",
 CellChangeTimes->{3.688109510119643*^9, 3.688110272870085*^9, 
  3.688110350875483*^9, 3.688110565688951*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"xValues", " ", "=", " ", 
  RowBox[{"{", " ", 
   RowBox[{
   "0.5", ",", " ", "0.5", ",", " ", "0.5", ",", " ", "0.5", ",", " ", "0.5", 
    ",", " ", "0.5", ",", " ", "0.5", ",", " ", "0.5", ",", " ", "0.5"}], 
   "}"}]}]], "Input",
 CellChangeTimes->{{3.6881094113321342`*^9, 3.688109427557271*^9}, {
  3.688109529300817*^9, 3.688109540588752*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
  "0.5`", ",", "0.5`", ",", "0.5`", ",", "0.5`", ",", "0.5`", ",", "0.5`", 
   ",", "0.5`", ",", "0.5`", ",", "0.5`"}], "}"}]], "Output",
 CellChangeTimes->{
  3.688109429506762*^9, {3.688109526925215*^9, 3.688109541022224*^9}, 
   3.6881102729397783`*^9, 3.688110350945903*^9, 3.68811056575429*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"pValues", " ", "=", " ", 
  RowBox[{"Table", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"i", ",", " ", 
      RowBox[{"yNextValues", "[", 
       RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", " ", 
    RowBox[{"{", 
     RowBox[{"i", ",", " ", "1", ",", " ", "9"}], "}"}]}], "]"}]}]], "Input",
 CellChangeTimes->{{3.688109435316019*^9, 3.688109477381198*^9}, {
  3.688109551381194*^9, 3.6881095636526012`*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"1", ",", 
     RowBox[{"-", "0.050000000000000044`"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"2", ",", "1.0525`"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"3", ",", 
     RowBox[{"-", "0.10512500000000014`"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"4", ",", "1.11038125`"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"5", ",", 
     RowBox[{"-", "0.16590031250000026`"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"6", ",", "1.1741953281250002`"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"7", ",", 
     RowBox[{"-", "0.2329050945312503`"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"8", ",", "1.2445503492578127`"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"9", ",", 
     RowBox[{"-", "0.3067778667207035`"}]}], "}"}]}], "}"}]], "Output",
 CellChangeTimes->{{3.688109451265951*^9, 3.68810947771984*^9}, {
   3.688109560290724*^9, 3.688109563868795*^9}, 3.688110272995986*^9, 
   3.6881103510253687`*^9, 3.6881105658340073`*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"Show", "[", "\[IndentingNewLine]", 
  RowBox[{
   RowBox[{"Plot", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Exp", "[", 
      RowBox[{"-", "0.5"}], "]"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"i", ",", " ", "1", ",", " ", "9"}], "}"}]}], 
    "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
   RowBox[{
   "ListPlot", "[", "\[IndentingNewLine]", "pValues", "\[IndentingNewLine]", 
    "]"}]}], "\[IndentingNewLine]", "]"}]], "Input",
 CellChangeTimes->{{3.6881094064823713`*^9, 3.688109464029291*^9}, {
  3.6881095680930147`*^9, 3.6881096166203403`*^9}}],

Cell[BoxData[
 GraphicsBox[{{{}, {}, 
    {RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[
     1.], LineBox[CompressedData["
1:eJxTTMoPSmViYGAwAWIQvaTxsjYDwwd7rmn5fzZlPLaX2NGxfIbjRzi/552t
smHzJzifMTVIo8bmK5yvu+XMxYnHv8P5axzz3j50/QXnb7+xU8zn1x84v9Ij
+0lDw384/0nC4/vpcowOMP7WPUvadMqY4PyHLDPrr21jhvMvBybV9wqxwvkK
3XEXNcPZ4PzpyXkxyVPZ4fwrDsHvVr7jgPNzuLIvXTXggvNP3wjfy9fHDecH
u0U8fPKEB843W9AdvkCFD85/8G/ylYx6fjj/85Lngd2JAnD+zTPv97wQEITz
Q440HhHZi+D/MdQt3RwrBOdzKDmvvMEtDOc7dhS1FaxD8Pn3aTNc9xWB8x3K
/P8e/oXgz1/Ss1h5jiicnxhqcpbTWwzO33E1dfK+bwi+zZkNTM+micP5yq5p
Xye7SMD5FiamE7c8Q/Affeo9ubhVEs5/bxzYKmkkBedrvtZ9xXgZwT+uUnqp
oFEazp905WpykIoMnP8p+MBEpiMI/tZQUWfLQlk4f9nZ5rmPhOTg/F/HY6qF
DiH4jyfu/yqQJw/n/30xl8eRXQHOt/QSfGATh+D3pAlyFK1H8FdmhdXx/Ufw
f6wPMMsLVYTz4zZcd2JfhuCLLlg3j/kygn+mv/XX//8IPgDh0JgR
      "]]}}, {{}, {{}, 
     {RGBColor[0.368417, 0.506779, 0.709798], PointSize[
      0.012833333333333334`], AbsoluteThickness[1.6], 
      PointBox[{{1., -0.050000000000000044`}, {2., 1.0525}, {
       3., -0.10512500000000014`}, {4., 1.11038125}, {
       5., -0.16590031250000026`}, {6., 1.1741953281250002`}, {
       7., -0.2329050945312503}, {8., 1.2445503492578127`}, {
       9., -0.3067778667207035}}]}, {}}, {}}},
  AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
  Axes->{True, True},
  AxesLabel->{None, None},
  AxesOrigin->{2., 0},
  DisplayFunction->Identity,
  Frame->{{False, False}, {False, False}},
  FrameLabel->{{None, None}, {None, None}},
  FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
  GridLines->{None, None},
  GridLinesStyle->Directive[
    GrayLevel[0.5, 0.4]],
  Method->{
   "DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" -> 
    AbsolutePointSize[6], "ScalingFunctions" -> None},
  PlotRange->{{1, 9}, {0., 1.2130613194252668`}},
  PlotRangeClipping->True,
  PlotRangePadding->{{
     Scaled[0.02], 
     Scaled[0.02]}, {
     Scaled[0.05], 
     Scaled[0.05]}},
  Ticks->{Automatic, Automatic}]], "Output",
 CellChangeTimes->{{3.68810946439671*^9, 3.6881094785983686`*^9}, {
   3.6881095647315187`*^9, 3.6881095801719913`*^9}, 3.688109617483754*^9, 
   3.6881102730755672`*^9, 3.68811035114158*^9, 3.688110565938201*^9}]
}, Open  ]]
},
WindowSize->{862, 1179},
WindowMargins->{{0, Automatic}, {Automatic, 19}},
FrontEndVersion->"10.3 for Linux x86 (64-bit) (October 9, 2015)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 843, 20, 121, "Input"],
Cell[1404, 42, 138, 2, 31, "Text"],
Cell[CellGroupData[{
Cell[1567, 48, 376, 8, 32, "Input"],
Cell[1946, 58, 274, 5, 32, "Output"]
}, Open  ]],
Cell[2235, 66, 103, 1, 31, "Text"],
Cell[CellGroupData[{
Cell[2363, 71, 434, 11, 32, "Input"],
Cell[2800, 84, 255, 6, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[3092, 95, 368, 10, 32, "Input"],
Cell[3463, 107, 300, 6, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[3800, 118, 368, 10, 32, "Input"],
Cell[4171, 130, 326, 7, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[4534, 142, 368, 10, 32, "Input"],
Cell[4905, 154, 349, 7, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[5291, 166, 368, 10, 32, "Input"],
Cell[5662, 178, 377, 8, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[6076, 191, 368, 10, 32, "Input"],
Cell[6447, 203, 419, 8, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[6903, 216, 368, 10, 32, "Input"],
Cell[7274, 228, 452, 9, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[7763, 242, 368, 10, 32, "Input"],
Cell[8134, 254, 495, 9, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[8666, 268, 375, 8, 32, "Input"],
Cell[9044, 278, 339, 7, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[9420, 290, 440, 11, 32, "Input"],
Cell[9863, 303, 1024, 28, 55, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[10924, 336, 628, 14, 209, "Input"],
Cell[11555, 352, 2208, 47, 241, "Output"]
}, Open  ]]
}
]
*)

(* End of internal cache information *)