I've defined a mathematica function that makes a taylor series of a function.

s4a[n_] := Normal[Series[f4a[a], {a, 0, n}]]

But I cannot plot it

Plot[s4a[5], {a,-2,2}]
General::stop: Further output of General::ivar will be suppressed during this calculation.

I understand I have a problem like described here: General::ivar is not a valid variable when plotting - what actually causes this and how to avoid it?

But I cannot define

s4a[n_] = Normal[Series[f4a[a], {a, 0, n}]]
Series::serlim: Series order specification n is not a machine-sized integer.

So how do I define a function that makes a series of order $n$ and can be plotted?


I guess Plot[Evaluate[s4a[5]],{a,-2,2}] works though. Maybe this is the best solution

  • $\begingroup$ Does Plot[Evaluate[s4a[5]], {a, -2, 2}] give what you expect? $\endgroup$ – kglr Oct 14 '16 at 19:42
  • $\begingroup$ yes. thank you. i made an edit about that a few seconds before your comment. i guess that would be the simplest solution. what does it do though? "causes expr to be evaluated even if it appears as the argument of a function whose attributes specify that it should be held unevaluated." I thought the problem was that evaluation was occurring too early $\endgroup$ – bernie Oct 14 '16 at 19:43
  • $\begingroup$ Should probably be a duplicate of this: mathematica.stackexchange.com/q/48980/4999 $\endgroup$ – Michael E2 Aug 1 '19 at 11:51

This problem occurs because Plot assigns a numeric value to the variable a and then evaluates the expression s4a[5]. Because of the set delayed operator, the expression that is actually evaluated inside Plot is probably something like:

Normal[Series[f4a[-2], {-2, 0, n}]]

This obviously would return an error.

You can force Plot to evaluate its argument first by wrapping it in Evaluate or using the following option:

Plot[s4a[5], {a, -2, 2}, Evaluated -> True]
|improve this answer|||||
  • $\begingroup$ I see. Thank you. One counter intuitive thing is that the error message before further output of General::ivar will be suppressed is General::ivar: -1.99992 is not a valid variable. This made me thing that Plot was looking for a symbolic form. $\endgroup$ – bernie Oct 15 '16 at 15:49

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