[Date Index]
[Thread Index]
[Author Index]
Re: ? D[f,{x,n}]
*To*: mathgroup at smc.vnet.net
*Subject*: [mg25554] Re: ? D[f,{x,n}]
*From*: "Allan Hayes" <hay at haystack.demon.co.uk>
*Date*: Sat, 7 Oct 2000 03:35:59 -0400 (EDT)
*References*: <8rjioe$oea@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Jack,
It seems that D[f,x] and D[f, {x,1}] are independently definable
Clear[D]
Unprotect[D];
D[f_, x_] := A
D[f_, {x_, 1}] := B
DownValues[D]
{HoldPattern[D[f_, {x_, 1}]] :> B, HoldPattern[D[f_, x_]] :> A}
Never mind the math its the matching that counts.
D[f, x]
A
D[f, {x, 1}]
B
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Jack Goldberg" <jackgold at math.lsa.umich.edu> wrote in message
news:8rjioe$oea at smc.vnet.net...
> 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:
**Re: List element manipulation**
Next by Date:
**RE: RE: Hold, HoldForm, ReleaseHold when Plotting multiple functions**
Previous by thread:
**Re: ? D[f,{x,n}]**
Next by thread:
**Re: RE:? D[f,{x,n}]**
| |