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

I do not understand why g(.,v) only shows non-zero components after evaluation.

{m,n,a,b,c,r,s}::Indices(values={0,1,2,3}).
#
g_{a b}::Metric.
g^{a b}::InverseMetric.
#
g:=[g_{0 0}=-1, g_{0 1}=0, g_{0 2}=1, g_{0 3}=0, g_{1 0}=0,  g_{1 1}=1, g_{1 2}=0, g_{1 3}=0, g_{2 0}=1, g_{2 1}=0, g_{2 2}=1, g_{2 3}=0, g_{3 0}=0, g_{3 1}=0, g_{3 2}=0, g_{3 3}=1].
v:=[v^{0}=1, v^{1}=1, v^{2}=1, v^{3}=1];
display(v)
ex:=g_{a b} v^{a};
evaluate(ex,join(g,v), rhsonly=True);
OUTPUT gives
□_{b}
    {1} = 1
    {2} = 2
    {3} = 1

Setting g00=1 (tather than -1 above) gives

□_{b}
    {0} = 2
    {1} = 1
    {2} = 2
    {3} = 1
in General questions by (230 points)

1 Answer

+1 vote

That's an intentional choice, as for most 'interesting' tensors, there will typically be far more zero components than non-zero components (e.g. Riemann tensors). I guess we could make it configurable, but I haven't had the need for that so far.

by (82.0k points)

I guess it might be possible to define and set a variable, say zero_components=True, to display also the zero components of the expression.

...