MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Why are the functions different?


On Mar 31, 2005, at 1:24 AM, Helge Stenstroem wrote:

> How are these two functions (f0 and f1) different? f0 can be plotted,
> but f1 cannot.
>
> f1[x_] := Normal[Series[Tanh[x], {x, 0, 5}]]
> f0[x_] := x - x^3/3 + (2*x^5)/15
>
> When evaluated like this:
>  f0[x]
>  f1[x]
> they look the same.
>
> The following gives error messages if f0 is replaced by f1.
>  Plot[{Tanh[z], f0[z]}, {z, -1, 1}]
>

Because x is evaluated before the Series and Normal in f1.  Redefine f1 
as

f1[y_] := Block[{x}, Normal[Series[Tanh[x], {x, 0, 5}]] /.{x->y}]

and it will work as you expect.

Regards,

Ssezi



  • Prev by Date: GraphPlot vs. SpringEmbedding
  • Next by Date: Re: Packages
  • Previous by thread: Re: GraphPlot vs. SpringEmbedding
  • Next by thread: Re: Why are the functions different?