Group Abstract Group Abstract

Message Boards Message Boards

Plotting an f'(x)?

Posted 10 years ago

hi i dont understand why this works :

Plot[{Log[x], Evaluate[D[Log[x], x]]}, {x, -1, 10}]

while this does not work :

Plot[
 Table[
  Evaluate[D[Log[x], {x, i}]],
  {i, 5, 20}
  ],
 {x, -1, 10}
 ]

i must confess i dont really see clearly either why the Evaluate is necessary in the first instruction : i just see that it does not work without.

Other question : Why does this not give to f the value Log[x]+k

ClearAll[f]
D[f[x], {x, 20}] /. f[x_] -> Log[x] + k

Answer :f(20)[x]

POSTED BY: Adrien Guyader
2 Replies
Posted 10 years ago

Ok thanks Gianluca

so i put a Plot@Evaluate instead of a single Plot and it works

if i understand your explanation, the Evaluate must be at the level juste below the Plot

POSTED BY: Adrien Guyader

It is the order of evaluation. Without Evaluate, Plot[D[Log[x], x], {x, -1, 10}] is problematic because the values of x are inserted into the expression D[Log[x], x] before it is evaluated, yielding the meaningless D[Log[-1], -1].

In the example Plot[{Log[x], Evaluate[D[Log[x], x]]}, {x, -1, 10}] the Evaluate is detected by the Plot algorithm, although it is not at the top level.

I think that the problem with

Plot[Table[Evaluate[D[Log[x], {x, i}]], {i, 5, 20}], {x, -1, 10}]

is that the Evaluate is not detected by Plot before the problem can occur. Just move the Evaluate outside the table, and it will be detected:

Plot[Evaluate[Table[D[Log[x], {x, i}], {i, 5, 20}]], {x, -1, 10}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard