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

Hi Folks,

Here is a block of code that evaluates two expressions as functions of t.

{t,x,z}::Coordinate.
{i,j,k}::Indices(values={t,x,y,z}).

\partial{#}::PartialDerivative.

A::Depends{t}.

sub := {A_{x} = t, A_{y} = 2*t, A_{z} = 3*t};

abc := A_{i};
evaluate (abc, sub);

pqr := \partial_{t}{A_{i}};
evaluate (pqr, sub);

When you run this code you should notice two curious aspects of the results:

  1. The y-component is missing in both expressions. If y is added into the ::Coordinate property then the y-component is displayed for both expressions. I would have though that the evaluate command would use the values listed in the ::Index property rather than the ::Coordinate property to control the evaluation of objects.

  2. In the second expression the subscripts on the squares contain a t. This suggests to me that Cadabra has taken the definition of the pqr object as a subset of components of an object with 2 subscripts (i.e., the pqr object is the {t i} subset of the object \partial_{j}{A_{i}}). This seems innocuous but as the next example shows this can cause serious problems. In this example Cadabra crashes (Python spits a segmentation fault).

    {t,x,z}::Coordinate. {a,b,c,d}::Indices(values={t,x,y,z}).

    \partial{#}::PartialDerivative.

    sub := { A{x} = t, A{y} = 2t, A_{z} = 3t};

    Aa := A{a} + \partial{t}{A_{a}};

    evaluate (Aa, sub);

My guess is that in the + operation Cadabra attempts to add a single index object with a double index object -- and it's no surprise that this leads to grief. One way to fix this problem is to not use \partial_{t} directly but implicitly through a contraction as in the following example.

{t,x,z}::Coordinate.
{a,b,c,d}::Indices(values={t,x,y,z}).

\partial{#}::PartialDerivative.

sub := { D^{t} = 1, A_{x} = t, A_{y} = 2*t, A_{z} = 3*t};

Aa := A_{a} + D^{c}\partial_{c}{A_{a}};

evaluate (Aa, sub);

This works and gives the correct results. Note that the vector D^{a} has just one component D^{t} = 1 so the construction D^{c} \partial_{c} reduces to \partial_{t}.

So after this long preamble I have my questions

  1. Should the evaluate algorithm respect the indices listed in the ::Indices or the ::Coordinate property?

  2. Should expressions like

    Aa := A{a} + \partial{t}{A_{a}};

be legal?

  1. If the components of A are known to depend on some parameter, say m, how can I teach Cadabra to correctly interpret

    Aa := A{a} + \partial{m}{A_{a}};

where the parameter m is not a coordinate?

Sorry for the long post,

Cheers, Leo

in Bug reports by (1.8k points)

1 Answer

0 votes
 
Best answer

The current version on github fixes these problems for explicit derivatives with respect to Coordinates. Will make that work for derivatives wrt. Symbols as well soon (so that your last example works then too). I have tested the examples in your question, but please let me know if you still run into issues.

by (83.1k points)
selected by

The three examples now run without problems. Thanks Kasper.

...