# Define an operator for long equations

I'm trying to workout a long expression with derivations, the thing is I can't seem to transfer this problem to code.

What I need is a operator $$D = l^\mu \frac{\partial}{\partial x^\mu}$$ where $$l^\mu$$ is a vector. Problem is I have long expression, for expample I need to write a equation $$(D + \epsilon + \kappa + \gamma )(D -\omega + \kappa)\phi == 0,$$ where all functions $$(\epsilon, \gamma, \kappa, \phi) = (\epsilon(x^i), \gamma(x^i), \kappa(x^i), \phi(x^i))$$.

For this reasons defining $$D$$ as

DD = Sum[l[[i]] D[#,x[[i]]],{i,1,4}]&


Is not usefull because I would have to expand eqaution for $$\phi$$ and then rewrite is in terms $$D[\epsilon,\kappa,\gamma,\phi]...$$. Note that I choose to wtite $$D$$ as $$DD$$ in code so it isn't confused with Mathematicas derivative funciton.

There are other expressions which I need to write out and other derivatives. Is there any way to define $$D$$ so that I can just write the equation and get the result?

Define

x = {a, b, c, d};
l = {1, 2, 3, 4};
DD = l . D[#, {x}]&


and then use prefix notation to approximate your expression:

(DD[#] + ε + κ + γ &) @ (DD[#] - ω + κ &) @ φ

• Yes, but it becomes very difficult to write out the equations in terms of $DD[expr]$. I would like if it were possible to define $DD$ in such way, where we can just write out the expression and $DD$ is automatically mapped to expressions. Mar 13 at 10:11
• I guess I still don't understand what you need. What do you mean by mapping automatically? Can you give an example of what you need? Mar 13 at 10:12
• Considering the equation give above I would like to write (having already defined $𝑒𝑒,𝑔𝑔,𝑦𝑦,𝑜𝑜,𝑘𝑘,𝑝ℎ$ as functions of $𝑥^𝑖$) (DD + ee + gg + yy)(D-oo+kk)ph ==0. Now I would like automatically get the expressions as DD[DD[ ph]] + DD[ ee ph] + DD[ gg ph] + DD[ kk ph] + ee kk ph + gg kk ph - DD[ oo ph] - ee oo ph - gg oo ph + DD[ ph yy] + kk ph yy - oo ph yy == 0 which is the written out form. Or define $DD$ in such a way, that this is done automatically, which was my original question. Mar 13 at 10:19
• Automatically means not having to rewrite the expressions by hand. Mar 13 at 10:25
• ok maybe now I got it, please see update Mar 13 at 11:14