Re: Issuing Function Calls within a Plot command
- To: mathgroup at smc.vnet.net
- Subject: [mg111535] Re: Issuing Function Calls within a Plot command
- From: Themis Matsoukas <tmatsoukas at me.com>
- Date: Wed, 4 Aug 2010 05:51:08 -0400 (EDT)
The error messages give a hint of what is going on:
myFunction[x_] := x^2;
Plot[D[myFunction[x], x], {x, 0, 5}]
General::ivar: 0.00010214285714285715` is not a valid variable. >>
Plot works by evaluating myFunction at fixed x but then D[] fails b/c it expects x to be a variable, not a number. You will get the same error is you try to execute the following:
N[D[myFunction[x], x = 0.000102]]
You can avoid this conflict by using separate variables in D[] and in Plot[]:
myFunction[x_] := x^2;
Plot[D[myFunction[y], y] /. y -> x, {x, 0, 5}]
Themis