# Plotting a few Maclaurin Series in Mathematica

I would like to plot the Taylor polynomials for several functions. Specifically:

Exp[Sin[x]]
( x^2 + Exp[ x ] )^( -1 )


and

Exp[ -4 x^2 + 5 x]


I have their Taylor series as:

taylorFunction1[x_, n_] := Normal[Series[f1[x], { x, 0, n} ] ]
taylorFunction2[x_, n_] := Normal[Series[f2[x], {x,  0, n} ] ]
taylorFunction3[x_, n_] := Normal[Series[f3[x], {x,  0, n} ] ]


I would like to plot the functions of x and their Taylor series of degree n = 10 and compare each, specifically over the interval [-1/2, 1/2]. However, for some reason, whenever I use the "Plot[]" command, Mathematica just returns an empty graph. I come from a C programming background, but I am rather unfamiliar with Mathematica. Can anyone help me out and let me know what's going on?

Thanks!

• It's because (probably -- guessing without Plot code) in Plot, the symbol x is given a numeric value whereas Series would fail if x is not a symbol. – Michael E2 Nov 26 '17 at 1:14
• Hmm... So do you think changing the variable for x in the function definitions would do the trick? – Alexander Swanson Nov 26 '17 at 1:16

## 1 Answer

Here's one way:

Plot[
Evaluate@Normal@Series[{Exp[Sin[x]], (x^2 + Exp[x])^(-1), Exp[-4 x^2 + 5 x]}, {x, 0, 5}],
{x, -1/2, 1/2}] • Hey Michael, thanks for the response. I see... So is Mathematica actually evaluating the functions, and then plotting every value with x = [-1/2, 1/2]? – Alexander Swanson Nov 26 '17 at 1:20
• @AlexanderSwanson Yes, the trick is to evaluate Series before assigning values to x. – Michael E2 Nov 26 '17 at 1:24
• I see. I'm assuming Evaluate@... does that for us. Thanks a lot, Michael. – Alexander Swanson Nov 26 '17 at 1:29
• @AlexanderSwanson Right, Plot evaluates its argument in a non-standard way, which Evaluate overrides. – Michael E2 Nov 26 '17 at 1:44