I have a symbolic function (which is in fact an operator) f[expr, x]
where the second argument is a local variable for f
(kind of like how Integrate[expr, x]
is set up).
How do I make analysis functions like D
act on f[expr, x]
similar to how D
acts on Inactive[Integrate]
:
D[Inactive[Integrate][Sin[p x^2], x], p]
Inactive[Integrate][x^2 Cos[p x^2], x]
D[f[Sin[p x^2], x], p]
x^2 Cos[p x^2] Derivative[1, 0][f][Sin[p x^2], x] (*Wrong*)
This output is wrong because x^2 Cos[p x^2]
has incorrectly been pulled out of f
.
Edit: It should work if f
appears arbitrarily deep inside expr
. Another test case that needs to work:
D[a * f[Sin[p x^2], x], p]
with the desired result:
a*f[x^2*Cos[p*x^2], x] (*Desired*)
D
onf
with e.g.f /: D[_f, x_] := someOperation[f, x]
-- do you mean something else? $\endgroup$f /: D[body_f, x_] := someOperation[body, x]
$\endgroup$