MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ? D[f,{x,n}]


It seems to me that your definition for D[f_,x_] should work for both D[f,x] and
D[f,{x,n}], since the pattern matcher can match x to {x,n}. So why do you need an
additional definition for D[f_,{x_,n_}]?
For example, I ran the following test:










The From In[6] and From In[7] lines correspond to the print statements in the
mySimplification command. So, a single definition of D[f_,x_] is all you need.

You don't mention what your package does, but I don't think I would have chosen
to overload D with additional definitions as you have chosen to do. What exactly
are you trying to do in this package?


Jack Goldberg wrote:

> Hi folks,
> I am touching up a package I have worked on for a number of years.
> Rather than send it off as is, I keep tweeking it to improve its
> usefulness.  I should know better...  My latest tweek leads me to
> a problem with  D[f,{x,n}].  Here's the story:
> In my package I define a constant "flag" which I set true: flag = True.
> Then I Unprotect D:  Unprotect[D]:  I want to modify f before the built-in
> D fires so I write a little program:
>         D[f_,x_]/;flag := Block[ {flag=False},
>           D[ mySimplification[f],x]
>                 ]
> So, what I think happens is this. Since flag = True and since Mathematica uses
> my definition of D before its own, this little snippet fires.  Block sets
> flag = False, mySimplification[f] fires, and my definition of D does not
> fire again (or I would be caught in a loop) so Mathematica's definition of D
> now works and I have accomplished my aim which is to simplify f before
> taking the derivative.  This seems to work.  However, this idea fails to
> work for  D[f,{x,n}]!  Here's my code:
>         D[f_,{x_,n_}]/;flag := Block[ {flag=False},
>           D[ mySimplification[f],{x,n} ]
>                 ]
> (Of course, the nature of mySimplification should be irrelevant.)
> While trying to work out this problem, I discovered that I don't
> understand the difference between  D[f,x] and D[f,{x,1}].  If I
> alter the definition of D[f,x] have I also altered the definition
> of  D[f,{x,1}]?  How about the other way around?  If I alter the
> definiton of  D[f,{x,1}] does this alter the definition of D[f,x]?
> It seems as though they should be linked internally but if so,
> I can find no reference to this linkage. This not a mute point since
> I found that in trying to use mySimplification in both  D[f,x] and
> D[f,{x,n}] it is necessary to know what happens if a user chooses to
> write D[f,x] in the form  D[f,{x,n}].
> Help is needed.  Thanks.

  • Prev by Date: MultiLinear and Linear function
  • Next by Date: Re: Re: Hold, HoldForm, ReleaseHold when Plotting multiple functions
  • Previous by thread: ? D[f,{x,n}]
  • Next by thread: RE:? D[f,{x,n}]