There are two possible approaches:
(1)
To map an operator exponential onto a MatrixExp
, one would have to assume that there exists an orthogonal basis of the function space in which the target functions f[x]
can be expanded. Then construct a matrix representing the operator in that basis. For example, the momentum operator $p$ is diagonal in the Fourier basis, and therefore we can do the exponential very easily in that basis. But we may not always be able to determine the expansion coefficients in a chosen basis in closed form. As a result, you end up with matrices corresponding to a truncated expansion of the function f[x]
. Exact results can be obtained in this approach if your function space is finite-dimensional and the operator doesn't throw you out of that space.
(2)
Instead of truncating the expansion of f[x]
in some basis, you can truncate the series for the exponential at some order of the expansion. Truncation in either approach genrally can't be avoided, but this approach is very common since the exponential series is absolutely convergent over the complex numbers.
However, the usual form of the series expansion for the exponential requires you to calculate factorials at every order. This is inefficient from a computational point of view.
Instead, the exponential of an operator can be conveniently (and efficiently) defined by using a recursive formula for the exponential. This is implemented here:
Clear[f, operatorExp];
operatorExp[dop_, n_] := Function[f, Fold[f + dop[#1]/#2 &, f, Reverse@Range[n]]]
This one-liner defines the exponential of dop
up to a number n
of terms. The result is itself an operator, taking as its argument a function of the form f[x]
. Here I'll illustrate what this does to a general operator dop
:
Clear[dop,x];
operatorExp[dop, 4][f[x]]
$\text{dop}\left(\frac{1}{2}
\text{dop}\left(\frac{1}{3}
\text{dop}\left(\frac{1}{4}
\text{dop}(f(x))+f(x)\right)+f(x)\right)+f(x)\right)+f(x)$
Now try it for a well-known example (the Taylor series), and then for an operator with non-commuting terms. To do this, I use Function
to define the operators dOp
and dOp2
. They assume that the independent variable of the differential operation is x
.
dOp = Function[f, D[f, x]];
operatorExp[dOp, 3][f[x]]
$f(x) + f'(x)+\frac{1}{2} \left(\frac{1}{3}
f^{(3)}(x)+f''(x)\right)$
dOp2 = Function[f, x + D[f, x]];
operatorExp[dOp2, 3][f[x]]
$x + f(x) + f'(x)+\frac{1}{2} \left(\frac{1}{3}
f^{(3)}(x)+f''(x)+1\right)$
Applied to the specific problem in the question
Here I use the momentum as the differentiation variable in the operator:
Clear[c,p];
dOp3 = Function[f, c D[f, p]];
Expand[operatorExp[dOp3, 3][f[x, p]]]
$\frac{1}{6} c^3
f^{(0,3)}(x,p)+\frac{1}{2} c^2
f^{(0,2)}(x,p)+c
f^{(0,1)}(x,p)+f(x,p)$
By using Expand
, I turned the recursively factored form back into something that looks like the usual Taylor expansion.
...
bit? One approach would beSeries[f[x, p + c], {c, 0, 2}]
but that's because I know what the resummed series looks like. $\endgroup$...
? $\endgroup$