 
 
 
 
 
 
Re: Why are the functions different?
- To: mathgroup at smc.vnet.net
- Subject: [mg55663] Re: Why are the functions different?
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Fri, 1 Apr 2005 05:37:14 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 3/31/05 at 1:24 AM, helge.stenstrom.NOSPAM at NOSPAMericsson.com
(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}]
The problem is evaluation with a numeric argument. If you supply f1 with a numeric argument, Tanh evaluates to a number and the arguements to Series will not be valid.
This can be fixed by using Set instead of SetDelayed in the definition of f1, i.e.,
f1[x_] = Normal[Series[Tanh[x], {x, 0, 5}]]
With this definition, the rhs gets evaluated to x - x^3/3 +(2*x^5)/15 before any number is supplied to f1 and f1[x] will evaluate to a number when x is a number as Plot requires.
--
To reply via email subtract one hundred and four

