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

• To: mathgroup at smc.vnet.net
• Subject: [mg92441] Re: Plotting f = Function[x,expr] and f[x_] := expr
• From: Peter Breitfeld <phbrf at t-online.de>
• Date: Tue, 30 Sep 2008 21:53:33 -0400 (EDT)
• References: <gbt2oo\$lbo\$1@smc.vnet.net>

```E. Martin-Serrano schrieb:
> 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:
>
> ------------------------------------------------------
>
>
>
> This works as expected
>
>
>
> In:= Clear[f, x]
>
> f[x_] := -20 x^3 + 3 x^5
>
> f[x]
>
> f'[x]
>
> f''[x]
>
>
>
> In:= Plot[f[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Red]
>
> In:= Plot[f'[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Green]
>
> In:= Plot[f''[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Blue]
>
> In:= Plot[{f[x], f'[x], f''[x]}, {x, -2  Pi, 2  Pi},
>
>  PlotStyle -> {Red, Green, Blue},
>
>  PlotRange -> {{-6.28318, 6.27681}, {-14129, 14084}}]
>
>
>
> --------------------------------------------
>
>
>
> This do work too
>
>
>
> In:= 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:= Clear[f, x]
>
> f = Function[x, -20 x^3 + 3 x^5];
>
> f[x]
>
> f'[x]
>
> f''[x]
>
>
>
> In:= Plot[f[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Red]
>
> In:= Plot[f'[x], {x, -2  Pi, 2  Pi}, PlotStyle -> Green]
>
> In:= Plot[f''[x], {x, -2  Pi, 2  Pi},
>
>  PlotStyle ->  Blue] (* here seems to be the problem *)
>
> In:= Plot[{f[x], f'[x], f''[x]}, {x, -2  Pi, 2  Pi},
>
>  PlotStyle -> {Red, Green, Blue},
>
>  PlotRange -> {{-6.28318, 6.27681}, {-14129, 14084}}]
>
>
>
>
>
> I need the format : f = Function[x, -20 x^3 + 3 x^5]
>
>
>
> E. Martin-Serrano
>

I don't see a difference in any of your plots between f[x_]=... and
g=Function[x, ...]

Gruss Peter
--
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

```

• Prev by Date: RE: Plotting f = Function[x,expr] and f[x_] := expr
• Next by Date: Re: Plotting f = Function[x,expr] and f[x_] := expr
• Previous by thread: RE: Plotting f = Function[x,expr] and f[x_] := expr
• Next by thread: Re: Plotting f = Function[x,expr] and f[x_] := expr