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

I have installed cadabra2 on a Ubuntu 24.04 system using the deb file provided. I imported the sample notebook called einstein_equations.cnb which derives Einstein's equation using an action variation. The last cell to be executed using python gives the following error:

substitute: Index error in replacement rule. substitute: No numerical pre-factors allowed on lhs of replacement rule.

The offending cell is

t1 = action[1][0][0][2]
eom:= 2\kappa @(t1) = 0;
distribute(_)
collect_factors(_)
manip.to_rhs(_, $- \kappa T_{\mu\nu}$);
substitute(_, manip.swap_sides(einsteinTensor));

and the last substitute command appears to give the error. manip.swap_sides command is coming from the imported cdb.core.manip package.

Any ideas what is going wrong?

Also could anyone enlighten me on the syntactical meaning of the first two lines of this cell. I couldn't find any references to it in the manual...

Thanks

ago in General questions by (140 points)

2 Answers

+1 vote

The problem is the line

manip.to_rhs(_, $- \kappa T_{\mu\nu}$);

Just remove the minus sign so that it reads

manip.to_rhs(_, $\kappa T_{\mu\nu}$);
ago by (86.7k points)

Great thanks that works!

+1 vote

As for your other question: in

t1 = action[1][0][0][2]

we start from the equation action. This is of the form $$ S = \int \left(\cdots\right) {\rm d}x. $$ The action[1] takes the first child (counting from zero), which is the right-hand side. Could also have been written as rhs(action). Then the zeroth child of that is the integrand, the zeroth child of the integrand is the first term, and the 2nd child of that is the thing that multiplies $\sqrt{-g} \delta g^{\mu]$ (the 2nd factor in the product).

As for the second line,

eom:= 2\kappa @(t1) = 0;

This defines a new expression eom, which is an equation. The @(t1) pulls the expression which is known to python as t1 (defined in the first line) into this new eom expression.

You may want to read at least the first chapter of the cadabra book, if the input format confuses you.

ago by (86.7k points)

Ah makes sense. That technique of child extraction sounds pretty useful. As well as reading your book more carefully I might also need to brush up on my python skills ;-).

Thanks for your help!

...