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

Hi and thanks as always for cdb.

Please consider the following definition of an "inner product":

{α, β}::Indices(spacetime).
σ::LaTeXForm("\mathbf{σ}").
σ::DifferentialForm(degree=1).

e_{idx?}::LaTeXForm("\mathbf{e}", "_{", idx?, "}").

inner{a?? b??}::LaTeXForm("\langle",a??,", ",b??,"\rangle").

This works nicely when I write

σβ := inner{σ e_{β}} ;

but it fails when I write

σβ := σ_{β} = inner{σ e_{β}} ;

The error is

RuntimeError: Free indices on lhs and rhs do not match

What am I doing wrong please?

Thank you

GPN

in General questions by (2.0k points)
recategorized by

1 Answer

+2 votes
 
Best answer

That message says that the left-hand side ($\sigma_{\beta}$) does not have the same free indices as the right-hand side. As it stands, the right-hand side does not have any free indices, as functional arguments (things which do not have a sub- or super-script symbol) do not propagate their indices outside the function.

If you add

inner{a?? b??}::IndexInherit.

then the index $\beta$ on the $e_\beta$ inside inner will be 'visible' on the outside of inner, and things match up.

by (83.1k points)
selected by

Also please be aware that many LaTeX installations will not handle UTF8 greek symbols, so sharing notebooks which use these may lead to trouble. Better write things out using TeX notation.

Thank you. You're right. Though using the greek alphabet is so cool...

...