Is there currently any possibility to replace subexpressions in tensor
expressions? I am trying to evaluate Feynman diagrams; computing the
gamma_trace is easy, but how do i substitute the fourvector products
(tensor multiplications) that occur in the end?
Here is an example
from sympy import *
from sympy.physics.hep.gamma_matrices import GammaMatrix as G
from sympy.tensor.tensor import tensor_indices, tensorhead, TensMul
init_printing()
p, q = tensorhead('p, q', [G.LorentzIndex], [[1]])
i0,i1,i2,i3,i4,i5 = tensor_indices('i0:6', G.LorentzIndex)
ps = p(i0)*G(-i0)*q(i0)*G(-i0)*G.LorentzIndex.metric(i4, i5)
t = G.gamma_trace(ps)
t
which yields
4∗metric(i4,i5)∗p(L0)∗q(−L0)
Now how can i replace p*q with another expression?
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/3891800d-eec8-4448-a900-af0c4181e0b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.