I've tried to run the following code:
f[x_] := 2 ArcTan[x] + ArcSin[2 x/(1 + x^2)];
Plot[D[f[x], x], {x, -4, 4}]
Same with SetDelayed
:
df[x_] := D[f[x], x];
Plot[df[x], {x, -4, 4}]
It starts to complaining:
General::ivar: -3.99984 is not a valid variable. >>
General::ivar: -3.83657 is not a valid variable. >>
General::ivar: -3.67331 is not a valid variable. >>
General::stop: Further output of General::ivar will be suppressed during this calculation. >>
But this code works:
f[x_] := 2 ArcTan[x] + ArcSin[2 x/(1 + x^2)];
df = D[f[x], x];
Plot[df, {x, -4, 4}]
Did I miss something or this is an issue?
Plot[f'[x], {x, -4, 4}]
? $\endgroup$Plot
command is passing in values to the function it is to plot. In the case ofD[f[x],x]
it is asking to take the derivative with respect to a numerical value, whereasf'[x]
is asking for the derivative at a numerical value. Because the function isn't evaluated (unless you useEvaluate[]
) this difference is important. $\endgroup$