MathGroup Archive 1996

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

Search the Archive

Re: A simple question?

  • To: mathgroup at
  • Subject: [mg3651] Re: A simple question?
  • From: lou (Lou D'Andria)
  • Date: Sun, 31 Mar 1996 00:52:59 -0500
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

In article <4jd5ej$pmr at>, nader at
(Nader Tajvidi) wrote:

     >        I guess this must be a simple question, but I can't seem to
     >find a good solution to it. For a function f[x,y] I want to create a
     >2x2x2x2 matrix called fourthDs. The elements of fourthDs will be the
     >fourth derivatives of f with respect to x and y in the following form:
     >        This simply means that the number of 1's in the index will
     >give the number of derivations with respect to x and the number of 2's
     >in the index will give the number of derivations with respect to y. In
     >this case there will be 5 different elements in fourthDs. For example,
     >the last element in the above list will be the same for
     >fourthDs[[2,1,1,1]], fourthDs[[1,1,2,1]] and so on.


As usual with Mathematica, there are many, many different ways to do what
you need.  The most straight-forward, given your description in the last
paragraph above, is this.


There is at least one problem with this though.  It calculates most of the
derivatives more than once.  In fact, D[f[x,y],{x,2},{y,2}] is calculated
6 different times!  That's a bit wasteful.  Here's a solution that
calculates each derivative exactly once.

Array[Plus,{2,2,2,2},0] /. Table[i->D[f[x,y],{x,4-i},{y,i}],{i,0,4}]

The third argument to Array sets the "origin" of the array.  So that
instead of elements running from {1,1,1,1} through {2,2,2,2}, the elements
will run from {0,0,0,0} to {1,1,1,1}.

Here are some more methods which will work - almost one for every day of
the week.  ;-)  I believe that each one uses a different idea, and all of
them except the last one are wasteful in their calculation of
derivatives.  Enjoy!






Lou D'Andria


  • Prev by Date: Re: re: ANOVA
  • Next by Date: packages
  • Previous by thread: Re: A simple question?
  • Next by thread: Re: A simple question?