I have a very strange problem I'm sure I haven't had before, but I'm new to Mathematica, so maybe I'm just tired and can't see the obvious.
The Problem is, that for some reason Plot[] won't work with D[f[x],x], although it accepts f'[x]:
f[x_] := x^2
Plot[f'[x], {x, 0, 1}]
Plot[D[f[x], x], {x, 0, 1}]
The first command plots just fine, the second one gives several error messages "General::ivar: 0.000020428571428571424` is not a valid variable." with different numbers.
But they should be the exact same expression? I checked with SameQ[]:
In:= f'[x] === D[f[x], x]
Out= True
And this works:
Plot[D[f[a], a] /. a -> x, {x, 0, 1}]
But I don't think that's how Mathematica is supposed to be used..
Can someone help?
(Also I'm not sure about the tags, this probably hasn't anything to do with plotting - feel free to change them!)
Plot[Evaluate@D[f[x], x], {x, 0, 1}]works. – bbgodfrey Apr 04 '17 at 01:28EvaluatekeepsD[f[x], x]from turning intoD[f[0], 0]. Even if that were not an issue,Evaluatewould reduce runtime. – bbgodfrey Apr 04 '17 at 01:38