Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Anomaly? or at least a surprise.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90268] Re: Anomaly? or at least a surprise.
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 4 Jul 2008 03:56:17 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g4i942$3cr$1@smc.vnet.net>

Steve Gray wrote:

> Doing D[ArcTan[x], x] gives 1/(x^2+1) as expected.
> Doing Plot[D[ArcTan[x]],{x,-10,10},PlotRange->Full] with no variable
> to differentiate by gives a correct plot (!) This is surprising - Help

On my system, the above expression plots the graph of *ArcTan[x]* and 
not the graph of its first derivative.

     Plot[D[ArcTan[x]], {x, -10, 10}, PlotRange -> Full]

     Plot[ArcTan[x], {x, -10, 10}, PlotRange -> Full]

     %% === %

     True

     $Version

     "6.0 for Mac OS X x86 (64-bit) (February 7, 2008)"

Why is that? Because, although D[Arctan[x]] is meaningless, this does 
not bother Plot since Plot does not preprocess its arguments (thanks to 
the attributes HoldAll). So it evaluates ArcTan[some_value] that returns 
some_other_value, then it evaluates D[some_other_value], which does 
nothing. The end result is that one gets the graph of arctan(x) without 
fuss!.

You can see what is going on with the command Trace:

     Plot[D[ArcTan[x]], {x, -10, 10}, PlotRange -> Full] // Trace

{Plot[D[ArcTan[x]],{x,-10,10},PlotRange->Full],
{x=.,Null},{x=.,Null},{{x}=.,{x=.},{x=.,Null},{Null}},
{{{x,-9.99959142857143`},ArcTan[-9.99959142857143`],-1.4711236288784175`},
D[-1.4711236288784175`],-1.4711236288784175`},

[... rest of the output deleted ...]

> says nothing about leaving out the independent variable even when the
> function is of only one variable. Now, doing
> Plot[D[ArcTan[x], x], {x, -10, 10}, PlotRange -> Full]
> gives error messages such as 
> 
> General::ivar: -9.18326 is not a valid variable. >>
> General::ivar: -9.59143 is not a valid variable. >>, etc.
> 
> I thought that D[ArcTan[x], x] and 1/(x^2+1) should behave identically
> in the Plot statement.
> 
> Is this behavior something I should know? Thank you.

The following expressions both correctly plot the graph of d/dx arctan(x):

     Plot[Evaluate[D[ArcTan[x], x]], {x, -10, 10},
      PlotRange -> Full]

     Plot[ArcTan'[x], {x, -10, 10}, PlotRange -> Full]

     %% === %

     True

Regards,
-- Jean-Marc


  • Prev by Date: Re: Re: Re: Printing, WYSIWYG, and Window Magnification?
  • Next by Date: Re: Set::setps problems
  • Previous by thread: Re: Anomaly? or at least a surprise.
  • Next by thread: Set::setps problems