# Doing algebra with differential operators

I'm doing some work on stochastic processes, where I use random functions which are defined by their properties over averages, i.e $$\langle f(t) \rangle =0 \\ \langle f(t) f(t')\rangle = \alpha(x,y) e^{-(t-t')^2}$$ Is there a way to define something like this?

My problem is that I have a multitude of spatial derivatives applied to those functions in different ways which I can take out of the time average i.e. $$\langle \partial_x f(t) \partial_{y'} f(t')\rangle = \partial_x \partial_{y'} \langle f(t) f(t')\rangle$$ Is there a way to just do the algebra with the operators where I could then apply a complex differential operator onto my correlation function?

Best

There is a problem with the build in D, Dt, and Derivative operators:

They execute in such a way, as if any symbolic function is differentiable in the ordinary sense.

So if you manage to replace

mean[ f'[x] * g'[y]] :> D[  mean[ f[x] * g[y]],  x,y]


you get immediately

f'[x] g'[y] (mean'[f[x] g[y]]  +f[x] g[y] (f'[x] g'[y]) mean''[ f[x] g[y]]


None of the expressions is what you want. Conclusion: The D operator outside the mean is a strange object.

In order to suppress automatic execution while preserving the printed repesentation is an Inactive[D]

mean[a'[b] c'[d]] /. {mean[f_'[x_] g_'[y_]] :> Inactive[D][mean[f[x] g[y]], x, y]}


Observe that you cannot Activate D before its first argument is a differentiable expression or an arithmetic function with respect to the variables.

On the other hand, writing the mean as an integral, there are no problems in exchanging integration and differentiation

Integrate[ w[u] D[f[x, u], x]*D[g[y,u], y],u] == D[Integrate[ w[u]f[x,u]*g[y,u], u]], x, y]

True