Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: Keeping 'f[x,y,z]' in derivative expressions

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Keeping 'f[x,y,z]' in derivative expressions
  • From: John Lee <lee at math.washington.edu>
  • Date: Thu, 4 Jun 92 14:34:27 -0700

Robby Villegas <Villegas%Knox.Bitnet at uicvm.uic.edu> writes:

   Tom Grandy asked about changing 'Sqrt[m^2 + x^2 + y^2 + z^2]' back to
   'f[x, y, z]' after differentiating an expression with f in it.

   Before I offer a couple of things I tried, I have a question that arose while
   playing with this problem.  I ended up making definitions for f's derivatives
   manually, such as

        Derivative[1, 0, 0][f][x, y, z] = x / f[x, y, z]

   and in an attempt to follow the "object-oriented programming" practice
   suggested in the Mathematica book, I tried to associate this to the symbol 'f'
   instead of to 'Derivative', so as not to overload Derivative with junk.  What
   I got when I preceded the above assignment with "f /: " (TagSet for f) was a
   complaint that 'f' was not in a valid position for assignment.  It seems more
   natural to tag this to f.  Also, if you define derivatives for several
   different symbols, say g and h as well as f, then you can't clear out f's
   definitions with Clear[Derivative] because that would wipe out g's and h's
   derivative definitions, too.  Does anyone know how to tag the assignment to
   'f'?  Or some alternative to doing that?

The tag on an assignment has to be either the top-level head (Derivative in
the case above), or one of the arguments (x,y,z), or the head of one of the
arguments (as is a in f[a[b]]).  One way to do what you want is to define
the derivative of f as a "pure function", as follows:

  In[19]:= f/: Derivative[1,0,0][f] = #1 / f[##] &

             #1
  Out[19]= ------ & 
           f[##1]

  In[20]:= D[f[x,y,z],x]

               x
  Out[20]= ----------
           f[x, y, z]

Of course, this is cumbersome, and perhaps not feasible for very
complicated expressions; but I don't think there's any other way.

Jack Lee
Dept. of Mathematics
University of Washington
Seattle, WA 98105





  • Prev by Date: Re: unions ... Oops.
  • Next by Date: Functional solution to union of intervals
  • Previous by thread: Re: unions ... Oops.
  • Next by thread: Functional solution to union of intervals