# Issues with vary

+1 vote

Why will following code produce odd result?

{\mu,\nu}::Indices(vector).
\Vt{#}::LaTeXForm("{\tilde{V}}").
ex:=\int{\Vt_{\mu}\Vt^{\mu}};
vary(_,$\Vt_{\mu}->\delta{\Vt_{\mu}}$);


Keep in mind that if you want to continue working with this expression, you better declare \delta{#} to have the Accent property, otherwise it will soak up the indices (the expression \delta{\Vt_{\mu}} counts as a scalar, not a vector, otherwise).

I have added the property Accent, but I still get the wrong result:

$$\int{{\tilde{V}}{{\tilde{V}}_{\mu}} {\tilde{V}}^{\mu}+{\tilde{V}}_{\mu} {\tilde{V}}{{\tilde{V}}^{\mu}}}$$

With just that snippet? I get

$$\int ( \delta(\tilde{V}_{\mu}) \tilde{V}^{\mu} + \tilde{V}_{\mu} \delta(\tilde{V}^{\mu}))$$

as expected.

This is my code:

{\mu,\nu}::Indices(vector).
\delta{#}::Accent.
\Vt{#}::LaTeXForm("{\tilde{V}}").
ex:=\int{\Vt_{\mu}\Vt^{\mu}};
vary(_,$\Vt_{\mu}->\delta{\Vt_{\mu}}$);


Well, that gives (for me) the answer I displayed. Which version of cadabra?

Version 2.2.9 (build 2295.e85d69ac56 dated 2019-12-18)

Very strange. Which platform (Linux/macOS/Windows)?

Linux...........

I confirm the behaviour reported by @Eureka. See the image

Cadabra: Version 2.2.7 (build 2275.333ca654f6 dated 2019-12-03

OS: Debian Linux (bullseye)

Ok, vary seems to do something with the expression tree which corrupts the tree, and then depending on what is in memory, the bug will get triggered (I have now reproduced it a few times). Hang on.

This is a printing problem actually, the tree structure is fine. As a temporary workaround, use

\delta{#}::IndexInherit;


instead of using the Accent property. Has the same effect (indices of whatever \delta acts on will be visible 'outside' the \delta), but prints correctly.

Confirm that the work around works!

Ok, It works.