# Total applied to the lists: length of the object

My goal is to evaluate the total of each line of the following list:

f2 = {{c1, c2 Log[(En k T1)/(c^4 m^2)], c3 Log[(En k T1)/(c^4 m^2)]^2, c4 Log[(En k T1)/(c^4 m^2)]^3, c5 Log[(En k T1)/(c^4 m^2)]^4, c6 Log[(En k T1)/(c^4 m^2)]^5}, {c1, c2 Log[(En k T2)/(c^4 m^2)], c3 Log[(En k T2)/(c^4 m^2)]^2, c4 Log[(En k T2)/(c^4 m^2)]^3, c5 Log[(En k T2)/(c^4 m^2)]^4, c6 Log[(En k T2)/(c^4 m^2)]^5}, {c1, c2 Log[(En k T3)/(c^4 m^2)], c3 Log[(En k T3)/(c^4 m^2)]^2, c4 Log[(En k T3)/(c^4 m^2)]^3, c5 Log[(En k T3)/(c^4 m^2)]^4, c6 Log[(En k T3)/(c^4 m^2)]^5}, {c1, c2 Log[(En k T4)/(c^4 m^2)], c3 Log[(En k T4)/(c^4 m^2)]^2, c4 Log[(En k T4)/(c^4 m^2)]^3, c5 Log[(En k T4)/(c^4 m^2)]^4, c6 Log[(En k T4)/(c^4 m^2)]^5}, {c1, c2 Log[(En k T5)/(c^4 m^2)], c3 Log[(En k T5)/(c^4 m^2)]^2, c4 Log[(En k T5)/(c^4 m^2)]^3, c5 Log[(En k T5)/(c^4 m^2)]^4, c6 Log[(En k T5)/(c^4 m^2)]^5}, {c1, c2 Log[(En k T6)/(c^4 m^2)], c3 Log[(En k T6)/(c^4 m^2)]^2, c4 Log[(En k T6)/(c^4 m^2)]^3, c5 Log[(En k T6)/(c^4 m^2)]^4, c6 Log[(En k T6)/(c^4 m^2)]^5}, {c1, c2 Log[(En k T7)/(c^4 m^2)], c3 Log[(En k T7)/(c^4 m^2)]^2, c4 Log[(En k T7)/(c^4 m^2)]^3, c5 Log[(En k T7)/(c^4 m^2)]^4, c6 Log[(En k T7)/(c^4 m^2)]^5}}


To achieve that, I have used.

In[31]:= f3 = Table[Total[f2[[l]]], {l, Length[f2]}]
Out[31]= {c1 + c2 Log[(En k T1)/(c^4 m^2)] + c3 Log[(En k T1)/(c^4 m^2)]^2 + c4 Log[(En k T1)/(c^4 m^2)]^3 + c5 Log[(En k T1)/(c^4 m^2)]^4 + c6 Log[(En k T1)/(c^4 m^2)]^5, c1 + c2 Log[(En k T2)/(c^4 m^2)] + c3 Log[(En k T2)/(c^4 m^2)]^2 + c4 Log[(En k T2)/(c^4 m^2)]^3 + c5 Log[(En k T2)/(c^4 m^2)]^4 + c6 Log[(En k T2)/(c^4 m^2)]^5, c1 + c2 Log[(En k T3)/(c^4 m^2)] + c3 Log[(En k T3)/(c^4 m^2)]^2 + c4 Log[(En k T3)/(c^4 m^2)]^3 + c5 Log[(En k T3)/(c^4 m^2)]^4 + c6 Log[(En k T3)/(c^4 m^2)]^5, c1 + c2 Log[(En k T4)/(c^4 m^2)] + c3 Log[(En k T4)/(c^4 m^2)]^2 + c4 Log[(En k T4)/(c^4 m^2)]^3 + c5 Log[(En k T4)/(c^4 m^2)]^4 + c6 Log[(En k T4)/(c^4 m^2)]^5, c1 + c2 Log[(En k T5)/(c^4 m^2)] + c3 Log[(En k T5)/(c^4 m^2)]^2 + c4 Log[(En k T5)/(c^4 m^2)]^3 + c5 Log[(En k T5)/(c^4 m^2)]^4 + c6 Log[(En k T5)/(c^4 m^2)]^5, c1 + c2 Log[(En k T6)/(c^4 m^2)] + c3 Log[(En k T6)/(c^4 m^2)]^2 + c4 Log[(En k T6)/(c^4 m^2)]^3 + c5 Log[(En k T6)/(c^4 m^2)]^4 + c6 Log[(En k T6)/(c^4 m^2)]^5, c1 + c2 Log[(En k T7)/(c^4 m^2)] + c3 Log[(En k T7)/(c^4 m^2)]^2 + c4 Log[(En k T7)/(c^4 m^2)]^3 + c5 Log[(En k T7)/(c^4 m^2)]^4 + c6 Log[(En k T7)/(c^4 m^2)]^5}


This seems correct, but when I check the length of each element, this is.

In[32]:= Length[f3[[1]]]
Out[32]= 6


so, I can't use it as a list of 7 elements since it has a higher dimension. Do you know why? Is there a way to "flatter" these elements?

I tried also the function Sum but it works in the same way.

• Check: Dimensions@f3
– Syed
Feb 23 at 11:00
• f3 has a length of 7. f3[[1]] is the first element of f3, consisting of a sum of 6 elements. Feb 23 at 11:12
• Try Length[Plus[x, y, z]]. It gives the length of any expression, not just of lists. Note that using the level spec, Total[f2, {2}], yields f3. Feb 23 at 11:25
• Do you mean: "Total of each sublist" under the words: "total of each line of the following list?" If yes, try this: Map[Total, f2]. Feb 23 at 11:39
• In your example, Length[f3[[1]]] is 6 because there are six terms in the expression. See the $Scope$ section of the Length documentation. Feb 23 at 12:20