如何输入函数以便正确绘制

How to input function so it can be graphed correctly

目前我正在尝试绘制 sin(x) 函数和一个名为 myPolys 的函数,它是 sin(x) 的泰勒多项式,因为它等于

myPolys = 
Table[Table[(-1)^((j - 1)/2) x^j/Factorial[j], {j, 1, h, 2}], {h, 1, 
      19, 2}];

如何使用 manipulate 绘制两个函数的图形,以便绘制 myPolys 的每个部分

到目前为止我的绘图代码:

Manipulate[Plot[{Sin[x], myPolys[[n]]}, {x, -10, 10}, 
PlotRange -> {-5, 5}], {n, 1, Length[myPolys], 1}];

目前对于 n 的每次迭代,myPolys 被绘制为单独的图形 x 然后 x & -(x^3)/3!然后是 x & -(x^3)/3! &x^5/5! (所有的图都是分开绘制的)

我想要实现的图表是,对于 n=1,应该绘制 sin(x),并且应该绘制来自 myPoly 的 x,对于 n=2,它会继续,并且绘制 x-(x^3/3 !)(而不是绘制,对于 n=2、x 和 -x^3/3!分别)等等,直到 n 达到 10。

我目前的图表:

我希望得到的图表:

myPolys = Table[Sum[(-1)^((j - 1)/2) x^j/Factorial[j],
    {j, 1, h, 2}], {h, 1, 19, 2}];

Manipulate[Plot[{Sin[x], Evaluate@Take[myPolys, n]},
  {x, -10, 10}, PlotRange -> {-5, 5}], {n, 1, Length[myPolys], 1}]

或者,更实用的风格。

Clear[myPolys]

myPolys[n_] := Table[Sum[(-1)^((j - 1)/2) x^j/Factorial[j],
   {j, 1, h, 2}], {h, 1, 2 n - 1, 2}]

Manipulate[Plot[{Sin[x], Evaluate@myPolys[n]},
  {x, -10, 10}, PlotRange -> {-5, 5}], {n, 1, 10, 1}]

并带有图例。

myLabels[n_] := Table[Sum[(-1)^((j - 1)/2) x^j/ToString[j] <> "!",
   {j, 1, h, 2}], {h, 1, 2 n - 1, 2}] 

Manipulate[Plot[{Sin[x], Evaluate@myPolys[n]},
  {x, -10, 10}, PlotRange -> {-5, 5},
  PlotLegends -> Placed[PointLegend[
     Rest@Array[ColorData[97], n + 1], HoldForm /@ myLabels[n],
     LegendMarkers -> {"\[Tilde]", 30}], Left]], {n, 1, 10, 1}]

我想你知道有内置的 Series 你可以使用..

Manipulate[m = n;
 Show[{
   Plot[Sin[x], {x, -10, 10}, PlotRange -> {-5, 5}, 
    PlotStyle -> {Thick, Red}],
   Plot[Evaluate[
     Accumulate[List @@ Normal@Series[Sin[x], {x, 0, m}]]], {x, -10, 10}]}],
    {{n, 3}, 3, 25, 2}]