# Multiplying \sqrt{2} by 1/\sqrt{2} crashes the kernel unexpectedly

+1 vote

Hi,

In Cadabra 2.2.0 I am having some trouble cancelling numerical factors involving powers of 1/2 and minus 1/2.

For instance, if I evaluate

$2 1/2$;


However if I evaluate

$2**(1/2) 2**(-1/2)$;


Cadabra outputs in TeX \sqrt{2} 2^{-1/2} and does not combine these.

If I try to make it do so using collectfactors(), I get a "The kernel crashed unexpectedly" message. (And actually I notice this happens in Cadabra 1 too...)

Conversely, it collects_factors correctly for

$X**(1/2) X**(-1/2)$;
collect_factors(_);


Is this meant to happen? Am I missing some very basic instruction on how to treat numbers?

Thanks!

+1 vote

No, this is a bug. You'd be surprised how many computations can be done without ever encountering this one... Will fix, thanks.

selected by

A quick workaround is to use sympy to simplify this; the following works:

$2**(1/2) 2**(-1/2)$;
simplify(_);


(you need to have the sympy package for python installed, either by installing a python3-sympy package or something similar, or by installing it through sudo pip3 install sympy or similar).

Better and somewhat more robust is

 map_sympy(_, "simplify");


Okay, wow, that is indeed surprising. Thanks for the quick reply. In the meantime I will rescale my vielbein components...

Aha even better - have installed sympy as suggested and can now use simplify, which indeed works. Thanks a lot!