# Plot Taylor expansion of polynomial

I have a polynomial:

f[x_] := x^3 + 2*x^2 + 4


and I create a function that implements the Taylor expansion:

ft[x_, x0, n] := Normal[Series[f[x], {x, x0, n}]]


If I implement the expansion, the output is as expected:

ft[x, 5, 2]


(179 + 95 (-5 + x) + 17 (-5 + x)^2)

If I then plot the output, it works as expected:

Plot[179 + 95 (-5 + x) + 17 (-5 + x)^2, {x, -10, 10}]


But if I do it in one step, I obtain an error:

Plot[{f[x], ft[x, 5, 2]}, {x, 0, 10}]


(General::stop: Further output of General::ivar will be suppressed during this calculation.)

• Why causes this error?
• How I can solve it keeping the one step approach? I know there are examples such as this one, but they use multiple steps.
• Search for “ivar Plot” on this site for answers. Here’s one such Q&A: mathematica.stackexchange.com/q/1301/4999. What happens is that your functions aren’t evaluated until after Plot gives x a numerical value. In effect it’s evaluating Series[f[0.], {0., 5, 2}] etc. Oct 9, 2022 at 22:01
• Hi, you can reduce your problem to "why is my plot not working" (removing the Taylor expansion back story). Although I knew the answer to the problem, I was curious how quickly one could find the answer here as it is one of the most popular issues. I typed "plot not working" in the search box and found a question entitled plot not working that should solve this problem. Learning to search for solutions here is a valuable skill to have that will allow you to get solutions to your problems a lot faster. Oct 9, 2022 at 22:25
• That said, I am actually curious as to why I actually do not get an error. Maybe something changed in the version that I have 13.1 Oct 9, 2022 at 22:26
• For more common issues one can encounter using Mathematica there is this question Oct 9, 2022 at 22:28

f[x_] := x^3 + 2*x^2 + 4

Plot[{f[x], Evaluate@ft[x, 5, 2]}, {x, 0, 10}]