Cell[CellGroupData[{Cell[BoxData[ RowBox[{" ", RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"p", ",", "q"}], "}"}], ",", " ", RowBox[{"(*", " ", RowBox[{ "To", " ", "avoid", " ", "pts", " ", "having", " ", "the", " ", "same", " ", "x", " ", RowBox[{"coordinate", ":"}]}], " ", "*)"}], " ", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"p", ",", "q"}], "}"}], "=", RowBox[{"Transpose", "@", "pts"}]}], ";", " ", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{"Outer", "[", RowBox[{"Equal", ",", "p", ",", "p"}], "]"}], "!=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"#", "!=", "0"}], "&"}], ",", RowBox[{"IdentityMatrix", "[", RowBox[{"Length", "@", "p"}], "]"}], ",", RowBox[{"{", "2", "}"}]}], "]"}]}], ",", RowBox[{"p", "=", RowBox[{"p", "+", RowBox[{"Table", "[", RowBox[{ RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{"0", ",", ".001"}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"Length", "@", "p"}], "}"}]}], "]"}]}]}]}], "]"}], ";", " ", RowBox[{"pts", "=", RowBox[{"Transpose", "@", RowBox[{"{", RowBox[{"p", ",", "q"}], "}"}]}]}], ";", " ", RowBox[{ RowBox[{"myf", "[", "x_", "]"}], ":=", RowBox[{"Evaluate", "[", RowBox[{"InterpolatingPolynomial", "[", RowBox[{"pts", ",", " ", "x"}], "]"}], "]"}]}], ";", " ", RowBox[{ RowBox[{"fder", "[", "x_", "]"}], ":=", RowBox[{"Evaluate", "[", RowBox[{"D", "[", RowBox[{ RowBox[{"myf", "[", "x", "]"}], ",", " ", "x"}], "]"}], "]"}]}], ";", " ", RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"myf", "[", "x", "]"}], ",", " ", RowBox[{"fder", "[", "x", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"-", "2"}], ",", " ", "2"}], "}"}], ",", RowBox[{"PlotStyle", "->", " ", "Thick"}], ",", " ", RowBox[{"PlotRange", "->", "10"}], ",", RowBox[{"ImageSize", "->", RowBox[{"{", RowBox[{"500", ",", "300"}], "}"}]}]}], "]"}]}]}], " ", "]"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"pts", ",", RowBox[{"(", RowBox[{ RowBox[{"SeedRandom", "[", "123", "]"}], ";", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{"k", ",", " ", RowBox[{"k", "+", ".8"}]}], "}"}], "]"}], ",", " ", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", " ", "2"}], "}"}], "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"k", ",", " ", RowBox[{"-", "2"}], ",", " ", "1.2", ",", " ", ".8"}], "}"}]}], "]"}]}], ")"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", RowBox[{"-", "10"}]}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "10"}], "}"}], ",", " ", "Locator"}], "}"}], ",", RowBox[{"TrackedSymbols", "->", RowBox[{"{", "pts", "}"}]}]}], "]"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.439940146483614*^9, 3.439940147501052*^9}, { 3.4595443828222065`*^9, 3.4595443901972537`*^9}, { 3.459544468322754*^9, 3.459544507385504*^9}, {3.459544600136097*^9, 3.459544612854929*^9}, {3.4597678736474977`*^9, 3.459767957348867*^9}, {3.565021636808498*^9, 3.565021725473576*^9}, {3.565021757807289*^9, 3.565021759482336*^9}, {3.565021832777145*^9, 3.565021833742635*^9}, {3.565021892321951*^9, 3.5650219800060253`*^9}, {3.565022060830118*^9, 3.565022070327137*^9}, {3.5650221086316957`*^9, 3.565022114689097*^9}, {3.5650223801308727`*^9, 3.565022407253674*^9}, 3.7607750913712883`*^9}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`pts$$ = {{-1.6354246900240652`, 1.9113036749408856`}, {-0.44542828538222734`, 1.8488629955961837`}, {-0.15812167936712385`, \ -0.13316574942716564`}, {0.4493106518295985, -0.4574219824167729}, { 1.543870728415978, 1.1149758867780077`}}, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`pts$$], {{-1.6354246900240652`, 1.9113036749408856`}, {-0.44542828538222734`, 1.8488629955961837`}, {-0.15812167936712385`, \ -0.13316574942716564`}, {0.4493106518295985, -0.4574219824167729}, { 1.543870728415978, 1.1149758867780077`}}}, {-2, -10}, {2, 10}}}, Typeset`size$$ = {500., {148., 152.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`pts$1673$$ = {0, 0}}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`pts$$ = {{-1.6354246900240652`, 1.9113036749408856`}, {-0.44542828538222734`, 1.8488629955961837`}, {-0.15812167936712385`, \ -0.13316574942716564`}, {0.4493106518295985, -0.4574219824167729}, { 1.543870728415978, 1.1149758867780077`}}}, "ControllerVariables" :> { Hold[$CellContext`pts$$, $CellContext`pts$1673$$, {0, 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" :> Module[{$CellContext`p$, $CellContext`q$}, {$CellContext`p$, \ $CellContext`q$} = Transpose[$CellContext`pts$$]; While[Outer[Equal, $CellContext`p$, $CellContext`p$] != Map[# != 0& , IdentityMatrix[ Length[$CellContext`p$]], { 2}], $CellContext`p$ = $CellContext`p$ + Table[ RandomReal[{0, 0.001}], { Length[$CellContext`p$]}]]; $CellContext`pts$$ = Transpose[{$CellContext`p$, $CellContext`q$}]; \ $CellContext`myf[ Pattern[$CellContext`x$, Blank[]]] := Evaluate[ InterpolatingPolynomial[$CellContext`pts$$, \ $CellContext`x$]]; $CellContext`fder[ Pattern[$CellContext`x, Blank[]]] := Evaluate[ D[ $CellContext`myf[$CellContext`x], $CellContext`x]]; Plot[{ $CellContext`myf[$CellContext`x], $CellContext`fder[$CellContext`x]}, {$CellContext`x, -2, 2}, PlotStyle -> Thick, PlotRange -> 10, ImageSize -> {500, 300}]], "Specifications" :> {{{$CellContext`pts$$, \ {{-1.6354246900240652`, 1.9113036749408856`}, {-0.44542828538222734`, 1.8488629955961837`}, {-0.15812167936712385`, \ -0.13316574942716564`}, {0.4493106518295985, -0.4574219824167729}, { 1.543870728415978, 1.1149758867780077`}}}, {-2, -10}, {2, 10}, ControlType -> Locator}}, "Options" :> {TrackedSymbols -> {$CellContext`pts$$}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{551., {180., 186.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{3.76077509137155*^9}, CellID->1915913288] }, {2}]]