Re: Anomaly? or at least a surprise.

*To*: mathgroup at smc.vnet.net*Subject*: [mg90284] Re: Anomaly? or at least a surprise.*From*: "David Park" <djmpark at comcast.net>*Date*: Fri, 4 Jul 2008 03:59:26 -0400 (EDT)*References*: <g4i942$3cr$1@smc.vnet.net>

First notice that D[ArcTan[x]] gives ArcTan[x] So Plot[D[ArcTan[x]], {x, -10, 10}, PlotRange -> Full] is just a plot of ArcTan[x], if that is what you wanted. You might as well just have used ArcTan[x]. But Plot[D[ArcTan[x], x], {x, -10, 10}, PlotRange -> Full] is evaluated by substituting numerical values of x into the plot expression. For example, when Mathematica is evaluating for x = .5, say, it tries to evaluate: D[ArcTan[.5], .5] which is nonsense because the second argument is not a symbolic variable and, even if it was, the first argument does not contain a symbolic variable but is evaluated to a number. But the plot statement will work if you Evaluate the plotting expression. Plot[D[ArcTan[x], x] // Evaluate, {x, -10, 10}, PlotRange -> Full] Which all leads to a useful, but certainly not ironclad, rule. Don't cram a lot of calculation into plotting expressions. Look at them first, outside the plotting statement, and make certain you know what they are. Then you might even define a function for them and put that into the plotting statement. f[x_] = D[ArcTan[x], x] Plot[f[x], {x, -10, 10}, PlotRange -> Full] Or, in this case, there is even a simpler solution: Plot[ArcTan'[x], {x, -10, 10}, PlotRange -> Full] -- David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ "Steve Gray" <stevebg at roadrunner.com> wrote in message news:g4i942$3cr$1 at smc.vnet.net... > 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 > 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. > > Steve Gray >