Re: Re: A simple question? Correction
- To: mathgroup at smc.vnet.net
- Subject: [mg3655] Re: [mg3654] Re: A simple question? Correction
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Tue, 2 Apr 1996 21:54:47 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Count Dracula points out that the last definition in my previous posting on this topic should be G[F_, vars__][args__] := G[F, vars][Sequence@@Sort[{args}]] = D[F[vars], args] not G[F_, vars__][args__] := G[F, vars][Sequence@@Sort[args]] = D[F[vars], args] The corrected form is attached. Allan Hayes hay at haystack.demon.co.uk A generally applicable technique will shorten to Count Dracula's solution to the problem posed by nader at math.chalmers.se (Nader Tajvidi) in [mg3627]. The problem is > 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: > fourthDs[[1,1,1,1]]=D[f[x,y],{x,4}] > fourthDs[[2,2,2,2]]=D[f[x,y],{y,4}] > fourthDs[[1,2,1,1]]=D[f[x,y],{x,3},{y,1}] Count Dracula's solution is >>For a function f with arguments vars, and maxord = maximum order >>of derivative needed in the matrix, the function dmatrix will >>create such a matrix. >> G[F_, vars__][args__] /; OrderedQ[{args}] := >> G[F, vars][args] = D[F[vars], args] >> >> G[z__][args__] := G[z] @@ Sort[{args}] >> >> dmatrix[f_Symbol, vars__Symbol, maxord_Integer] := >> Outer[ G[f, vars], Sequence @@ Table[{vars}, {maxord}] ] We can replace the first two definitions with G[F_, vars__][args__] := G[F, vars][Sequence@@Sort[{args}]] = D[F[vars], args] ==== [MESSAGE SEPARATOR] ====