kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
215 stars 37 forks source link

Meld bug #226

Closed kpeeters closed 2 years ago

kpeeters commented 3 years ago

Originally posted by Arina on the Q&A.

{a,b,c,d,e,f,g,h,i,j,k,l,m,n,q,r,s,u,v,w,z#}::Indices(full,values={t,x,y}, position=independent).
\partial{#}::PartialDerivative.
\nabla{#}::Derivative.
{\nabla{#},\partial{#}}::Commuting.
h_{m? n?}::Metric.
h^{m? n?}::InverseMetric.
h_{m? n?}::Symmetric.
h^{m? n?}::Symmetric.
p::Depends(\nabla{#}, \partial{#}).
\phi::Depends(\nabla{#}, \partial{#}).
h_{m n}::Depends(\partial{#}).
h^{m n}::Depends(\partial{#}).
G4::Depends(\nabla{#}, \partial{#}).
G4p::Depends(\nabla{#}, \partial{#}).
G4X::Depends(\nabla{#}, \partial{#}).
G4XX::Depends(\nabla{#}, \partial{#}).
R::Depends(\nabla{#}, \partial{#}).
F_{m n}::Depends(\nabla{#}, \partial{#}).
F^{m n}::Depends(\nabla{#}, \partial{#}).
pi2::Depends(\nabla{#}, \partial{#}).
boxpi4::Depends(\nabla{#}, \partial{#}).
pi24::Depends(\nabla{#}, \partial{#}).
p::LaTeXForm("\pi").
G4p::LaTeXForm("G_{4\pi}").
G4X::LaTeXForm("G_{4X}").
G4XX::LaTeXForm("G_{4XX}").
G4Xp::LaTeXForm("G_{4\pi X}").
boxpi4::LaTeXForm("\Box^{(4)}{\pi}").
pi24::LaTeXForm("\pi^{\mu \nu}\pi_{\mu \nu}").
mathcalG{#}::LaTeXForm("\mathcal{G}").

G4 := mathcalG^{4}_{a b} =  -  1/2 G4X R \nabla_{a}(p) \nabla_{b}(p)-2G4 \nabla_{a}(\phi) \nabla_{b}(\phi) (\phi)**(-1) + \nabla_{c}(\nabla_{d}(G4)) h^{c d} h_{a b}
+ \nabla_{c}(G4X \nabla_{d}(p) boxpi4) h_{a b} h^{c d} 
+ \nabla_{d}(G4X \nabla_{a}(\nabla_{c}(p)) \nabla_{b}(p)) h^{d c}-\nabla_{c}(G4X \nabla_{a}(\nabla_{b}(p)) \nabla_{d}(p)) h^{c d}; 
meld(G4);

The result is:

https://sun9-42.userapi.com/impg/5KgSyCX43Lj8g9jlTeWoZ0Gkl--HeOKGSROUqw/x63QYCeAssk.jpg?size=699x169&quality=96&proxy=1&sign=aa6fd8cde7d0ecdbdb305539a09b6948&type=album

slazav commented 2 years ago

I also have found a strange thing about meld():

{j,k}::Indices;
ex := A = - x x n_{k} n_{k} - x x n_{j} n_{j};
meld(_);

Result is A = 2x x n_{k} n_{k} instead of -2x x n_{k} n_{k}

Is there any way to avoid using meld() if I just want to get rid of antisymmetric tensor with repeating index, like e_{j j k}?

slazav commented 2 years ago

One more example of strange meld():

#!/usr/bin/cadabra2

{a,b,c}::Indices;
{a,b,c}::Integer(1..3);
{X,Y}::Symbol
{X,Y,n_{a}}::Commuting

ex := 10 X n_{a} Y + 2 Y X n_{a};
meld(_);

ex := 10 X n_{a} Y + 2 X Y n_{a};
meld(_);

Results: (100X Y + 4Y X) n_{a} and 104X Y n_{a} instead of 12 X Y n_{a}

kpeeters commented 2 years ago

A fix is in preparation, hang on.

kpeeters commented 2 years ago

@slazav: Dom has fixed the issues you were seeing. You still need a sort_product for your 10 X n_{a} Y + 2 Y X n_{a} example, but that is expected behaviour. Changes are in github on the master branch.

slazav commented 2 years ago

Yes, it works! Thank you