vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
982 stars 118 forks source link

[newbie] Derivative of polynomial of CTensors #415

Closed fetchinson closed 1 year ago

fetchinson commented 1 year ago

I'm wondering how to do the following in FORM: I have a gauge field $A\mu^a$ which I defined as a CTensor A[mu,a] in FORM and I also have a polynomial in A[mu,a] and some other quantities like momenta, p[mu], k[mu], etc. What I'd like to have is various derivatives of this expression with respect to A[mu,a], almost always a scalar, so at least 2 derivatives. Things like a Laplacian in $A\mu^a$:

$\frac{ \partial^2 }{ {\partial A_\mu^a}^2 } P(A)$

where $P(A)$ is the polynomial. How would I go about doing this?

tueda commented 1 year ago

If you use non-commutative objects ((N)Tensor or (N)Function), it is easy to implement the chain rule for differentiation operators: $\cdots \nabla F \cdots = \cdots (\nabla F) \cdots + \cdots F \ \nabla \cdots$.

For example, the following code performs $\partial / (\partial A_{\mu_1}^{a1}) \cdots \partial / (\partial A{\mu_4}^{a_4})$ on a quartic polynomial of $A$, leading to the Feynman rule for the four-gluon vertex in QCD (with the Peskin & Schroeder convention, dropped the trivial factor $ig^2$):

#-
NFunction A,del;
CFunction f(antisymmetric);

* dimensions for space-time and color adjoint
Symbol d,na;

Index <mu1=d>,...,<mu9=d>;
Index <a1=na>,...,<a9=na>;

* for dummy indices
Index <nu1=d>,...,<nu9=d>;
Index <b1=na>,...,<b9=na>;

Local expr = - 1/4 * (
  + f(b1,b2,b3) * A(nu1,b2) * A(nu2,b3)
  * f(b1,b4,b5) * A(nu1,b4) * A(nu2,b5)
);

* take derivatives
multiply left, del(A(mu1,a1)) * del(A(mu2,a2)) * del(A(mu3,a3)) * del(A(mu4,a4));

* chain rule
repeat id del(A(mu1?,a1?)) * A(mu2?,a2?)
  = d_(mu1,mu2) * d_(a1,a2) + A(mu2,a2) * del(A(mu1,a1));

* drop derivatives because no remaining A on the right
id del(A(mu1?,a1?)) = 0;

P +s;
.end
Time =       0.01 sec    Generated terms =         24
            expr         Terms in output =          6
                         Bytes used      =        396

   expr =
       - f(a1,a2,b1)*f(a3,a4,b1)*d_(mu1,mu3)*d_(mu2,mu4)
       + f(a1,a2,b1)*f(a3,a4,b1)*d_(mu1,mu4)*d_(mu2,mu3)
       - f(a1,a3,b1)*f(a2,a4,b1)*d_(mu1,mu2)*d_(mu3,mu4)
       + f(a1,a3,b1)*f(a2,a4,b1)*d_(mu1,mu4)*d_(mu2,mu3)
       - f(a1,a4,b1)*f(a2,a3,b1)*d_(mu1,mu2)*d_(mu3,mu4)
       + f(a1,a4,b1)*f(a2,a3,b1)*d_(mu1,mu3)*d_(mu2,mu4)
      ;

If you like to get a "Laplacian"

* take derivatives
multiply left, del(A(mu1,a1)) * del(A(mu1,a1));

should be fine.

If you need to keep your functions as CFunction, you can temporarily convert CFunction to NFunction and convert them back after performing differentiation:

CFunction A;
NFunction AA;

id A(?a) = AA(?a);

* take derivatives with respect to AA here

id AA(?a) = A(?a);
fetchinson commented 1 year ago

Thanks a lot, this works very well!