Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

3 Answers

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
add comment

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
add comment

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
add comment

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.