Re: Why are the functions different?
- To: mathgroup at smc.vnet.net
- Subject: [mg55636] Re: Why are the functions different?
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Fri, 1 Apr 2005 05:36:08 -0500 (EST)
- Organization: Uni Leipzig
- References: <d2g5mg$f2m$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, you mean f1[x_] = Normal[Series[Tanh[x], {x, 0, 5}]] f0[x_] := x - x^3/3 + (2*x^5)/15 because if you call f1 with a numeric argument,say x->1, you evaluate Normal[Series[Tanh[1],{1,0,5}] and this can not work. With you definition the Series[] function is executed in every call of f1[] and this waste computation time. Regards Jens "Helge Stenstroem" <helge.stenstrom.NOSPAM at NOSPAMericsson.com> schrieb im Newsbeitrag news:d2g5mg$f2m$1 at smc.vnet.net... > 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}] > > (Mathematica 4.1 on Windows 2000) > -- > Helge Stenström >