Cell[CellGroupData[{Cell[BoxData[ RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "samples", ",", "signal", ",", "splineInterpolation", ",", "poly"}], "}"}], ",", " ", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ "example", "===", "\"\\""}], ",", " ", RowBox[{"signal", "=", RowBox[{ RowBox[{"Cos", "[", RowBox[{ RowBox[{"freq", " ", "\[Pi]", " ", "#"}], "+", "phase"}], "]"}], "&"}]}], ",", RowBox[{"(*", " ", "else", " ", "*)"}], " ", RowBox[{"signal", "=", RowBox[{ RowBox[{"1", "/", RowBox[{"(", RowBox[{"1", "+", RowBox[{"25", " ", RowBox[{"#", "^", "2"}]}]}], ")"}]}], "&"}]}]}], " ", "]"}], ";", " ", RowBox[{"Which", "[", RowBox[{ RowBox[{"Not", "@", RowBox[{"TrueQ", "[", RowBox[{ RowBox[{"4", "<", "n"}], "&&", RowBox[{"IntegerQ", "@", "n"}]}], "]"}]}], ",", " ", RowBox[{"Framed", "@", RowBox[{"Pane", "[", RowBox[{ "\"\\"", ",", RowBox[{"{", RowBox[{"450", ",", "230"}], "}"}]}], "]"}]}], ",", " ", " ", RowBox[{"Not", "@", RowBox[{"TrueQ", "[", RowBox[{"Positive", "[", "freq", "]"}], "]"}]}], ",", " ", RowBox[{"Pane", "[", RowBox[{ "\"\\"", ",", RowBox[{"{", RowBox[{"450", ",", "230"}], "}"}]}], "]"}], ",", " ", " ", RowBox[{"Not", "@", RowBox[{"TrueQ", "[", RowBox[{"phase", "\[Element]", "Reals"}], "]"}]}], ",", " ", RowBox[{"Pane", "[", RowBox[{ "\"\\"", ",", RowBox[{"{", RowBox[{"450", ",", "230"}], "}"}]}], "]"}], ",", " ", " ", "True", ",", " ", RowBox[{ RowBox[{"samples", "=", RowBox[{"Array", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"#", ",", RowBox[{"signal", "@", "#"}]}], "}"}], "&"}], ",", "n", ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}]}], "]"}]}], ";", " ", RowBox[{ RowBox[{"poly", "[", "t_", "]"}], "=", RowBox[{"InterpolatingPolynomial", "[", RowBox[{"samples", ",", "t"}], "]"}]}], ";", " ", RowBox[{"splineInterpolation", "=", RowBox[{"Interpolation", "[", RowBox[{"samples", ",", RowBox[{"InterpolationOrder", "->", "3"}], ",", RowBox[{"Method", "->", "\"\\""}]}], "]"}]}], ";", " ", RowBox[{"Column", "[", RowBox[{ RowBox[{"{", " ", RowBox[{ RowBox[{"Row", "@", RowBox[{"{", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"signal", "@", "t"}], ",", RowBox[{"poly", "@", "t"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", RowBox[{"-", "1.2"}], ",", "1.2"}], "}"}], ",", RowBox[{"PlotStyle", "->", RowBox[{"{", RowBox[{ InterpretationBox[ ButtonBox[ TooltipBox[ RowBox[{ GraphicsBox[{ {GrayLevel[0], RectangleBox[{0, 0}]}, {GrayLevel[0], RectangleBox[{1, -1}]}, {RGBColor[0.368417, 0.506779, 0.709798], RectangleBox[{0, -1}, {2, 1}]}}, AspectRatio->1, Frame->True, FrameStyle->RGBColor[ 0.24561133333333335`, 0.3378526666666667, 0.4731986666666667], FrameTicks->None, ImageSize-> Dynamic[{ Automatic, 1.35 (CurrentValue["FontCapHeight"]/ AbsoluteCurrentValue[Magnification])}], PlotRangePadding->None], ""}], "RGBColor[0.368417, 0.506779, 0.709798]"], Appearance->None, BaseStyle->{}, BaselinePosition->Baseline, ButtonFunction:> With[{Typeset`box$ = EvaluationBox[]}, If[ Not[ AbsoluteCurrentValue["Deployed"]], SelectionMove[Typeset`box$, All, Expression]; FrontEnd`Private`$ColorSelectorInitialAlpha = 1; FrontEnd`Private`$ColorSelectorInitialColor = RGBColor[0.368417, 0.506779, 0.709798]; FrontEnd`Private`$ColorSelectorUseMakeBoxes = True; MathLink`CallFrontEnd[ FrontEnd`AttachCell[Typeset`box$, FrontEndResource["RGBColorValueSelector"], { 0, {Left, Bottom}}, {Left, Top}, "ClosingActions" -> { "SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]], DefaultBaseStyle->{}, Evaluator->Automatic, Method->"Preemptive"], RGBColor[0.368417, 0.506779, 0.709798], Editable->False, Selectable->False], ",", InterpretationBox[ ButtonBox[ TooltipBox[ RowBox[{ GraphicsBox[{ {GrayLevel[0], RectangleBox[{0, 0}]}, {GrayLevel[0], RectangleBox[{1, -1}]}, {RGBColor[0.880722, 0.611041, 0.142051], RectangleBox[{0, -1}, {2, 1}]}}, AspectRatio->1, Frame->True, FrameStyle->RGBColor[ 0.587148, 0.40736066666666665`, 0.09470066666666668], FrameTicks->None, ImageSize-> Dynamic[{ Automatic, 1.35 (CurrentValue["FontCapHeight"]/ AbsoluteCurrentValue[Magnification])}], PlotRangePadding->None], ""}], "RGBColor[0.880722, 0.611041, 0.142051]"], Appearance->None, BaseStyle->{}, BaselinePosition->Baseline, ButtonFunction:> With[{Typeset`box$ = EvaluationBox[]}, If[ Not[ AbsoluteCurrentValue["Deployed"]], SelectionMove[Typeset`box$, All, Expression]; FrontEnd`Private`$ColorSelectorInitialAlpha = 1; FrontEnd`Private`$ColorSelectorInitialColor = RGBColor[0.880722, 0.611041, 0.142051]; FrontEnd`Private`$ColorSelectorUseMakeBoxes = True; MathLink`CallFrontEnd[ FrontEnd`AttachCell[Typeset`box$, FrontEndResource["RGBColorValueSelector"], { 0, {Left, Bottom}}, {Left, Top}, "ClosingActions" -> { "SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]], DefaultBaseStyle->{}, Evaluator->Automatic, Method->"Preemptive"], RGBColor[0.880722, 0.611041, 0.142051], Editable->False, Selectable->False]}], "}"}]}], ",", RowBox[{ "PlotLabel", "->", "\"\\""}], ",", RowBox[{"ImageSize", "->", RowBox[{"1.25", RowBox[{"{", RowBox[{"302", ",", "103"}], "}"}]}]}], ",", RowBox[{"AspectRatio", "->", "0.2784"}], ",", RowBox[{"Epilog", "->", RowBox[{"{", RowBox[{ RowBox[{"AbsolutePointSize", "@", "4"}], ",", RowBox[{"Point", "@", "samples"}]}], "}"}]}], ",", RowBox[{"AxesLabel", "->", RowBox[{"{", RowBox[{ RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\<\>\""}], "}"}]}]}], "]"}], ",", " ", RowBox[{"Column", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"LineLegend", "[", RowBox[{ RowBox[{"{", RowBox[{ InterpretationBox[ ButtonBox[ TooltipBox[ RowBox[{ GraphicsBox[{ {GrayLevel[0], RectangleBox[{0, 0}]}, {GrayLevel[0], RectangleBox[{1, -1}]}, {RGBColor[0.368417, 0.506779, 0.709798], RectangleBox[{0, -1}, {2, 1}]}}, AspectRatio->1, Frame->True, FrameStyle->RGBColor[ 0.24561133333333335`, 0.3378526666666667, 0.4731986666666667], FrameTicks->None, ImageSize->Dynamic[{ Automatic, 1.35 (CurrentValue["FontCapHeight"]/ AbsoluteCurrentValue[Magnification])}], PlotRangePadding->None], ""}], "RGBColor[0.368417, 0.506779, 0.709798]"], Appearance->None, BaseStyle->{}, BaselinePosition->Baseline, ButtonFunction:> With[{Typeset`box$ = EvaluationBox[]}, If[ Not[ AbsoluteCurrentValue["Deployed"]], SelectionMove[Typeset`box$, All, Expression]; FrontEnd`Private`$ColorSelectorInitialAlpha = 1; FrontEnd`Private`$ColorSelectorInitialColor = RGBColor[0.368417, 0.506779, 0.709798]; FrontEnd`Private`$ColorSelectorUseMakeBoxes = True; MathLink`CallFrontEnd[ FrontEnd`AttachCell[Typeset`box$, FrontEndResource["RGBColorValueSelector"], { 0, {Left, Bottom}}, {Left, Top}, "ClosingActions" -> { "SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]], DefaultBaseStyle->{}, Evaluator->Automatic, Method->"Preemptive"], RGBColor[0.368417, 0.506779, 0.709798], Editable->False, Selectable->False], ",", InterpretationBox[ ButtonBox[ TooltipBox[ RowBox[{ GraphicsBox[{ {GrayLevel[0], RectangleBox[{0, 0}]}, {GrayLevel[0], RectangleBox[{1, -1}]}, {RGBColor[0.880722, 0.611041, 0.142051], RectangleBox[{0, -1}, {2, 1}]}}, AspectRatio->1, Frame->True, FrameStyle->RGBColor[ 0.587148, 0.40736066666666665`, 0.09470066666666668], FrameTicks->None, ImageSize->Dynamic[{ Automatic, 1.35 (CurrentValue["FontCapHeight"]/ AbsoluteCurrentValue[Magnification])}], PlotRangePadding->None], ""}], "RGBColor[0.880722, 0.611041, 0.142051]"], Appearance->None, BaseStyle->{}, BaselinePosition->Baseline, ButtonFunction:> With[{Typeset`box$ = EvaluationBox[]}, If[ Not[ AbsoluteCurrentValue["Deployed"]], SelectionMove[Typeset`box$, All, Expression]; FrontEnd`Private`$ColorSelectorInitialAlpha = 1; FrontEnd`Private`$ColorSelectorInitialColor = RGBColor[0.880722, 0.611041, 0.142051]; FrontEnd`Private`$ColorSelectorUseMakeBoxes = True; MathLink`CallFrontEnd[ FrontEnd`AttachCell[Typeset`box$, FrontEndResource["RGBColorValueSelector"], { 0, {Left, Bottom}}, {Left, Top}, "ClosingActions" -> { "SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]], DefaultBaseStyle->{}, Evaluator->Automatic, Method->"Preemptive"], RGBColor[0.880722, 0.611041, 0.142051], Editable->False, Selectable->False]}], "}"}], ",", RowBox[{"{", " ", RowBox[{ RowBox[{"Pane", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"TrueQ", "[", RowBox[{ RowBox[{"signal", "[", "t", "]"}], "==", RowBox[{"Cos", "[", RowBox[{ RowBox[{"freq", " ", "\[Pi]", " ", "t"}], "+", "phase"}], "]"}]}], "]"}], ",", " ", RowBox[{"Which", "[", " ", RowBox[{ RowBox[{ RowBox[{"phase", "==", "0"}], "&&", RowBox[{"freq", "==", "1"}]}], ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\< )\>\""}], "}"}]}], ",", " ", " ", RowBox[{"phase", "==", "0"}], ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{ "\"\\"", ",", "freq", ",", "\"\< \[Pi] \>\"", ",", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\< )\>\""}], "}"}]}], ",", " ", " ", RowBox[{ RowBox[{"freq", "==", "1"}], "&&", RowBox[{"Positive", "@", "phase"}]}], ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\< + \>\"", ",", "phase", ",", "\"\<)\>\""}], "}"}]}], ",", " ", " ", RowBox[{"freq", "==", "1"}], ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\< - \>\"", ",", RowBox[{"-", "phase"}], ",", "\"\<)\>\""}], "}"}]}], ",", " ", " ", RowBox[{"Positive", "@", "phase"}], ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{ "\"\\"", ",", "freq", ",", "\"\< \[Pi] \>\"", ",", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\< + \>\"", ",", "phase", ",", "\"\<)\>\""}], "}"}]}], ",", " ", " ", "True", ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{ "\"\\"", ",", "freq", ",", "\"\< \[Pi] \>\"", ",", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\< - \>\"", ",", RowBox[{"-", "phase"}], ",", "\"\<)\>\""}], "}"}]}]}], " ", "]"}], ",", " ", RowBox[{"(*", " ", "else", " ", "*)"}], " ", RowBox[{"signal", "@", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}]}]}], " ", "]"}], ",", "109"}], "]"}], ",", "\"\\""}], "}"}], ",", RowBox[{"LabelStyle", "->", RowBox[{"{", RowBox[{"FontSize", "->", "10"}], "}"}]}]}], "]"}], ",", " ", RowBox[{"Row", "@", RowBox[{"{", RowBox[{ RowBox[{"Spacer", "@", "7"}], ",", RowBox[{"PointLegend", "[", RowBox[{ RowBox[{"{", "Black", "}"}], ",", RowBox[{ "{", "\"\\"", "}"}], ",", RowBox[{"LabelStyle", "->", RowBox[{"{", RowBox[{"FontSize", "->", "10"}], "}"}]}]}], "]"}]}], "}"}]}]}], "}"}], ",", RowBox[{"Spacings", "->", "0"}]}], "]"}]}], "}"}]}], ",", " ", " ", RowBox[{"LogPlot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Abs", "[", RowBox[{ RowBox[{"signal", "[", "t", "]"}], "-", RowBox[{"splineInterpolation", "[", "t", "]"}]}], "]"}], ",", RowBox[{"Abs", "[", RowBox[{ RowBox[{"signal", "[", "t", "]"}], "-", RowBox[{"poly", "[", "t", "]"}]}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", RowBox[{"-", "1.2"}], ",", "1.2"}], "}"}], ",", RowBox[{"ImageSize", "->", RowBox[{"1.25", RowBox[{"{", RowBox[{"302", ",", "103"}], "}"}]}]}], ",", " ", RowBox[{"AspectRatio", "->", "0.2784"}], ",", RowBox[{ "PlotLabel", "->", "\"\\""}], ",", RowBox[{"AxesLabel", "->", RowBox[{"{", RowBox[{ RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Italic"}], "]"}], ",", "\"\<\>\""}], "}"}]}], ",", RowBox[{"PlotStyle", "->", RowBox[{"{", RowBox[{ InterpretationBox[ ButtonBox[ TooltipBox[ RowBox[{ GraphicsBox[{ {GrayLevel[0], RectangleBox[{0, 0}]}, {GrayLevel[0], RectangleBox[{1, -1}]}, {RGBColor[1, 0.152, 0], RectangleBox[{0, -1}, {2, 1}]}}, AspectRatio->1, Frame->True, FrameStyle->RGBColor[ 0.6666666666666666, 0.10133333333333333`, 0.], FrameTicks->None, ImageSize-> Dynamic[{ Automatic, 1.35 (CurrentValue["FontCapHeight"]/ AbsoluteCurrentValue[Magnification])}], PlotRangePadding->None], ""}], "RGBColor[1, 0.152, 0]"], Appearance->None, BaseStyle->{}, BaselinePosition->Baseline, ButtonFunction:> With[{Typeset`box$ = EvaluationBox[]}, If[ Not[ AbsoluteCurrentValue["Deployed"]], SelectionMove[Typeset`box$, All, Expression]; FrontEnd`Private`$ColorSelectorInitialAlpha = 1; FrontEnd`Private`$ColorSelectorInitialColor = RGBColor[1, 0.152, 0]; FrontEnd`Private`$ColorSelectorUseMakeBoxes = True; MathLink`CallFrontEnd[ FrontEnd`AttachCell[Typeset`box$, FrontEndResource["RGBColorValueSelector"], { 0, {Left, Bottom}}, {Left, Top}, "ClosingActions" -> { "SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]], DefaultBaseStyle->{}, Evaluator->Automatic, Method->"Preemptive"], RGBColor[1, 0.152, 0], Editable->False, Selectable->False], ",", InterpretationBox[ ButtonBox[ TooltipBox[ RowBox[{ GraphicsBox[{ {GrayLevel[0], RectangleBox[{0, 0}]}, {GrayLevel[0], RectangleBox[{1, -1}]}, {RGBColor[0.880722, 0.611041, 0.142051], RectangleBox[{0, -1}, {2, 1}]}}, AspectRatio->1, Frame->True, FrameStyle->RGBColor[ 0.587148, 0.40736066666666665`, 0.09470066666666668], FrameTicks->None, ImageSize-> Dynamic[{ Automatic, 1.35 (CurrentValue["FontCapHeight"]/ AbsoluteCurrentValue[Magnification])}], PlotRangePadding->None], ""}], "RGBColor[0.880722, 0.611041, 0.142051]"], Appearance->None, BaseStyle->{}, BaselinePosition->Baseline, ButtonFunction:> With[{Typeset`box$ = EvaluationBox[]}, If[ Not[ AbsoluteCurrentValue["Deployed"]], SelectionMove[Typeset`box$, All, Expression]; FrontEnd`Private`$ColorSelectorInitialAlpha = 1; FrontEnd`Private`$ColorSelectorInitialColor = RGBColor[0.880722, 0.611041, 0.142051]; FrontEnd`Private`$ColorSelectorUseMakeBoxes = True; MathLink`CallFrontEnd[ FrontEnd`AttachCell[Typeset`box$, FrontEndResource["RGBColorValueSelector"], { 0, {Left, Bottom}}, {Left, Top}, "ClosingActions" -> { "SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]], DefaultBaseStyle->{}, Evaluator->Automatic, Method->"Preemptive"], RGBColor[0.880722, 0.611041, 0.142051], Editable->False, Selectable->False]}], "}"}]}], ",", " ", RowBox[{"PlotLegends", "->", RowBox[{"LineLegend", "[", RowBox[{ RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\""}], "}"}], ",", RowBox[{"LabelStyle", "->", RowBox[{"{", "10", "}"}]}]}], "]"}]}]}], "]"}]}], " ", " ", "}"}], ",", RowBox[{"Spacings", "->", "2"}], ",", RowBox[{"Dividers", "->", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{"2", "->", "Black"}], "}"}]}], "}"}]}]}], "]"}]}]}], " ", "]"}]}]}], "]"}], ",", " ", RowBox[{"Column", "[", RowBox[{ RowBox[{"{", " ", RowBox[{ RowBox[{"Control", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "example", ",", "\"\\"", ",", "\"\<\>\""}], "}"}], ",", " ", RowBox[{"{", RowBox[{ "\"\\ \"", ",", "\"\\""}], "}"}], ",", RowBox[{"ControlType", "->", "PopupMenu"}]}], "}"}], "]"}], ",", " ", "\"\<\>\"", ",", " ", RowBox[{"Control", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"n", ",", "7", ",", "\"\\""}], "}"}], ",", "5", ",", "15", ",", "1", ",", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], "]"}], ",", " ", RowBox[{"Control", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "freq", ",", "1", ",", "\"\\""}], "}"}], ",", "0.5", ",", "1.5", ",", "0.001", ",", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], "]"}], ",", " ", RowBox[{"Control", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"phase", ",", "0", ",", "\"\\""}], "}"}], ",", RowBox[{"-", "3.141"}], ",", "3.141", ",", "0.001", ",", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"Spacings", "->", "0"}]}], "]"}], ",", " ", RowBox[{"TrackedSymbols", "->", RowBox[{"{", RowBox[{"example", ",", "n", ",", "freq", ",", "phase"}], "}"}]}]}], "]"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.700500037020497*^9, 3.700902058784717*^9, {3.7009021340652447`*^9, 3.7009021755063877`*^9}, 3.76074227938409*^9}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`example$$ = "examples when an interpolating polynomial does well", \ $CellContext`freq$$ = 1, $CellContext`n$$ = 7, $CellContext`phase$$ = 0, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`example$$], "examples when an interpolating polynomial does well", ""}, { "examples when an interpolating polynomial does well", "examples when an interpolating polynomial does poorly"}}, {{ Hold[$CellContext`n$$], 7, "number of samples"}, 5, 15, 1}, {{ Hold[$CellContext`freq$$], 1, "signal frequency Hz"}, 0.5, 1.5, 0.001}, {{ Hold[$CellContext`phase$$], 0, "signal phase"}, -3.141, 3.141, 0.001}, { Hold[ Column[{ Manipulate`Place[1], "", Manipulate`Place[2], Manipulate`Place[3], Manipulate`Place[4]}, Spacings -> 0]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 526., {138.3544921875, 143.6455078125}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`example$62662$$ = False, $CellContext`n$62663$$ = 0, $CellContext`freq$62664$$ = 0, $CellContext`phase$62665$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 2, StandardForm, "Variables" :> {$CellContext`example$$ = "examples when an interpolating polynomial does well", \ $CellContext`freq$$ = 1, $CellContext`n$$ = 7, $CellContext`phase$$ = 0}, "ControllerVariables" :> { Hold[$CellContext`example$$, $CellContext`example$62662$$, False], Hold[$CellContext`n$$, $CellContext`n$62663$$, 0], Hold[$CellContext`freq$$, $CellContext`freq$62664$$, 0], Hold[$CellContext`phase$$, $CellContext`phase$62665$$, 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`samples$, $CellContext`signal$, \ $CellContext`splineInterpolation$, $CellContext`poly$}, If[$CellContext`example$$ === "examples when an interpolating polynomial does well", \ $CellContext`signal$ = Cos[($CellContext`freq$$ Pi) # + $CellContext`phase$$]& , $CellContext`signal$ = 1/(1 + 25 #^2)& ]; Which[ Not[ TrueQ[ And[4 < $CellContext`n$$, IntegerQ[$CellContext`n$$]]]], Framed[ Pane[ "The number of samples must be an integer\ngreater than \ 4.", {450, 230}]], Not[ TrueQ[ Positive[$CellContext`freq$$]]], Pane["The signal frequency must be positive.", {450, 230}], Not[ TrueQ[ Element[$CellContext`phase$$, Reals]]], Pane["The signal phase must be a real number.", {450, 230}], True, $CellContext`samples$ = Array[{#, $CellContext`signal$[#]}& , $CellContext`n$$, {-1, 1}]; $CellContext`poly$[ Pattern[$CellContext`t$, Blank[]]] = InterpolatingPolynomial[$CellContext`samples$, \ $CellContext`t$]; $CellContext`splineInterpolation$ = Interpolation[$CellContext`samples$, InterpolationOrder -> 3, Method -> "Spline"]; Column[{ Row[{ Plot[{ $CellContext`signal$[$CellContext`t], $CellContext`poly$[$CellContext`t]}, \ {$CellContext`t, -1.2, 1.2}, PlotStyle -> { RGBColor[0.368417, 0.506779, 0.709798], RGBColor[0.880722, 0.611041, 0.142051]}, PlotLabel -> "signal and interpolation between samples", ImageSize -> 1.25 {302, 103}, AspectRatio -> 0.2784, Epilog -> { AbsolutePointSize[4], Point[$CellContext`samples$]}, AxesLabel -> { Style["t", Italic], ""}], Column[{ LineLegend[{ RGBColor[0.368417, 0.506779, 0.709798], RGBColor[0.880722, 0.611041, 0.142051]}, { Pane[ If[ TrueQ[$CellContext`signal$[$CellContext`t] == Cos[($CellContext`freq$$ Pi) $CellContext`t + $CellContext`phase$$]], Which[ And[$CellContext`phase$$ == 0, $CellContext`freq$$ == 1], Row[{"cos(\[Pi] ", Style["t", Italic], " )"}], $CellContext`phase$$ == 0, Row[{"cos( ", $CellContext`freq$$, " \[Pi] ", Style["t", Italic], " )"}], And[$CellContext`freq$$ == 1, Positive[$CellContext`phase$$]], Row[{"cos( \[Pi] ", Style["t", Italic], " + ", $CellContext`phase$$, ")"}], $CellContext`freq$$ == 1, Row[{"cos( \[Pi] ", Style["t", Italic], " - ", -$CellContext`phase$$, ")"}], Positive[$CellContext`phase$$], Row[{"cos(", $CellContext`freq$$, " \[Pi] ", Style["t", Italic], " + ", $CellContext`phase$$, ")"}], True, Row[{"cos(", $CellContext`freq$$, " \[Pi] ", Style["t", Italic], " - ", -$CellContext`phase$$, ")"}]], $CellContext`signal$[ Style["t", Italic]]], 109], "interpolating polynomial"}, LabelStyle -> {FontSize -> 10}], Row[{ Spacer[7], PointLegend[{Black}, {"interpolating points"}, LabelStyle -> {FontSize -> 10}]}]}, Spacings -> 0]}], LogPlot[{ Abs[$CellContext`signal$[$CellContext`t] - \ $CellContext`splineInterpolation$[$CellContext`t]], Abs[$CellContext`signal$[$CellContext`t] - \ $CellContext`poly$[$CellContext`t]]}, {$CellContext`t, -1.2, 1.2}, ImageSize -> 1.25 {302, 103}, AspectRatio -> 0.2784, PlotLabel -> "magnitude of interpolating error", AxesLabel -> { Style["t", Italic], ""}, PlotStyle -> { RGBColor[1, 0.152, 0], RGBColor[0.880722, 0.611041, 0.142051]}, PlotLegends -> LineLegend[{"cubic spline", "interpolating polynomial"}, LabelStyle -> {10}]]}, Spacings -> 2, Dividers -> {None, {2 -> Black}}]]], "Specifications" :> {{{$CellContext`example$$, "examples when an interpolating polynomial does well", ""}, {"examples when an interpolating polynomial does well", "examples when an interpolating polynomial does poorly"}, ControlType -> PopupMenu, ControlPlacement -> 1}, {{$CellContext`n$$, 7, "number of samples"}, 5, 15, 1, Appearance -> "Labeled", ControlPlacement -> 2}, {{$CellContext`freq$$, 1, "signal frequency Hz"}, 0.5, 1.5, 0.001, Appearance -> "Labeled", ControlPlacement -> 3}, {{$CellContext`phase$$, 0, "signal phase"}, -3.141, 3.141, 0.001, Appearance -> "Labeled", ControlPlacement -> 4}, Column[{ Manipulate`Place[1], "", Manipulate`Place[2], Manipulate`Place[3], Manipulate`Place[4]}, Spacings -> 0]}, "Options" :> { TrackedSymbols -> {$CellContext`example$$, $CellContext`n$$, \ $CellContext`freq$$, $CellContext`phase$$}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{571., {227., 233.}}, 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.700902020668906*^9, 3.70090206051289*^9, 3.7009021456163993`*^9, 3.7009021774195795`*^9, 3.7009022296648035`*^9, 3.700902658151908*^9, 3.7607422793846197`*^9}, CellID->9004402] }, {2}]]