If I plot a derivative it fails:
Plot[ D[x^2 + 1, x], {x, -6., 6.}]
General::ivar: -5.99975 is not a valid variable.
But if I simply put the derivative, 2x, in, the plot works:
Plot[2x,{x,-.6,.6}]
Most other standard functions don't do this. Why doesn't plotting a derivative work, and what is the "..valid variable" warning about?
f'[x]works whenD[f[x],x]does not. During the plotxis replaced directly by one of the values in the range specified. For example, starting atx=-5it will evaluateD[f[-5],-5]which is not valid as you can't take the derivative of a number. Howeverf'[-5]is fine whether you evaluate it your self orPlotevaluates it.f'[x]andD[f[x],x]have the same output but they are encoded differently. To see that you can use//HoldForm//FullFormon both. – userrandrand Oct 10 '22 at 01:17f'without choosing an argument and it will output the derivative as a function (you can try withf[x_]:=x^3). Hence basically,f'[4]is basically the same asg=f'; g[4]and there is no problem in plottingg[x]. – userrandrand Oct 10 '22 at 01:19