Message Boards Message Boards

0
|
4317 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Normal and Series commands together

Posted 11 years ago
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}]
Dear:

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.

thanks,

Ana
POSTED BY: Ana Squadri
2 Replies
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
Posted 11 years ago
Thank you
POSTED BY: Ana Squadri
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract