Keeping Head xTensor when defining objects in xCoba

Skip to first unread message

Max Banados

Jan 26, 2023, 10:10:45 PMJan 26
to xAct Tensor Computer Algebra
Dear all, I have a simple question (I believe). 

In xCoba with a 3d Manifold and chart (ch) defined, I have introduced a vector, say,

v = CTensor[{1,2,3},{ch}]

Its Head is xTensor as it should be. Now I define the product

T[a,b] = v[a] v[b]

The problem is that the Head of T is not xTensor, and this brings some trouble with 
other calculations.  I have found a way around (adapting a previous message from José) 

(T = HeadOfTensor[v[a] v[b], {a, b}])[a, b]

The question is: Is this the right way to do this?  
Would this form properly treat the indices used in the definition (a,b) as dummy?  
(Is there a simpler way to do this?  My real calculation is way more complicated...)



Jan 26, 2023, 10:26:21 PMJan 26
to xAct Tensor Computer Algebra

From the vector

   v = CTensor[{1, 2, 3}, {ch}]

there are basically two ways of performing the tensor product v * v : either via indices or in index-free form:

   - The formula you gave, using HeadOfTensor, is the right way to do this operation with indices: you first put indices in both v vectors, let the product happen (with the indices taking care of order), and finally remove the indices again to get T (with HeadOfTensor).

   - Internally xCoba converts that operation with indices into an index-free operation, using this internal function:

      In[ ]:= T = xAct`xCoba`Private`CTensorProduct[v, v]
      Out[ ]= CTensor[{{1, 2, 3}, {2, 4, 6}, {3, 6, 9}}, {ch, ch}, 0]

The three fundamental operations of tensor algebra (tensor products, transpositions and contractions) can be performed with indices or in index-free form, and there are respective internal functions for those operations (CTensorProduct, CTensorTranspose and CTensorContract). For simple cases the index-free functions may be useful and more efficient, but as soon as the computations get complicated, the indexed approach is easier to read/write, and hence safer, in my opinion.


Max Bañados

Jan 27, 2023, 10:43:03 AMJan 27
to Jose,
Dear José, 

Thank you very much for your quick and informative reply. I agree that (error-free) tensor products are easier with indexed expressions. 

You received this message because you are subscribed to a topic in the Google Groups "xAct Tensor Computer Algebra" group.
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages