Defining a tensor which take tensor as a prameter

22 views
Skip to first unread message

shubham kumar sinha

unread,
Feb 16, 2026, 4:07:19 AM (3 days ago) Feb 16
to xAct Tensor Computer Algebra
Hi,

I want to define a tensor function which take some tensor as a parameter and give me a tensor.

for example if I want to define project tensor pT[v][a,b] which should give met[a,b] - p[a]p[b](p[c] p[-c])

where P[a] is a vector on manifold M.  PT i want to define such that i can call for different values of p.

DefManifold[M3, 3, {i1, i2, i3, i4, i5, i6, i7}];
DefMetric[-1, met[-i1, -i2], CD, {";", "\[Del]"}, PrintAs -> "g"];
DefTensor[p[i1], M3];
DefTensor[q[i2], M3];

DefTensor[PT[-i1, -i2], M3, Symmetric[{-i1, -i2}]];
PTDef = PT[p][-i1, -i2] ==
   met[-i1, -i2] - p[-i1] p[-i2] 1/(p[-i3] p[i3]);
PTRule = ToRule[PTDef, MetricOn -> All, ContractMetrics -> True];
AutomaticRules[PT, PTRule];

But this does not work. If anyone can give me suggestion or hint then it will be very helpful.

Best,
Shubham

Jose

unread,
Feb 16, 2026, 2:20:00 PM (2 days ago) Feb 16
to xAct Tensor Computer Algebra
Hi,

You don't need to define PT to construct a function that construct tensors. The Def commands are needed for objects that will appear in outputs of expressions.

Take this setup:

<< xAct`xTensor`

DefManifold[M3, 3, {i1, i2, i3, i4, i5, i6, i7}];
DefMetric[-1, met[-i1, -i2], CD, {";", "\[Del]"}, PrintAs -> "g"];
DefTensor[p[i1], M3];
DefTensor[q[i2], M3];
$PrePrint = ScreenDollarIndices;

Then I think you want a construction like this, where we use Scalar to wrap scalars that are dividing:

PT[p_][a_, b_] := met[a, b] - p[a] p[b]/Scalar[p[i1] p[-i1]]

Then you can check the projector property:

In[29]:= PT[p][i1, -i2] PT[p][i2, -i3] // PutScalar // Simplification
Out[29]= xAct`xTensor`delta[i1, -i3] - (p[i1]   p[-i3])/xAct`xTensor`Scalar[p[-i1] p[i1]]

Cheers,
Jose.

shubham kumar sinha

unread,
Feb 16, 2026, 9:59:13 PM (2 days ago) Feb 16
to xAct Tensor Computer Algebra
Thanks! I was wondering why there is reed bracket around scalar product p[i1]p[-i1] .

Jose

unread,
Feb 16, 2026, 10:01:06 PM (2 days ago) Feb 16
to xAct Tensor Computer Algebra
The red parentheses represent the Scalar head, which means that the indices inside are disconnected from the indices outside, and therefore can be repeated. You can see each Scalar[...] object as a fully independent tensorial expression, which happens to be a scalar.

Cheers,
Jose.

Reply all
Reply to author
Forward
0 new messages