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[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. 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[1]:= 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[4]:= quat /: MakeBoxes[quat[fun_], form:StandardForm | TraditionalForm] := 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
- References:
- "Transparency" with respect to differentiation
- From: Martin Schoenecker <ms_usenet@gmx.de>
- "Transparency" with respect to differentiation