0

I understand why you have to use Evaluate with D to make it work, but why then does the apostrophe form work for Derivate without Evaluate?

If I plot a derivative one way I get an error - and yes, I know I have to use Evaluate: Plot[D[Sin[x], x], {x, -6., 6.}] General::ivar: -5.99975 is not a valid variable.

But if I plot with an apostrophe it gives me the Cosine plot without Evaluate. Plot[Sin'[x], {x, -6., 6.}]

And I know Mathematica thinks they are identical since D[Sin[x], x] == Sin'[x] gives me True

Michael E2
  • 235,386
  • 17
  • 334
  • 747
cybervigilante
  • 599
  • 2
  • 7
  • 1
    Please read the comments you receive carefully: https://mathematica.stackexchange.com/questions/274501/why-doesnt-plotting-a-derivative-work#comment685322_274501 – xzczd Oct 16 '22 at 00:47
  • 1
    Note that results being identical does not mean that the codes are identical. (And as discussed in the linked Q&A in the first comment above, Plot evaluates the code first setting x to a numeric value and does not evaluate the results of D[Sin[x], x] and Sin'[x] you see when x is an undefined symbol.) – Michael E2 Oct 16 '22 at 01:09
  • 1
    To make it more obvious: try x = 1; D[Sin[x], x] == Sin'[x]. – xzczd Oct 16 '22 at 02:35

0 Answers0