       Re: "Transparency" with respect to differentiation

• To: mathgroup at smc.vnet.net
• Subject: [mg74055] Re: "Transparency" with respect to differentiation
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Thu, 8 Mar 2007 04:31:45 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <es909c\$2c5\$1@smc.vnet.net> <eslrt9\$ptl\$1@smc.vnet.net>

```Martin Schoenecker wrote:
> Regarding the object quat with the following properties
>
>> quat[a_+b_]:=quat[a]+quat[b]
>> quat/:D[quat[fun_],var__]:=quat[D[fun,var]]
>
> The unwanted behaviour was that differenciation was carried out before
> distribution:
>
>> In:= D[quat[f[x] + g[x]], x]
>> Out= f'[x] quat'[f[x]] + g'[x] quat'[g[x]]
>
> I found out with the help of the Mathematica Reference Guide, A.2.7 that
>   UpValues have a higher precedence than DownValues, which explains this
> behaviour.  Trying to give the needed rule explicitly results in
>
>
> quat /: D[quat[(a_) + (b_)], var__] :=
>    D[quat[a], var] + D[quat[b], var]
>
> \$Failed
> TagSetDelayed::"tagpos":" .... too deep for an assigned rule to be found.
>
> Now the question, reformulated, is:  how could I define the mentioned
> properties so that they would be carried out in the right order?
>
> Thanks,
> Martin
>

Does something like the following meet your needs?

In:=
quat[(a_) + (b_)] := quat[a] + quat[b];
quat /: D[quat[fun_], var__] := quat[D[fun, var]];
Unprotect[D];
D[quat[(a_) + (b_)], var__] := D[quat[a], var] + D[quat[b], var];
Protect[D];

In:=
quat[f[x] + g[x] + h[x]]
D[quat[f[x] + g[x]], x]
(D[#1, x] & ) /@ quat[f[x] + g[x]]
D[quat[f[x] + g[x]], x]
D[quat[f[x]], x]

Out=
quat[f[x]] + quat[g[x]] + quat[h[x]]

Out=
quat[Derivative[f][x]] +
quat[Derivative[g][x]]

Out=
quat[Derivative[f][x]] +
quat[Derivative[g][x]]

Out=
quat[Derivative[f][x]] +
quat[Derivative[g][x]]

Out=
quat[Derivative[f][x]]

Regards,
Jean-Marc

```

• Prev by Date: Re: Simplifying {0,0,0}.X.{0,0,0}
• Next by Date: Re: Problem with Which
• Previous by thread: Re: "Transparency" with respect to differentiation
• Next by thread: Re: "Transparency" with respect to differentiation