       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)
• Organization: Technische Universitaet Darmstadt
• References: <200703021123.GAA03190@smc.vnet.net> <esr1f4\$6o7\$1@smc.vnet.net>

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

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

Puh.

Thank you, Carl, for your suggestions!  Still, I'm not sure about
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:=
quatify[a_Plus] := Distribute[Unevaluated[quatify[a]]]
SetAttributes[quatify, Listable]
quatify[arg_] := quat[Head[arg]] @@ arg

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

In:= quat /: MakeBoxes[quat[fun_],
form:StandardForm | TraditionalForm] :=
ToExpression["d"<>ToString[fun]]

Test the above:

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

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

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

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

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

Out=
(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
• Next by thread: ReadList and columns