1

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!

Michael E2
  • 235,386
  • 17
  • 334
  • 747
swandog
  • 13
  • 4
  • 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 01:14
  • Hmm... So do you think changing the variable for x in the function definitions would do the trick? – swandog Nov 26 '17 at 01:16

1 Answers1

2

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

Mathematica graphics

Michael E2
  • 235,386
  • 17
  • 334
  • 747