Re: "Transparency" with respect to differentiation

• To: mathgroup at smc.vnet.net
• Subject: [mg74107] Re: "Transparency" with respect to differentiation
• From: Martin Schoenecker <ms_usenet at gmx.de>
• Date: Sat, 10 Mar 2007 06:53:32 -0500 (EST)
• References: <200703021123.GAA03190@smc.vnet.net> <esr1f4\$6o7\$1@smc.vnet.net>

```> In[3]:=
> oldheads = "ExcludedFunctions" /. ("DifferentiationOptions" /.
> Developer`SystemOptions["DifferentiationOptions"]);
> In[4]:=
> Developer`SetSystemOptions["DifferentiationOptions" ->
>      "ExcludedFunctions" -> Append[oldheads, quat]] // InputForm
> In[5]:=
> D[quat[x], x] // InputForm
> In[6]:=
> quat /: D[quat[a_], x_] := quat[D[a, x]]
> quat[a_Plus] := Distribute[Unevaluated[quat[a]]]

> In[7]:=
> D[quat[f[x] + g[x]], x] // OutputForm
> Out[7]//OutputForm=
> quat[f'[x]] + quat[g'[x]]

Puh.

changing default values in Mathematica.  Now I got the idea for this
marker we called quat not to mark all of the expression, but only the
Head.  So define a method that makes functions quattened:

In[1]:=
quatify[a_Plus] := Distribute[Unevaluated[quatify[a]]]
SetAttributes[quatify, Listable]

And, because it looks ugly, format the output a bit nicer, by prepending
a "d" to the marked functions:

In[4]:= quat /: MakeBoxes[quat[fun_],
ToExpression["d"<>ToString[fun]]

Test the above:

In[5]:=
funlist = {f[x], f[x] + g[x], h[x, y]}
qfunlist = quatify[funlist]
Dqfunlist = D[qfunlist, x]
FullForm[%]

Out[5]= {f[x], f[x] + g[x], h[x, y]}
Out[6]= {df[x], df[x] + dg[x], dh[x, y]}
Out[7]=
(1,0)
{df'[x], df'[x] + dg'[x], dh     [x, y]}

The above is human readable, but still interpretable for Mathematica:

Out[8]//FullForm=
List[Derivative[1][quat[f]][x],
Plus[Derivative[1][quat[f]][x], Derivative[1][quat[g]][x]],
Derivative[1, 0][quat[h]][x, y]]

In[9]:=
D[c quatify[k[x, y, z]], x]

Out[9]=
(1,0,0)
c dk       [x, y, z]

Best Regards,
Martin

```

• Prev by Date: RE: Re: Multi-core Support in Mathematica 5.2
• Next by Date: Re: Evaluate a spline function
• Previous by thread: Re: "Transparency" with respect to differentiation