# How can I construct a determinant-type differential operator?

How can I construct a determinant-type differential operator, where the multiplication of elements in the determinant represents the composition of multiple differential operators?

\begin{align*} \diamond\left(\bullet\right)&=\begin{vmatrix} a\!\cdot\!\left(\bullet\right)&b\!\cdot\!\left(\bullet\right)&c\!\cdot\!\left(\bullet\right)\\ \dfrac{\partial}{\partial\,\!x}\left(\bullet\right)&\dfrac{\partial}{\partial\,\!y}\left(\bullet\right)&\dfrac{\partial}{\partial\,\!z}\left(\bullet\right)\\ \dfrac{\partial^2}{\partial\,\!x^2}\left(\bullet\right)&\dfrac{\partial^2}{\partial\,\!y^2}\left(\bullet\right)&\dfrac{\partial^2}{\partial\,\!z^2}\left(\bullet\right)\\ \end{vmatrix}\\ &=a\!\cdot\!\left(\dfrac{\partial}{\partial\,\!y}\left(\dfrac{\partial^2}{\partial\,\!z^2}\right)\right)-a\!\cdot\!\left(\dfrac{\partial^2}{\partial\,\!y^2}\left(\dfrac{\partial}{\partial\,\!z}\right)\right)-b\!\cdot\!\left(\dfrac{\partial}{\partial\,\!x}\left(\dfrac{\partial^2}{\partial\,\!z^2}\right)\right)\\ &\qquad+b\!\cdot\!\left(\dfrac{\partial^2}{\partial\,\!x^2}\left(\dfrac{\partial}{\partial\,\!z}\right)\right) +c\!\cdot\!\left(\dfrac{\partial}{\partial\,\!x}\left(\dfrac{\partial^2}{\partial\,\!y^2}\right)\right)-c\!\cdot\!\left(\dfrac{\partial^2}{\partial\,\!x^2}\left(\dfrac{\partial}{\partial\,\!y}\right)\right)\\ &=a\dfrac{\partial^3}{\partial\,\!y\partial\,\!z^2}-a\dfrac{\partial^3}{\partial\,\!y^2\partial\,\!z}-b \dfrac{\partial^3}{\partial\,\!x\partial\,\!z^2}+b \dfrac{\partial^3}{\partial\,\!x^2\partial\,\!z} +c\dfrac{\partial^3}{\partial\,\!x\partial\,\!y^2}-c \dfrac{\partial^3}{\partial\,\!x^2\partial\,\!y} \end{align*}

The composites of differential operators are commutative and arranged in lexicographical order.

a*@  b*@  c*@
Dx@  Dy@  Dz@
Dxx@ Dyy@ Dzz@


What should I do if I want to get higher-order operators?

a*@     b*@     c*@     d*@
e*@     f*@     g*@     h*@
Dx@     Dy@     Dz@     Dw@
Dxx@    Dyy@    Dzz@    Dww@


## 3 Answers

We define a matrix with needed functions. To inhibit the instantaneous evaluation of the derivative operator, we write not "D", but "DD", an inert symbol:

