Given a list
{{{a1},{a2},{a3},{a}},
{{a4},{a2},{a6},{a}},
{{a7},{a8},{a9},{a}},
{{b1},{b2},{b3},{b}},
{{b4},{b2},{b6},{b}}}
I want to change this to
{{{1},{a2},{a1*a3+a4*a6},{a}},
{{a7},{a8},{a9},{a}},
{{1},{b2},{b1*b3+b4*b6},{b}}}
As you can see
The first element is multiplied to the third element and gets contracted by summing all the modified third elements, which labels at the end and the same and second element are the same. When Contraction happens, first element becomes 1
.
The first element is a number, third column is an expression, and labels are some operators.
How can I achieve this?
Caution It is not a matrix manipulation problem!