Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

  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.

share|improve this question

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}, 
   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}];

enter image description here

share|improve this answer

With a few bells and whistles:


  plts[a_, t_] =
     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

share|improve this answer

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.

 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}]

Manipulate output

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.