Message Boards Message Boards


Normal and Series commands together

Posted 10 years ago
2 Replies
0 Total Likes
f[x_] = Exp[x];

p[n_, x_] := Normal[Series[f[t], {t, 0, n}]] /. t -> x
Animate[Plot[{p[n, x], f[x]}, {x, 0, 5},

  PlotRange -> {0, Exp[5]}], {n, 1, 10, 1}]

Why do I have to define p[n_,x_] as above using the intermediate variable t ? I have verified that it does not work if  I use f instead of t and  t->x.


POSTED BY: Ana Squadri
2 Replies
Posted 10 years ago
Thank you
POSTED BY: Ana Squadri
Hello Ana,
You don't need the intermediate value:
f[x_] := Exp[x] (*set delayed*)

p[n_, z_] := Normal[Series[f[z], {z, 0, n}]]

Animate[Plot[Evaluate[{p[n, x], f[x]}], {x, 0, 5},
  PlotRange -> {0, Exp[5]}], {n, 1, 10, 1}]
The important step above is the Evaluate in Plot.  If you look at the tutorials on Plotting, you will see some examples of how and why Evaluate is used.

The little box of code above in the reply is obtained by using the "red spikey" button.  This is the suggested method for posting code in the community.

I hope this helps
POSTED BY: W. Craig Carter
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract