Sums of Functions as Derivative Operators
- To: mathgroup at smc.vnet.net
- Subject: [mg33096] Sums of Functions as Derivative Operators
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 1 Mar 2002 06:53:27 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Dear MathGroup,
I would be interested in any comments on this little piece of Mathematica
and mathematics.
If f and g are functions and a and b are constants, we usually use the rule
(a f + b g)[t] == a f[t] + b g[t]
What about
(a f + b g)'[t] == a f'[t] + b g'[t] ?
What is the easiest method to get Mathematica to make this simplification?
Mathematica won't simplify the above expression (of course, how does it know
that f and g are functions?), but it won't simplify the following either.
(Cos + Sin)'[t] or even
(Cos[#] & + (Sin[#] &))'[t]
Nor does Through seem to work.
It seems that the way to simplify (a f + b g)'[t] is to actually write
(Function[t, a Function[t, f[t]][t] + b Function[t, g[t]][t]])'[t]
a f'[t] + b g'[t]
But that is certainly quite cumbersome. So I wrote a little routine which
will convert a linear derivative expression to the functional form. You have
to give it a list of symbols which will be regarded as functions.
DerivativeBreakout[functions_List][expr_] :=
Module[{temp},
temp =
expr //. Derivative[args__][a_ + b_] :>
Derivative[args][Function[t, a[t] + b[t]]];
temp //.
Derivative[args__][
a_?(FreeQ[#, Alternatives @@ functions] &) f_?(MemberQ[
functions, #] &)] :>
Derivative[args][Function[t, a f[t]]]
]
(a f + b g)'[t]// DerivativeBreakout[{f, g}]
a f'[t] + b g'[t]
(Cos + Sin)'[t] // DerivativeBreakout[{Cos, Sin}]
Cos[t] - Sin[t]
Is there a better method for doing this?
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/