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

I'm trying to reproduce the first example on page 37 of The Cadabra Book.

I tried in cadabra2-gtk and jupyter kernel but I got a strange result. Instead of a dot in between I got a comma and a dot over.

In cadabra2-cli this is the output : \dot(A , D) \dot(B , C) which when entered in notebook give me the same wrong result.

Here is the code I'm running :


> {\mu, \nu, \rho, \sigma}::Indices(vector);

> ex:= A\\_\\{\mu\\} B\\_\\{\nu\\} C\\_\\{\nu\\} D\\_\\{\mu\\};

> substitute\(\_\, $A?\_\{\rho\} B?\_\{\rho\} \-\> \dot\{A?\}\{B?\}$\, repeat=True\);
in Bug reports by (340 points)
edited by

2 Answers

+2 votes

That used to work back when \dot{...} was reserved to always print as a centered dot, but this goes against the idea that you should be able to use it as e.g. a time derivative.

In order to make the example work, you therefore need to tell Cadabra that you want to print this in a different way. Add a LaTeXForm property, as in the first line below,

\dot(A??,B??)::LaTeXForm("(", A??, "\cdot{}", B??, ")");

{\mu, \nu, \rho, \sigma}::Indices(vector);
ex:= A_{\mu} B_{\nu} C_{\nu} D_{\mu};
substitute(_, $A?_{\rho} B?_{\rho} -> \dot{A?}{B?}$, repeat=True);

and it works again. Thanks for spotting this, will update the docs.

by (86.3k points)

How do you write nice code here? I was unable to display it correctly.

I have put in the full example above.

You can write code like that by pressing the 'CB' icon in the editor here ("code block"). Uses standard markdown: triple back-quotes.

0 votes

Maybe I don't write it correctly but it's not working for me

can you show me the complete line ?

by (340 points)
...