# Dynamic plot with Evaluate on expression

I'm trying to make a make a plot of a table of expressions, which should be pre-evaluated (since they are infinite series with analytic sums). I'm able to make the plot normally with Evaluate @ Table:

Plot[Evaluate@Table[Sum[t^k/k! Exp[-t], {k, 0, Infinity, n}], {n, 1, 5}], {t, 0, 5}]


But when I surround it with a Manipulate it no longer works (there are errors that indicate Mathematica is evaluating the summation with a fixed value of t, which doesn't work at t = 0, k = 0).

Manipulate[
Plot[Evaluate @
Table[Sum[ ((a t)^k)/k! Exp[-a t], {k, 0, Infinity, n}], {n, 1, 5}], {t, 0, 5}],
{a, 0, 3}]


I know I can just evaluate the table and copy-paste, but I was hoping for a more elegant solution.

-

It can work with a=0 too, the problem is that a is applied before closed form of the sum is calculated. We can force this:

DynamicModule[{t, k, tab, a},
Column[{
Dynamic@Plot[tab[a, t], {t, 0, 5}, ImageSize -> 400],
Slider[Dynamic[a], {0, 11, 1}]
}],
Initialization :> {tab[a_, t_] = Table[Sum[((a t)^k)/k! Exp[-a t], {k, 0, Infinity, n}],
{n, 1, 5}];
}]


-

With a few bells and whistles:

Manipulate[
Module[{plts},

plts[a_, t_] =
Table[Tooltip[
Sum[((a t)^k)/k! Exp[-a t],{k, 0, Infinity, n}] // Simplify,
StringForm["n = ", n]], {n, 5}];

Plot[Evaluate[plts[a, t]], {t, 0, 5},PlotRange -> {0, 1}]],

{{a, 1.5}, 0, 3, 0.05, Appearance -> "Labeled"}]


Bob Hanlon

-

The problem is how to evaluate the sums without before a is set to 0. That can be done with With. If you put Dynamic around Plot, then only the Plot will be updated when the slider for a is moved.

Manipulate[
With[{plots = Table[Sum[((a0 t)^k)/k! Exp[-a0 t], {k, 0, Infinity, n}], {n, 1, 5}]},
Dynamic @ Plot[Evaluate[plots /. a0 -> a], {t, 0, 5}, PlotRange -> {0, 1}]],
{a, 0, 3}]


-