Tag Set Delayed and D

I used the Tag Set Delayed to set

F /: D[F[f_], x_] := F[D[f, x]]

It works if I give as input a single F:

D[F[g[x]],x] = F[g'[x]]

the result is as expected. However if I insert a linear combination of Fs

D[F[g[x]] + F[h[x]], x] = F'[g[x]]g'[x]+F'[h[x]]h'[x]

D[F[g[x]] + F[h[x]], x] = F[g'[x]] + F[h'[x]]

I was expecting the last result since I thought that first the D would distribute on Fs

D[F[g[x]],x] + D[F[h[x]],x]

and then my Tag Set Delayed would have applied.

Defining

d[a_ + b_] := d[a] + d[b];
F/:d[F[g_],x_]:=F[d[g,x]];

I gat the expected result

d[F[g[x]]+F[h[x]],x] = F[d[g[x],x]]+F[d[h[x],x]]

Which is what I would like to have with D.

Question

How can I get the same behavior with D?

• Can you provide a MWE?
– MaPo
Commented Feb 11, 2019 at 14:09
• I was thinking F as an operator. Imagine F = Sum. It is linear and a derivative can be moved inside.
– MaPo
Commented Feb 11, 2019 at 14:26
• With F = Sum there is no contradiction in D[Sum[f[x] , ...], x]. How can I have a similar structure with a generic F?
– MaPo
Commented Feb 11, 2019 at 14:33

You need to turn off automatic handling of derivatives for your function by adjusting the system options:

With[{old = OptionValue[SystemOptions["DifferentiationOptions"],"DifferentiationOptions"->"ExcludedFunctions"]},
SetSystemOptions["DifferentiationOptions" -> "ExcludedFunctions" -> DeleteDuplicates[Append[old, F]]]
];

D[F[a_], r__] ^:= F[D[a, r]]

Then:

D[F[g[x]] + F[h[x]], x]

F[g'[x]] + F[h'[x]]