(* 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[ 19656, 528] NotebookOptionsPosition[ 19046, 502] NotebookOutlinePosition[ 19407, 518] CellTagsIndexPosition[ 19364, 515] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Derivative Approximations", "Title", CellChangeTimes->{{3.41195102154713*^9, 3.411951028950885*^9}}, TextAlignment->Center], Cell["\<\ by Ruth Dover Illinois Mathematics and Science Academy\ \>", "Subsubtitle", CellChangeTimes->{{3.692641236005176*^9, 3.6926412466809397`*^9}}], Cell[TextData[{ "This notebook includes two sections - one using the symmetric approximation \ and the second using the one-sided version (that leads to a definition of the \ derivative.\nIn each section, edit the function and the min and max values \ for ", StyleBox["x", FontSlant->"Italic"], " only. Execute the cell and use the sliders. (Please don't mess up the \ rest of the stuff!)" }], "Text", CellChangeTimes->{{3.412210068485958*^9, 3.412210121566806*^9}, { 3.692641306971383*^9, 3.692641377049821*^9}}], Cell[CellGroupData[{ Cell["symmetric derivative approximation", "Section", CellChangeTimes->{{3.411952315278473*^9, 3.41195232529712*^9}, { 3.41220967834126*^9, 3.412209685037837*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{ SuperscriptBox["x", "3"], "-", RowBox[{"3", SuperscriptBox["x", "2"]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"xmin", "=", RowBox[{"-", "1"}]}], ";", " ", RowBox[{"xmax", " ", "=", "3"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Don", "'"}], "t", " ", "mess", " ", "with", " ", "the", " ", "coding", " ", RowBox[{"below", "!"}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"fder", "[", "x_", "]"}], ":=", RowBox[{"Evaluate", "[", RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", " ", "x"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"mypl", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"xmin", "-", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}], ",", " ", RowBox[{"xmax", "+", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"yrange", "=", RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", " ", "2"}], "]"}], "]"}], "-", RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", " ", "1"}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", "a", "]"}], "+", RowBox[{ RowBox[{"fder", "[", "a", "]"}], RowBox[{"(", RowBox[{"x", "-", "a"}], ")"}]}]}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"xmin", "-", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}], ",", " ", RowBox[{"xmax", "+", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}]}], "}"}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", " ", "1"}], "]"}], "]"}], "-", RowBox[{".2", "yrange"}]}], ",", " ", RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", "2"}], "]"}], "]"}], "+", RowBox[{".2", "yrange"}]}]}], "}"}]}], "}"}]}], ",", " ", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "Thick", "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"Thickness", "[", ".005", "]"}], ",", " ", "Red"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"Style", "[", RowBox[{ RowBox[{"StringForm", "[", RowBox[{"\"\\"", ",", RowBox[{"N", "[", FractionBox[ RowBox[{"(", RowBox[{ RowBox[{"f", "[", RowBox[{"a", "+", "h"}], "]"}], "-", RowBox[{"f", "[", RowBox[{"a", "-", "h"}], "]"}]}], ")"}], RowBox[{"2", "h"}]], "]"}]}], "]"}], ",", " ", "Purple", ",", " ", "14"}], "]"}], ",", " ", RowBox[{"Style", "[", RowBox[{ RowBox[{"StringForm", "[", RowBox[{"\"\< tangent slope = ``\>\"", ",", " ", RowBox[{"N", "[", RowBox[{"fder", "[", "a", "]"}], "]"}]}], "]"}], ",", "Magenta", ",", " ", "14"}], "]"}]}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"Epilog", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "Large", "]"}], ",", " ", "Purple", ",", " ", RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"a", "+", "h"}], ",", " ", RowBox[{"f", "[", RowBox[{"a", "+", "h"}], "]"}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "Large", "]"}], ",", " ", "Purple", ",", " ", RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"a", "-", "h"}], ",", " ", RowBox[{"f", "[", RowBox[{"a", "-", "h"}], "]"}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "Large", "]"}], ",", " ", "Magenta", ",", " ", RowBox[{"Point", "[", RowBox[{"{", RowBox[{"a", ",", " ", RowBox[{"f", "[", "a", "]"}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"Purple", ",", " ", RowBox[{"Thickness", "[", ".005", "]"}], ",", " ", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"a", "-", "h"}], ",", " ", RowBox[{"f", "[", RowBox[{"a", "-", "h"}], "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"a", "+", "h"}], ",", " ", RowBox[{"f", "[", RowBox[{"a", "+", "h"}], "]"}]}], "}"}]}], "}"}], "]"}]}], "}"}]}], "}"}]}]}], "]"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a", ",", RowBox[{"xmin", " ", "+", RowBox[{ RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}], "/", "2"}]}], ",", " ", "\"\\""}], "}"}], ",", " ", "xmin", ",", " ", "xmax", ",", " ", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"h", ",", " ", ".001", ",", RowBox[{ RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}], "/", "3"}], ",", " ", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}]}], "]"}]}], "Input", CellChangeTimes->{{3.411950598426127*^9, 3.411950619929777*^9}, { 3.4119506820216303`*^9, 3.411950815537359*^9}, {3.411950865852982*^9, 3.411950978232911*^9}, {3.411951075085533*^9, 3.411951315557534*^9}, { 3.411951347881444*^9, 3.4119514698927917`*^9}, {3.4119515242303057`*^9, 3.411951571191279*^9}, {3.4119516330073757`*^9, 3.4119516423109417`*^9}, { 3.411951723777913*^9, 3.4119517387911882`*^9}, 3.41195181055943*^9, { 3.4119519290251837`*^9, 3.4119521298234777`*^9}, {3.411952175160697*^9, 3.4119522035033073`*^9}, {3.412204468664954*^9, 3.4122044712269497`*^9}, { 3.4122045766679707`*^9, 3.412204663150526*^9}, {3.412204743241754*^9, 3.412204749601716*^9}, {3.41220497303508*^9, 3.412205003393211*^9}, { 3.41220504007302*^9, 3.41220514713304*^9}, {3.41220517725772*^9, 3.412205193194993*^9}, {3.412205648856154*^9, 3.412205669182455*^9}, { 3.412205850056549*^9, 3.412205913918647*^9}, {3.4122059840186787`*^9, 3.412206096832378*^9}, {3.412206741219634*^9, 3.412206750280238*^9}, { 3.412207308412109*^9, 3.412207313245823*^9}, {3.412207361170374*^9, 3.412207509254347*^9}, {3.412207626321281*^9, 3.412207647201109*^9}, { 3.4122076778448887`*^9, 3.412207735616784*^9}, 3.412208629053541*^9, { 3.4122086794045897`*^9, 3.412208684056962*^9}, {3.4122087203510838`*^9, 3.412208753524428*^9}, {3.412208820101919*^9, 3.412209031009725*^9}, { 3.412209255346675*^9, 3.412209256194202*^9}, {3.412209416493577*^9, 3.41220943172919*^9}, {3.412209587163554*^9, 3.4122096230343237`*^9}, 3.412209724853459*^9, {3.412349817994615*^9, 3.412349829598516*^9}, { 3.412349943592455*^9, 3.412349947650284*^9}, {3.41235211477173*^9, 3.4123522442760887`*^9}, {3.4123523743321333`*^9, 3.412352411388033*^9}, { 3.471354736262308*^9, 3.471354739630254*^9}, {3.525521980693115*^9, 3.525522020527886*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["one-sided derivative approximation", "Section", CellChangeTimes->{{3.4122092851697807`*^9, 3.412209296857058*^9}, 3.4122096468633137`*^9}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{ SuperscriptBox["x", "3"], "-", RowBox[{"3", SuperscriptBox["x", "2"]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"xmin", "=", RowBox[{"-", "1"}]}], ";", " ", RowBox[{"xmax", " ", "=", "3"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Don", "'"}], "t", " ", "mess", " ", "with", " ", "the", " ", "coding", " ", RowBox[{"below", "!"}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"fder", "[", "x_", "]"}], ":=", RowBox[{"Evaluate", "[", RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", " ", "x"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"mypl", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"xmin", "-", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}], ",", " ", RowBox[{"xmax", "+", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"yrange", "=", RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", " ", "2"}], "]"}], "]"}], "-", RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", " ", "1"}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", RowBox[{ RowBox[{"f", "[", "a", "]"}], "+", RowBox[{ RowBox[{"fder", "[", "a", "]"}], RowBox[{"(", RowBox[{"x", "-", "a"}], ")"}]}]}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"xmin", "-", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}], ",", " ", RowBox[{"xmax", "+", RowBox[{".05", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}]}]}], "}"}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", " ", "1"}], "]"}], "]"}], "-", RowBox[{".2", "yrange"}]}], ",", " ", RowBox[{ RowBox[{ RowBox[{"PlotRange", "[", "mypl", "]"}], "[", RowBox[{"[", RowBox[{"2", ",", "2"}], "]"}], "]"}], "+", RowBox[{".2", "yrange"}]}]}], "}"}]}], "}"}]}], ",", " ", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "Thick", "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"Thickness", "[", ".005", "]"}], ",", " ", "Red"}], "\[IndentingNewLine]", "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"Style", "[", RowBox[{ RowBox[{"StringForm", "[", RowBox[{"\"\\"", ",", RowBox[{"N", "[", FractionBox[ RowBox[{"(", RowBox[{ RowBox[{"f", "[", RowBox[{"a", "+", "h"}], "]"}], "-", RowBox[{"f", "[", "a", "]"}]}], ")"}], "h"], "]"}]}], "]"}], ",", " ", "Purple", ",", " ", "14"}], "]"}], ",", " ", RowBox[{"Style", "[", RowBox[{ RowBox[{"StringForm", "[", RowBox[{"\"\< tangent slope = ``\>\"", ",", " ", RowBox[{"N", "[", RowBox[{"fder", "[", "a", "]"}], "]"}]}], "]"}], ",", "Magenta", ",", " ", "14"}], "]"}]}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"Epilog", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "Large", "]"}], ",", " ", "Purple", ",", " ", RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"a", "+", "h"}], ",", " ", RowBox[{"f", "[", RowBox[{"a", "+", "h"}], "]"}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "Large", "]"}], ",", " ", "Magenta", ",", " ", RowBox[{"Point", "[", RowBox[{"{", RowBox[{"a", ",", " ", RowBox[{"f", "[", "a", "]"}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"Purple", ",", " ", RowBox[{"Thickness", "[", ".005", "]"}], ",", " ", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a", ",", " ", RowBox[{"f", "[", "a", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"a", "+", "h"}], ",", " ", RowBox[{"f", "[", RowBox[{"a", "+", "h"}], "]"}]}], "}"}]}], "}"}], "]"}]}], "}"}]}], "}"}]}]}], "]"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a", ",", RowBox[{"xmin", " ", "+", RowBox[{ RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}], "/", "2"}]}], ",", " ", "\"\\""}], "}"}], ",", " ", "xmin", ",", " ", "xmax", ",", " ", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"h", ",", " ", RowBox[{ RowBox[{"-", RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}]}], "/", "3"}], ",", RowBox[{ RowBox[{"(", RowBox[{"xmax", "-", "xmin"}], ")"}], "/", "3"}], ",", " ", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}]}], "]"}]}], "Input", CellChangeTimes->{{3.411950598426127*^9, 3.411950619929777*^9}, { 3.4119506820216303`*^9, 3.411950815537359*^9}, {3.411950865852982*^9, 3.411950978232911*^9}, {3.411951075085533*^9, 3.411951315557534*^9}, { 3.411951347881444*^9, 3.4119514698927917`*^9}, {3.4119515242303057`*^9, 3.411951571191279*^9}, {3.4119516330073757`*^9, 3.4119516423109417`*^9}, { 3.411951723777913*^9, 3.4119517387911882`*^9}, 3.41195181055943*^9, { 3.4119519290251837`*^9, 3.4119521298234777`*^9}, {3.411952175160697*^9, 3.4119522035033073`*^9}, {3.412204468664954*^9, 3.4122044712269497`*^9}, { 3.4122045766679707`*^9, 3.412204663150526*^9}, {3.412204743241754*^9, 3.412204749601716*^9}, {3.41220497303508*^9, 3.412205003393211*^9}, { 3.41220504007302*^9, 3.41220514713304*^9}, {3.41220517725772*^9, 3.412205193194993*^9}, {3.412205648856154*^9, 3.412205669182455*^9}, { 3.412205850056549*^9, 3.412205913918647*^9}, {3.4122059840186787`*^9, 3.412206096832378*^9}, {3.412206741219634*^9, 3.412206750280238*^9}, { 3.412207308412109*^9, 3.412207313245823*^9}, {3.412207361170374*^9, 3.412207509254347*^9}, {3.412207626321281*^9, 3.412207647201109*^9}, { 3.4122076778448887`*^9, 3.412207735616784*^9}, 3.412208629053541*^9, { 3.4122086794045897`*^9, 3.412208684056962*^9}, {3.4122087203510838`*^9, 3.412208753524428*^9}, {3.412208820101919*^9, 3.412209031009725*^9}, { 3.412209255346675*^9, 3.412209256194202*^9}, {3.412209416493577*^9, 3.41220943172919*^9}, {3.412209587163554*^9, 3.4122096230343237`*^9}, 3.4122097168566103`*^9, {3.412209769844184*^9, 3.4122097728342867`*^9}, { 3.412209821103496*^9, 3.412209863886677*^9}, {3.412209918951797*^9, 3.4122099209274178`*^9}, {3.412209988105721*^9, 3.412210012120503*^9}, 3.412349837297525*^9, {3.4123499571295023`*^9, 3.4123499597356358`*^9}, { 3.412352441101289*^9, 3.412352451489311*^9}, {3.4713547431972313`*^9, 3.471354746629971*^9}, {3.525521018189745*^9, 3.525521067825344*^9}, { 3.5255210987402897`*^9, 3.525521102159699*^9}, {3.525521175144158*^9, 3.5255211978826113`*^9}, {3.5255212387995157`*^9, 3.525521245547628*^9}, { 3.525521314819231*^9, 3.525521325921845*^9}, {3.525521468879471*^9, 3.52552148317312*^9}, {3.525521886624741*^9, 3.5255219079803543`*^9}, { 3.525521945231477*^9, 3.5255219461907187`*^9}}] }, Open ]] }, Open ]] }, WindowSize->{909, 701}, WindowMargins->{{Automatic, 545}, {Automatic, 243}}, FrontEndVersion->"11.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (September \ 21, 2016)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 131, 2, 92, "Title"], Cell[701, 26, 153, 4, 49, "Subsubtitle"], Cell[857, 32, 523, 11, 87, "Text"], Cell[CellGroupData[{ Cell[1405, 47, 166, 2, 64, "Section"], Cell[1574, 51, 8578, 221, 435, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[10189, 277, 149, 2, 64, "Section"], Cell[10341, 281, 8677, 217, 414, "Input"] }, Open ]] }, Open ]] } ] *)