Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

basically I have to simplify in Cadabra $\frac{1}{k.pk.(p+q) }+\frac{1}{k.qk.(p+q) }$ which is equal to $\frac{1}{k.p~~k.q }$

What I tried is


But its not helping.

The reason why I am asking these question is that I have a factor which involves simplification of such expressions.and I have to check gauge invariance of these factors with polarisation tensors also added.So the expressions gets complicated more.can I simplify such expressions in Cadabra

in General questions by (650 points)

1 Answer

+2 votes

I'll walk you through. First, it's always a good idea to declare which indices sit in the same set, so


Then your objects (unchanged),

w:= @(m) + @(n);

Expand the products which have a sum as one of their factors,


Now you have an expression which contains only simple scalar products. Cadabra offloads all scalar expression simplification to Sympy, but for that you need to get rid of the indices. Do

substitute(_, $k_{c} p_{c} = kp, k_{c} q_{c} = kq$, repeat=True);

And then finally

map_sympy(_, "together");

which collects the terms together.

This is a bit clunky (e.g. having to spell out that substitute rule), and the interface with Sympy is still quite new so can also be improved, but the above should get you what you want.

by (66.3k points)