RE: Plotting f = Function[x,expr] and f[x_] := expr

• To: mathgroup at smc.vnet.net
• Subject: [mg92502] RE: Plotting f = Function[x,expr] and f[x_] := expr
• From: "E. Martin-Serrano" <eMartinSerrano at telefonica.net>
• Date: Wed, 1 Oct 2008 18:36:22 -0400 (EDT)
• References: <gbt2oo\$lbo\$1@smc.vnet.net> <48E23533.8070203@gmail.com> <C7BB2E5E5F5A47E69C5F3D0344C8A8D4@SkyLine> <f831b3d60809300741t55ccfcc9md956ab4928a69a98@mail.gmail.com>

```Szabolcs,

Umhhhh!

Plot[Evaluate[g''[x]], {x, -2Pi, 2Pi}] or Plot[g''[x], {x, -2Pi,
2Pi}, Evaluated -> True] do work!!! I am sending you a notebook in email
apart. It sounds frustrating to me, since I was playing around with Evaluate
trying to circumvent the problem until I decided posting.

Many thanks.

E. Martin-Serrano

-----Original Message-----
From: Szabolcs Horv=E1t [mailto:szhorvat at gmail.com]
Sent: martes, 30 de septiembre de 2008 15:42
To: E. Martin-Serrano
Cc: mathgroup at smc.vnet.net
Subject: [mg92502] Re: Plotting f = Function[x,expr] and f[x_] := expr

I cannot test this on 6.0.1, but here's a guess:

Try Plot[Evaluate[g''[x]], {x, -2Pi, 2Pi}] or Plot[g''[x], {x, -2Pi,
2Pi}, Evaluated -> True].  Do they produce the correct result?  The
Plot function of Mathematica 6 has the nasty habit of silently
ignoring errors.  I use On[General::plnr] in init.m, which partially
restores the behaviour of Mathematica <= 5.2.  While the Plot::plnr
message was annoying to many users, I wouldn't call it completely
useless ...

On Tue, Sep 30, 2008 at 16:32, E. Martin-Serrano
<eMartinSerrano at telefonica.net> wrote:
>
> Hi,
>
> Perhaps the problem is in version 6.0.1. The following is my result.
Anybody
> still in 6.0.1?
>
> 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
>
>
>
> -----Original Message-----
> From: Szabolcs Horv=E1t [mailto:szhorvat at gmail.com]
> Sent: martes, 30 de septiembre de 2008 15:18
> To: E. Martin-Serrano
> Subject: 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 same shape in following examples . Please, see below:
>>
>> ------------------------------------------------------
>>
>>
>>
>> This works as expected
>>
>>
>>
>> In[1]:= Clear[f, x]
>>
>> f[x_] := -20 x^3 + 3 x^5
>>
>> f[x]
>>
>> f'[x]
>>
>> f''[x]
>>
>>
>>
>> In[6]:= Plot[f[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Red]
>>
>> In[7]:= Plot[f'[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Green]
>>
>> In[8]:= Plot[f''[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Blue]
>>
>> In[9]:= Plot[{f[x], f'[x], f''[x]}, {x, -2  Pi, 2  Pi},
>>
>>  PlotStyle -> {Red, Green, Blue},
>>
>>  PlotRange -> {{-6.28318, 6.27681}, {-14129, 14084}}]
>>
>>
>>
>> --------------------------------------------
>>
>>
>>
>> This does work too
>>
>>
>>
>> In[10]:= Clear[f, x]
>>
>> f = Function[x, -20 x^3 + 3 x^5]
>>
>> f''[x]
>>
>> tp = Table[N@{x, %}, {x, -2 Pi, 2 Pi, .001}];
>>
>> llp = ListLinePlot[tp]
>>
>> fgif = FullGraphics[llp] // InputForm;
>>
>>
>>
>> --------------------------------------
>>
>>
>>
>> This does not (The second derivative is plotted pretty flat)
>>
>>
>>
>> In[16]:= Clear[f, x]
>>
>> f = Function[x, -20 x^3 + 3 x^5];
>>
>> f[x]
>>
>> f'[x]
>>
>> f''[x]
>>
>>
>>
>> In[21]:= Plot[f[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Red]
>>
>> In[22]:= Plot[f'[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Green]
>>
>> In[23]:= Plot[f''[x], {x, -2  Pi, 2  Pi},
>>
>>  PlotStyle ->  Blue] (* here seems to be the problem *)
>>
>> In[24]:= Plot[{f[x], f'[x], f''[x]}, {x, -2  Pi, 2  Pi},
>>
>>  PlotStyle -> {Red, Green, Blue},
>>
>>  PlotRange -> {{-6.28318, 6.27681}, {-14129, 14084}}]
>>
>
> The two commands produce the same plot with Mathematica 6.0.3:
>
> 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]:= Plot[g''[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue] ===
>  Plot[f''[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue]
>
> Out[3]= True
>
>

```

• Prev by Date: Re: fellow authors
• Next by Date: RE: Avoiding Null output marker from a function
• Previous by thread: Re: Plotting f = Function[x,expr] and f[x_] := expr
• Next by thread: Re: mathematica newbie ?