Message Boards Message Boards

0
|
2274 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Plot and Dt and General::ivar

Posted 9 years ago
Plot[Dt[Sin[x], x], {x, -5, 5}]

So this gets a General::ivar error, which confused me for a while, then I figured out why.

Plot applies a value to x before Dt is evaluated, which makes the second x a value, not a variable.

Any ideas on how to fix this?

Edit: Found a way:

Plot[Dt[Sin[#],#]&[x],{x,-5,5}]

Edit2: No I didn't

Edit3: Now I did

Plot[Dt[Sin[a], a] /. a -> x, {x, -5, 5}]
POSTED BY: Darwin Kim

The function designed for this precise task is Evaluate:

Plot[Evaluate[Dt[Sin[x], x]], {x, -5, 5}]

I would use D rather than Dt to compute derivatives:

Plot[Evaluate[D[Sin[x], x]], {x, -5, 5}]
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

Group Abstract Group Abstract