[Date Index]
[Thread Index]
[Author Index]
Re: Plot derivative
*To*: mathgroup at smc.vnet.net
*Subject*: [mg64951] Re: Plot derivative
*From*: "Steven M. Christensen" <steve at smc.vnet.net>
*Date*: Wed, 8 Mar 2006 01:01:01 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
There were a great many duplicate answers to this question. I
have combined them all in this post.
Moderator
>From: Marco Gabiccini <m.gabiccini at ing.unipi.it>
To: mathgroup at smc.vnet.net
Try
Plot[Evaluate[Dt[Sin[x], x]], {x, 0, 1}]
marco
>From: Arkadiusz Majka <majka at icm.edu.pl>
To: mathgroup at smc.vnet.net
You must evaluate derivative first.
Plot[Evaluate[Dt[Sin[x],x],{x,0,1}]
A.
>From: bghiggins at ucdavis.edu
To: mathgroup at smc.vnet.net
Wrap the argument with Evaluate:
Plot[Evaluate[Dt[Sin[x], x]], {x, 0, 1}]
Cheers,
Brian
>From: Bob Hanlon <hanlonr at cox.net>
To: mathgroup at smc.vnet.net
Plot has attribute HoldAll
Attributes[Plot]
{HoldAll,Protected}
Use Evaluate
Plot[Evaluate[Dt[Sin[x],x]],{x,0,1}];
Plot[Evaluate[D[Sin[x],x]],{x,0,1}];
Bob Hanlon
>From: "Borut Levart" <BoLe79 at gmail.com>
To: mathgroup at smc.vnet.net
Try evaluating the argument to Plot first:
Plot[Evaluate[Dt[Sin[x], x]], {x, 0, 1}]
>From: dh <dh at metrohm.ch>
To: mathgroup at smc.vnet.net
Hi Walter,
look at the attributes of Plot:
Attributes[Plot]
and you will see that it has "HoldAll". This means that Dt[Sin[x], x]
will not be evaluated before x is replaced by a numerical value, e.g.
Dt[Sin[0.5], 0.5]. That is not what you want. You must force evaluation by:
Plot[Evaluate[ D[Sin[x], x] ], {x, 0, 1}]
By the way, you do not need the total differential here Dt, D will do
the job.
Daniel
>From: "David Park" <djmp at earthlink.net>
To: mathgroup at smc.vnet.net
When making plots, I often think it is good practice to prepare the plotting
function first, so you know exactly what it is, and then put it in the Plot
statement.
f[x_] = Dt[Sin[x], x]
Cos[x]
Plot[f[x], {x, 0, 1}];
What actually happened is explained by the fact that Plot has the attribute
HoldAll. In plotting each point, it holds the function, substitutes the x
variable and then evaluates the function. In this case the expression is
invalid when a number is substituted for x (at each place it occurs). Here
is an example when x = 0.01.
Hold[Dt[Sin[x], x]]
% /. x -> 0.01
% // ReleaseHold
Hold[Dt[Sin[x], x]]
Hold[Dt[Sin[0.01], 0.01]]
General::ivar: 0.01` is not a valid variable.
Dt[0.00999983, 0.01]
which is not what you wanted at all.
Of course, the simple answer is just to Evaluate the function in the Plot
statement.
Plot[Dt[Sin[x], x] // Evaluate, {x, 0, 1}];
But I have seen a number of postings on MathGroup where there is quite
extensive data processing put into the Plot statement. Much better, I think,
to prepare the plotting function first and disentangle derivations and data
processing from plotting.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
>From: walter hausser [mailto:nodi at freesurf.ch]
To: mathgroup at smc.vnet.net
Hello
Why doesn't this work?
Plot[Dt[Sin[x],x],{x,0,1}]
How do I do it correctly?
Thanks
>From: jmt <jmt at dxdydz.net>
To: mathgroup at smc.vnet.net
Try this :
Plot[Evaluate[Dt[Sin[x], x]], {x, 0, 1}]
>From: Pratik Desai <pdesai1 at umbc.edu>
To: mathgroup at smc.vnet.net
Plot has Attribute HoldAll, its evaluation is "non-standard"
In[1]:=
Attributes[Plot]
Out[1]=
{HoldAll,Protected}
In the mathematica book Section 2.6.5 (you can access this using the
Mathematica tab in your help browser and type 2.6.5) you can see what
this actually means..
The upshot is essentially use Evaluate with your plot commands and it
works fine
Plot[Evaluate[D[Sin[x],x]],{x,0,1}]
Hope this helps
Pratik Desai
>From: Peter Pein <petsie at dordos.net>
To: mathgroup at smc.vnet.net
Hi Walter,
try
Plot[Evaluate@Dt[Sin[x], x], {x, 0, 1}]
and have a look at
First@Attributes@Plot
--> HoldAll
"HoldAll" in the documentation.
Peter
>From: Bill Rowe <readnewsciv at earthlink.net>
To: mathgroup at smc.vnet.net
It doesn't work because of the way Plot evaluates its arguments. That is Plot evaluates the function to be plotted by substituting a numerical value for x and expects a numerical value in return. Since you cannot take the derivative of a function with respect to a numeric argument you get an error message stating the numeric value isn't a valid variable which in turn causes Plot to complain the result of the evaluation wasn't a machine-sized real.
The solution is to force evaluation of the derivative before Plot tries to substitute numeric values. That can be done with
Plot[Evaluate@Dt[Sin[x],x],{x,0,1}]
--
>From: ggroup at sarj.ca
To: mathgroup at smc.vnet.net
You need to wrap the argument in Evaluate[]. In other words:
Plot[Evaluate[Dt[Sin[x],x]],{x,0,1}]
Prev by Date:
**Re: General--Making the DisplayFormula style in ArticleModern look like Traditional**
Next by Date:
**Re: ndsolve & compile**
Previous by thread:
**Plot derivative**
Next by thread:
**Re: Plot derivative**
| |