Cell[CellGroupData[{Cell[BoxData[ RowBox[{ RowBox[{"tanCF", "[", RowBox[{"x_", ",", " ", "n_"}], "]"}], " ", ":=", RowBox[{"1", "/", RowBox[{"Fold", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"#2", "/", "x"}], "-", RowBox[{"1", "/", "#1"}]}], "&"}], ",", " ", RowBox[{"-", RowBox[{"(", RowBox[{ RowBox[{"2", "n"}], "+", "1"}], ")"}]}], ",", RowBox[{"Reverse", "[", RowBox[{"Table", "[", RowBox[{"k", ",", " ", RowBox[{"{", RowBox[{"k", ",", "1", ",", " ", RowBox[{"2", "n"}], ",", " ", "2"}], "}"}]}], "]"}], "]"}]}], "]"}]}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{{3.35254784056617*^9, 3.35254803798178*^9}, { 3.35254807081473*^9, 3.35254809413637*^9}, {3.35254812730402*^9, 3.35254815291111*^9}, 3.76073997611005*^9}, CellID->713737891], Cell[BoxData[ RowBox[{ RowBox[{"tanCFPlot", "[", "n_", "]"}], " ", ":=", " ", RowBox[{"Pane", "[", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"Pane", "[", RowBox[{ RowBox[{"Text", "[", RowBox[{ RowBox[{"HoldForm", "[", RowBox[{"Tan", "[", "x", "]"}], "]"}], "~~", RowBox[{"tanCF", "[", RowBox[{"x", ",", "n"}], "]"}]}], "]"}], ",", RowBox[{"ImageSize", "->", RowBox[{"{", RowBox[{"275", ",", "Automatic"}], "}"}]}]}], "]"}], ",", " ", RowBox[{"GraphicsGrid", "[", RowBox[{ RowBox[{"List", "/@", RowBox[{"{", " ", RowBox[{ RowBox[{"Show", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Tan", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"-", "20"}], ",", "20"}], "}"}], ",", RowBox[{"PlotRange", " ", "->", " ", RowBox[{"{", RowBox[{ RowBox[{"-", "10"}], ",", "10"}], "}"}]}], ",", RowBox[{ "PlotStyle", " ", "->", " ", " ", RowBox[{"Directive", "[", RowBox[{"Gray", ",", RowBox[{"Thickness", "[", "0.01", "]"}]}], "]"}]}], ",", RowBox[{"MaxRecursion", "->", RowBox[{"ControlActive", "[", RowBox[{"0", ",", "6"}], "]"}]}]}], "]"}], ",", " ", RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "@", RowBox[{"tanCF", "[", RowBox[{"x", ",", " ", "n"}], "]"}]}], ",", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"-", "25"}], ",", "25"}], "}"}], ",", RowBox[{"PlotRange", " ", "->", " ", RowBox[{"{", RowBox[{ RowBox[{"-", "10"}], ",", "10"}], "}"}]}], ",", RowBox[{"PlotStyle", " ", "->", " ", RowBox[{"{", RowBox[{"RGBColor", "[", RowBox[{"1", ",", ".2", ",", "0"}], "]"}], "}"}]}], ",", RowBox[{"MaxRecursion", "->", RowBox[{"ControlActive", "[", RowBox[{"0", ",", "6"}], "]"}]}]}], "]"}]}], "}"}], ",", " ", RowBox[{"Frame", "->", "True"}], ",", RowBox[{"Axes", "->", "False"}]}], "]"}], ",", " ", RowBox[{"Quiet", "[", RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"Log", "[", RowBox[{"10", ",", RowBox[{"Abs", "[", RowBox[{"1", "-", RowBox[{"Together", "[", RowBox[{ RowBox[{"tanCF", "[", RowBox[{"x", ",", " ", "n"}], "]"}], "/", RowBox[{"Tan", "[", "x", "]"}]}], "]"}]}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"-", "25"}], ",", "25"}], "}"}], ",", RowBox[{"PlotRange", " ", "->", " ", RowBox[{"{", RowBox[{ RowBox[{"-", "25"}], ",", "10"}], "}"}]}], ",", RowBox[{"PlotStyle", " ", "->", " ", RowBox[{"RGBColor", "[", RowBox[{".2", ",", ".6", ",", "1"}], "]"}]}], ",", " ", RowBox[{"WorkingPrecision", "->", RowBox[{"ControlActive", "[", RowBox[{"MachinePrecision", ",", "60"}], "]"}]}], ",", " ", RowBox[{"Frame", "->", "True"}], ",", RowBox[{"Axes", "->", "False"}], ",", " ", RowBox[{"PlotLabel", "->", RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{ "\"\\"", ",", "\"\\""}], "]"}]}]}], ",", RowBox[{"MaxRecursion", "->", RowBox[{"ControlActive", "[", RowBox[{"1", ",", "6"}], "]"}]}]}], "]"}], "]"}]}], "}"}]}], ",", RowBox[{"ImageSize", "->", "300"}]}], "]"}]}], "}"}], "}"}], ",", RowBox[{"Dividers", "->", RowBox[{"{", RowBox[{"Center", ",", "False"}], "}"}]}]}], "]"}], ",", RowBox[{"ImageSize", "->", "600"}]}], "]"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{{3.35254816220133*^9, 3.35254834222297*^9}, { 3.35254851716228*^9, 3.35254852804349*^9}, {3.3525488513543*^9, 3.35254892718273*^9}, {3.35254899499778*^9, 3.35254901531262*^9}, { 3.357227439875*^9, 3.35722744835938*^9}, {3.35722748307813*^9, 3.35722749028125*^9}, {3.358718215625*^9, 3.35871822579688*^9}, { 3.35871828792188*^9, 3.35871829814063*^9}, {3.35871834965625*^9, 3.35871834975*^9}, {3.36274398704692*^9, 3.36274403151197*^9}, { 3.3634291629914*^9, 3.36342916498924*^9}, {3.36499786847575*^9, 3.36499786928825*^9}, {3.36499793611638*^9, 3.36499794352263*^9}, { 3.3649981400695*^9, 3.36499819928825*^9}, {3.3649983299445*^9, 3.36499834553825*^9}, {3.36499837930388*^9, 3.36499839072575*^9}, { 3.36499846049138*^9, 3.36499848803825*^9}, {3.36499852064763*^9, 3.36499861735075*^9}, {3.36499865791325*^9, 3.36499866122575*^9}, { 3.36499874166325*^9, 3.36499874205388*^9}, {3.36499878391325*^9, 3.36499895197575*^9}, {3.36499899714763*^9, 3.36499900210075*^9}, { 3.36499906908513*^9, 3.36499908327263*^9}, {3.36499912349138*^9, 3.36499912411638*^9}, {3.36499915421013*^9, 3.36499918966325*^9}, { 3.364999247882*^9, 3.36499924822575*^9}, {3.364999356757*^9, 3.364999357132*^9}, {3.36499952485075*^9, 3.36499956899138*^9}, { 3.36611316561968*^9, 3.3661131658853*^9}, {3.36615466932813*^9, 3.3661547556875*^9}, {3.3703647521192646`*^9, 3.370364794868991*^9}, {3.3707816560533023`*^9, 3.370781753115181*^9}, {3.37078178614622*^9, 3.3707817907243156`*^9}, {3.3707818780987563`*^9, 3.370781890317428*^9}, {3.370781934895268*^9, 3.370781948988928*^9}, {3.370781991191783*^9, 3.3707819930667706`*^9}, {3.370782039597723*^9, 3.370782057519483*^9}, {3.377201568375*^9, 3.377201570375*^9}, 3.760739976110159*^9}, CellID->29779513], Cell[BoxData[ RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"TraditionalForm", "[", RowBox[{"tanCFPlot", "[", "n", "]"}], "]"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "n", ",", "3", ",", " ", "\"\\""}], "}"}], ",", "1", ",", " ", "10", ",", " ", "1"}], "}"}], ",", RowBox[{"SaveDefinitions", "->", "True"}]}], "]"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{{3.35332506645933*^9, 3.35332508439671*^9}, { 3.35472776245313*^9, 3.35472777182813*^9}, {3.35722742739063*^9, 3.3572274275*^9}, {3.35871851645313*^9, 3.3587185383125*^9}, { 3.370781633537822*^9, 3.370781633709696*^9}, {3.370782018644732*^9, 3.370782018910355*^9}, 3.3707820838943143`*^9, { 3.370782136925225*^9, 3.3707821370502243`*^9}, { 3.377201610640625*^9, 3.37720161096875*^9}, {3.381412843265625*^9, 3.38141284340625*^9}, 3.760739976103264*^9}, CellID->1496021318], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`n$$ = 3, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`n$$], 3, "continued fraction terms"}, 1, 10, 1}}, Typeset`size$$ = {600., {174.5, 179.5}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$30494$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`n$$ = 3}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$30494$$, 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" :> TraditionalForm[ $CellContext`tanCFPlot[$CellContext`n$$]], "Specifications" :> {{{$CellContext`n$$, 3, "continued fraction terms"}, 1, 10, 1}}, "Options" :> {}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{645., {220., 226.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`tanCFPlot[ Pattern[$CellContext`n, Blank[]]] := Pane[ Grid[{{ Pane[ Text[ TildeTilde[ HoldForm[ Tan[$CellContext`x]], $CellContext`tanCF[$CellContext`x, $CellContext`n]]], ImageSize -> {275, Automatic}], GraphicsGrid[ Map[List, { Show[{ Plot[ Tan[$CellContext`x], {$CellContext`x, -20, 20}, PlotRange -> {-10, 10}, PlotStyle -> Directive[Gray, Thickness[0.01]], MaxRecursion -> ControlActive[0, 6]], Plot[ Evaluate[ $CellContext`tanCF[$CellContext`x, \ $CellContext`n]], {$CellContext`x, -25, 25}, PlotRange -> {-10, 10}, PlotStyle -> { RGBColor[1, 0.2, 0]}, MaxRecursion -> ControlActive[0, 6]]}, Frame -> True, Axes -> False], Quiet[ Plot[ Evaluate[ Log[10, Abs[ 1 - Together[$CellContext`tanCF[$CellContext`x, \ $CellContext`n]/Tan[$CellContext`x]]]]], {$CellContext`x, -25, 25}, PlotRange -> {-25, 10}, PlotStyle -> RGBColor[0.2, 0.6, 1], WorkingPrecision -> ControlActive[MachinePrecision, 60], Frame -> True, Axes -> False, PlotLabel -> Text[ Style[ "base-10 logarithm of relative error", "Label"]], MaxRecursion -> ControlActive[1, 6]]]}], ImageSize -> 300]}}, Dividers -> {Center, False}], ImageSize -> 600], $CellContext`tanCF[ Pattern[$CellContext`x, Blank[]], Pattern[$CellContext`n, Blank[]]] := 1/Fold[#2/$CellContext`x - 1/#& , -(2 $CellContext`n + 1), Reverse[ Table[$CellContext`k, {$CellContext`k, 1, 2 $CellContext`n, 2}]]]}; Typeset`initDone$$ = True), SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{3.7607399761035233`*^9}, CellID->354560390] }, {4}]]