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

Numerical substitution in powers does not canonicalise #247

Closed kpeeters closed 1 year ago

kpeeters commented 2 years ago
n::Integer;
bpzrl := {
    \alpha_{n}^{\mu} -> - (-1)**{n} \alpha_{- n}^{\mu}
};

def bpz(ex):
    distribute(ex)
    substitute(ex, bpzrl)
    sort_product(ex)
    return ex

XX := \alpha_{1}^{\mu}.
bpz(XX);

This produces a weird left-over factor (-1)^1 in the product, which should be simplified automatically.

kpeeters commented 1 year ago

Fixed in 0c99588370.