0

I'm trying to get Plot within my Manipulate to evaluate, but I keep getting error messages:

F[x_]:= Cos[x]

Manipulate[
    Plot[
        Sum[
            ( ( D[ F[x], {x, k} ] /. x -> (π/6) )/k! ) * (x - (π/6) )^k ,
            {k, 1, terms}
        ], 
        {x, -3 π, 3 π}
    ], 
    {terms, 1, 100, 1}
]

It's supposed to be a taylor series that I can manipulate. Help is appreciated!

Edit: I'm very new to Mathematica, so I would appreciate, if you explained everything in a very simplified manner!

gwr
  • 13,452
  • 2
  • 47
  • 78
Mmnoob
  • 3
  • 2
  • 1
    Try giving the variable with respect to which you're differentiating a different name than the plotting variable. E.g., Manipulate[ Plot[Sum[((D[F[xx], {xx, k}] /. xx -> (\[Pi]/6))/k!)*(x - (\[Pi]/6))^ k, {k, 1, terms}], {x, -3 \[Pi], 3 \[Pi]}], {terms, 1, 100, 1}] – jjc385 Apr 13 '17 at 03:25
  • Or, calculate the function before it is supplied to Plot, e.g. With[{fcn = Sum[((D[F[x], {x, k}] /. x -> (\[Pi]/6))/k!)*(x - (\[Pi]/6))^k, {k,1, terms}]}, Plot[fcn, {x, -3 \[Pi], 3 \[Pi]}] ]. – rcollyer Apr 13 '17 at 03:26
  • 1
  • You forgot the constant term. 2. Add Evaluate[]: Manipulate[Plot[Evaluate @ Sum[(* stuff *)], (* stuff *)], (* stuff *)]
  • – J. M.'s missing motivation Apr 13 '17 at 03:26
  • Possible duplicate: https://mathematica.stackexchange.com/questions/1301/generalivar-is-not-a-valid-variable-when-plotting-what-actually-causes-this – Michael E2 Apr 13 '17 at 15:28