RE: Plotting f = Function[x,expr] and f[x_] := expr
- To: mathgroup at smc.vnet.net
 - Subject: [mg92434] RE: Plotting f = Function[x,expr] and f[x_] := expr
 - From: "E. Martin-Serrano" <eMartinSerrano at telefonica.net>
 - Date: Tue, 30 Sep 2008 21:52:11 -0400 (EDT)
 - References: <gbt2oo$lbo$1@smc.vnet.net> <48E22E69.7060700@gmail.com>
 
Hi,
This corresponds to the run in my version 6.0.1. Perhaps the source of the
problem is a bug in this version. This happens to occur with David Park's
Presentations package too. 
In[1]:= f[x_] := -20 x^3 + 3 x^5
In[2]:= g = Function[x, -20 x^3 + 3 x^5]
Out[2]= Function[x, -20 x^3 + 3 x^5]
In[3]:= Function[x, -20 x^3 + 3 x^5]
Out[3]= Function[x, -20 x^3 + 3 x^5]
In[4]:= Plot[g''[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue] === 
 Plot[f''[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue]
Out[4]= False
In[5]:= $Version
Out[5]= "6.0 for Microsoft Windows (32-bit) (June 19, 2007)"
-----Original Message-----
From: Jean-Marc Gulliet [mailto:jeanmarc.gulliet at gmail.com] 
Sent: martes, 30 de septiembre de 2008 14:49
To: E. Martin-Serrano; mathgroup at smc.vnet.net
Subject: [mg92434] Re: Plotting f = Function[x,expr] and f[x_] := expr
E. Martin-Serrano wrote:
> Hi,
> 
> Why this apparent estrange behavior while plotting  functions  under the
> formats f[x_] := -20 x^3 + 3 x^5 and f = Function[x, -20 x^3 + 3 x^5]?, 
> 
> In particular  the second derivative f ''[x]  for -20 x^3 + 3 x^5 fails to
> render the shame shape in following examples . Please, see below: 
FWIW, to me as well as for Mathematica 6.0.3 on 64-bit Intal Mac OS X 
10.5.5, the plots are identical in each case.
   In[123]:=
     Clear[f, x]
     f[x_] := -20 x^3 + 3 x^5
     pp1 = Plot[f[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Red]
     pp2 = Plot[f'[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Green]
     pp3 = Plot[f''[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue]
     pp4 = Plot[{f[x], f'[x], f''[x]}, {x, -2 Pi, 2 Pi},
       PlotStyle -> {Red, Green, Blue},
       PlotRange -> {{-6.28318, 6.27681}, {-14129, 14084}}]
     Clear[f, x]
     f = Function[x, -20 x^3 + 3 x^5];
     p1 = Plot[f[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Red]
     p2 = Plot[f'[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Green]
     p3 = Plot[f''[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue]
     p4 = Plot[{f[x], f'[x], f''[x]}, {x, -2 Pi, 2 Pi},
       PlotStyle -> {Red, Green, Blue},
       PlotRange -> {{-6.28318, 6.27681}, {-14129, 14084}}]
     p1 === pp1
     p2 === pp2
     p3 === pp3
     p4 === pp4
   Out[135]= True
   Out[136]= True
   Out[137]= True
   Out[138]= True
   In[139]:= $Version
   Out[139]= "6.0 for Mac OS X x86 (64-bit) (May 21, 2008)"
Regards,
-- Jean-Marc