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

Hello!

I am very a new Cadabra user and I am trying to expand partial derivative of a vector field A i.e. $\partial_{\mu} { A^{\mu} }$ with the following snippet of code:

{A^t,A^x, A^y, A^z}::Depends(\partial{#});
A := {A^{t}=A^t,A^{x}=A^x, A^{y}=A^y, A^{z}=A^z};
dA:=\partial_{\mu}{ A^{\mu} };
evaluate(dA,A);

which returns an error: RuntimeError: Dependencies on derivatives are not yet handled in the SymPy bridge

I ideally want it to give me the componenet expansion like: $ \partial_{\mu} { A^{\mu} } = - \partial_t A^t + \partial_x A^x + \partial_y A^y + \partial_z A^z $.

Also I want it to return a 2x2 matrix when I try to evaulate $ \partial_{\mu} { A^{\nu} } $.

Thanks in advance!

in General questions by (180 points)

1 Answer

+2 votes
 
Best answer

Whenever you evaluate, the expression should not contain derivatives, otherwise simplification by sympy will throw that error. But you can turn that off, so the following does what you want:

\partial{#}::PartialDerivative;
{t,x,y,z}::Coordinate;
{\mu, \nu}::Indices(values={t,x,y,z});
A^{\mu}::Depends(\partial{#});

dA:=\partial_{\mu}{ A^{\mu} }; 
evaluate(dA, simplify=False);

If you replace the last two lines with

dA:=\partial_{\mu}{ A^{\nu} }; 
evaluate(dA, simplify=False);

you get that 2x2 expression.

by (82.6k points)
selected by
...