m={{a # &, b # &, c # &},
{DD[#, x] &, DD[#, y] &, DD[#, z] &},
{DD[#, {x, 2}] &, DD[#, {y, 2}] &, DD[#, {z, 2}] &}};


Then we take the determinant:

det= Det[m];


We must next compose the product of operators:

det=Composition @@@ det;


Next we insert the argument. Note that "Compose" also acted on the product with "-" from the determinant. Therefore, we must also undo this.

det= (# [arg]) & /@ det;
det= det/. (-1)[x__] -> -x;


Now, we can change everything to a function and activate the derivative operator:

fun=Function[{arg}, Evaluate@det] /. DD -> D


Here is a test:

fun[x^2 y^3 z^4]


Addendum

For matrices with special forms like duplicate entries we may try another approach. We may first create the structure with dummy variables and afterwards insert the operators. With a 3x3 a matrix of inactive functions like above (for other dimensions this must be adapted):

m = {{a # &, b # &, c # &}, {DD[#, x] &, DD[#, y] &,
DD[#, z] &}, {DD[#, {x, 2}] &, DD[#, {y, 2}] &, DD[#, {z, 2}] &}};


we first create the structure:

det = Det[Array[a, {3, 3}]];


Then we insert the operators

det = det /.
HoldPattern[a[1, i1_] a[2, i2_] a[3, i3_]] :>
m[[1, i1]][m[[2, i2]][m[[3, i3]][arg]]];


Finally we define the function and activate the operators:

fun = Function[arg, Evaluate[det]] /. DD -> D;


A test:

fun[x^2 y^3 z^4]


For matrices with dimension nxn we would write Array[n,n] and:

det = det /.
HoldPattern[a[1, i1_] a[2, i2_] a[3, i3_] ... a[n, in]] :>
m[[1, i1]][ m[[2, i2]][ m[[3, i3]][... m[[m, in]][arg]  ]]]

• The code gives strange results for special matrices. Can you help me modify it? ( { {Times[a, #] &, Times[b, #] &, Times[c, #] &, Times[d, #] &}, {Times[d, #] &, Times[c, #] &, Times[b, #] &, Times[a, #] &}, {DD[#, x] &, DD[#, y] &, DD[#, z] &, DD[#, w] &}, {DD[#, {x, 2}] &, DD[#, {y, 2}] &, DD[#, {z, 2}] &, DD[#, {w, 2}] &} } ) Commented Apr 17, 2023 at 16:15
• The problem comes from having Square of functions in Det[m]. E.g.: contains (a #1 &)^2. Simply do not use the same name twice. E.g. use a1 and a2. Commented Apr 17, 2023 at 16:31
• Another solution would be to change the square of a function to a function with the square of the argument: det= Det[m] /. (x_ #1 &)^2 -> ((x^2) &) Commented Apr 17, 2023 at 16:40
• A new problem has arisen. Can you help me modify it? m = ({{Times[a, #]&, Times[f, #]&, Times[h, #]&, Times[d, #]&, Times[e, #]&, Times[j, #]&}, {Times[d, #]&, Times[b, #]&, Times[i, #]&, Times[f, #]&, Times[j, #]&, Times[g, #]&}, {Times[e, #]&, Times[g, #]&, Times[c, #]&, Times[j, #]&, Times[h, #]&, Times[i, #]&}, {DD[#, x]&, Times[0, #]&, Times[0, #]&, DD[#, y]&, DD[#, z]&, Times[0, #]&}, {Times[0, #]&, DD[#, y]&, Times[0, #]&, DD[#, x]&, Times[0, #]&, DD[#, z]&}, {Times[0, #]&, Times[0, #]&, DD[#, z]&, Times[0, #]&, DD[#, x]&, DD[#, y]&}}); Commented Apr 18, 2023 at 0:35
• I added a second method that should work for all operator matrices. The trick is to first create the structure before inserting the operators. It needs adaptation for different dimensions, this could also be automated but I think it is not worth the effort. Commented Apr 18, 2023 at 9:19

This is one (very inelegant, unfortunately) approach.

coeffs = {a, b, c};
vars = {x, y, z};

det1 = Det[{coeffs, d[slot, #, {1}] & /@ vars,
d[slot, #, {2}] & /@ vars}]

(* out *)
-c d[slot, x, {2}] d[slot, y, {1}] +
c d[slot, x, {1}] d[slot, y, {2}] +
b d[slot, x, {2}] d[slot, z, {1}] -
a d[slot, y, {2}] d[slot, z, {1}] -
b d[slot, x, {1}] d[slot, z, {2}] + a d[slot, y, {1}] d[slot, z, {2}]


Now replace multiple instanced of d by single operator

d /: HoldPattern[
Times[any_, d[slot, x_, dg_List], d[slot, y_, dg1_List]]] :=
Times[any, d[slot, Flatten[{Table[x, dg], Table[y, dg1]}]]]

det1
(* out *)
-c d[slot, {x, x, y}] + b d[slot, {x, x, z}] + c d[slot, {x, y, y}] -
b d[slot, {x, z, z}] - a d[slot, {y, y, z}] + a d[slot, {y, z, z}]


Finally construct the operator

detOp = (Function @@ {{slot},
det1 /. {d[slot, xl_List] :> d[slot, Sequence @@ xl]}}) /. d -> D


and test

detOp[f[x, y, z]]
(* out *)
a (f^(0,1,2))[x,y,z]-a (f^(0,2,1))[x,y,z]-b (f^(1,0,2))[x,y,z]+c (f^(1,2,0))[x,y,z]+b (f^(2,0,1))[x,y,z]-c (f^(2,1,0))[x,y,z]


I am unhappy with the approach and hope some one will come with much more elegant solution

In these case I resort to inert, self organized string manipulation.

Use partial derivative notation

Det[ Array[(
Subscript["\[PartialD]",
Times @@
Select[RandomChoice[{x, y, z}, {3}]^
RandomInteger[{0, 4}, 3], (# =!= 1 &)]] &), {4, 4}] ] //.
{Subscript["\[PartialD]", a_] Subscript["\[PartialD]",
b] _*x___ :> Subscript["\[PartialD]", a*b] x}


The symbolic derivatives as subscrpts can easly replaced by D[# ,var ] with x-^n- y-^m- :>{{x,n},{y,m}}