For Programmers: Free Programming Magazines  


Home > Archive > Mathematica > May 2006 > Re: applied to numeric constants









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: applied to numeric constants
Andrzej Kozlowski

2006-05-30, 4:15 am


On 29 May 2006, at 19:06, Andrew Moylan wrote:

> Hi,
>
> Do numeric constants have special behaviour under the Derivative[1]
> function?
>
> The number e.g. 2 is not defined as the function that always
> returns 2:
>
> In[1]:=2[x]
> Out[1]=2[x]
>
> But Derivative[1][2] is defined:
>
> In[2]:=2'
> Out[2]=0&
>
> Could anyone explain why this is? Is this behaviour documented in the
> help system?
>
> Cheers,
>
> Andrew
>



I can't give a definitive answer but note that we also have this
closely related behaviour,that is documented:

In[1]:=
SetAttributes[f,Constant]

In[2]:=
Derivative[1][f]

Out[2]=
0&

or

In[3]:=
D[f[#]&,#]

Out[3]=
0&

and

In[4]:=
Dt[f[#]&]

Out[4]=
0&


This is consistent with the documentation for Constant:

Functions f[ … ] are taken to have zero total derivative if f has
attribute Constant.

If a symbol f with attribute Constant is treated in this way, it
seems reasonable that genuine constants like 2 also are, although I
can't find any explicit mention of this (perhaps nobody has
considered the possibility that anyone might ask ;-)). But note that
(from the Help for Derivative):

Whenever Derivative[n][f] is generated, Mathematica rewrites it as D[f
[#]&, {#, n}].

So Derivative[1][2] is D[2[#]&,{#,1}] and presumably, for the same
reason as f[#]& when f has attribute Constant, this is taken to be 0.

As for the "deeper reasons" why this is so: at the moment I can't
think of one. I might play some role in the mechanism of functional
differentiation or it could simply be a side-effect of something that
does.

(Of course, the function that always returns 2 is 2& and it has the
same derivative as the abnormal "function" 2[#]& (or simple 2):

Derivative[1][2&]

0&


Derivative[1][2]


0&

Andrzej Kozlowski

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com