Try this
Using the following code below. Btw, there are better ways to make animated gif files from Manipulate, by saving into a table each frame, then export these frames one by one at the end. You can also have more control on time between frames. If you search this site, you will see examples.
It now also runs faster, since the functions are defined to take in numeric arguments. On my PC this finished in about 3 minutes.
I also added SetOptions[$FrontEnd,DynamicEvaluationTimeout->60]
just in case you need more than 6 seconds, but it probably not needed now. Also it is good to add TrackedSymbols :> {n}, SynchronousUpdating -> False, ContinuousAction -> False
so I added these also.
SetDirectory[NotebookDirectory[]]
SetOptions[$FrontEnd, DynamicEvaluationTimeout -> 60]
p[x_?NumericQ, n_?NumericQ] :=
Sum[f[Table[15*(k/n), {k, 0, n}][[i]]]*
Product[Piecewise[{{(x -
Table[15*(k/n), {k, 0, n}][[j]])/(Table[
15*(k/n), {k, 0, n}][[i]] -
Table[15*(k/n), {k, 0, n}][[j]]), Not[i == j]}, {1,
i == j}}], {j, 1, Length[Table[15*(k/n), {k, 0, n}]]}], {i, 1,
Length[Table[15*(k/n), {k, 0, n}]]}];
f[x_?NumericQ] := x*Sin[x^(15/10)];
Export["coolthing.gif", Manipulate[
Grid[{{Row["n=", n]},
{Plot[{f[x], p[x, n]}, {x, 0, 15}]}}
],
{n, 1, 20}, TrackedSymbols :> {n}, SynchronousUpdating -> False,
ContinuousAction -> False
],
"GIF"]
Update
Here is a version for $n=40$. It took 30 minutes on my PC and I had to increase SetOptions[$FrontEnd,DynamicEvaluationTimeout->200]
also
Export["coolthing.gif", Manipulate[
Grid[{{Row[{"n=", n}]},
{Plot[{f[x], p[x, n]}, {x, 0, 15}]}}
],
{n, 1, 40}, TrackedSymbols :> {n}, SynchronousUpdating -> False,
ContinuousAction -> False
],
"GIF"]
Update
per comments, made $n$ integer values and fixed the vertical scale to some values. OP can decide better what these should be.
Export["coolthing.gif",
Manipulate[
Grid[{{Row[{"n=", n}]},
{Plot[{f[x], p[x, n]},
{x, 0, 15}, PlotRange -> {Automatic, {-40, 40}}]}}
],
{{n, 1, "n"}, 1, 40, 1, Appearance -> "Labeled"},
TrackedSymbols :> {n},
SynchronousUpdating -> False,
ContinuousAction -> False
],
"GIF"]
f
, and the command that aborts. $\endgroup$