Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92470] Re: Plotting f = Function[x,expr] and f[x_] := expr
  • From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
  • Date: Wed, 1 Oct 2008 18:30:09 -0400 (EDT)
  • References: <gbt2oo$lbo$1@smc.vnet.net> <48E23533.8070203@gmail.com>

On Wed, Oct 1, 2008 at 17:18, E. Martin-Serrano
<eMartinSerrano at telefonica.net> wrote:
> 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.
>

This seems to be some nasty scoping bug that's present in Mathematica
5.2 as well.

Consider the following inputs:

In[1]:=
Block[{x=1},
  With[{f=Function[x,x^3]},
    {f[x],f'[x],f''[x]}
    ]
  ]

Out[1]= {1,3,0}

In[2]:=
Block[{x=1},
  With[{f=Function[x,x^3]},
    {f[1],f'[1],f''[1]}
    ]
  ]

Out[2]= {1,3,0}

The output should be {1,3,6} in both cases, but in Mathematica 5.2 the
second derivative is wrong.  Changing x in Block to some other symbol
makes the problem go away.  I think that this bug has been already
mentioned on MathGroup, but I'm not completely sure ...

Anyway, the good news is that Mathematica 6.0.3 is free of this problem!


  • Prev by Date: Re: Font size in plot coordinates?
  • Next by Date: Re: mathematica newbie ?
  • Previous by thread: Re: Font size in plot coordinates?
  • Next by thread: RE: Plotting f = Function[x,expr] and f[x_] := expr