# Normal and Series commands together

Posted 10 years ago
4012 Views
|
2 Replies
|
0 Total Likes
|
 f[x_] = Exp[x];p[n_, x_] := Normal[Series[f[t], {t, 0, n}]] /. t -> xAnimate[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
2 Replies
Sort By:
Posted 10 years ago
 Thank you
Posted 10 years ago
 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