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


I've found some strange thing: If I have an expression with square root in it, and try to substitute it, like

Eq := \sqrt(X);
substitute(Eq, $\sqrt(X) -> A$);

it works and I get A. But if I send it to sympy in the middle, the substitution stops working

Eq := \sqrt(X);
map_sympy(Eq, 'simplify');
substitute(Eq, $\sqrt(X) -> A$);

This particular example is silly, but it illustrates the problem.

in Bug reports by (1.6k points)

1 Answer

+2 votes

Ah, that's a good one. Internally, cadabra always writes X**(0.5) even when you write \sqrt{X}. But somehow this canonicalisation does not get applied when the \sqrt{X} comes back from Python. And then the substitute does not match anymore.

This requires a cadabra fix. It may be possible to convince sympy to output as X**(0.5) as a temporary workaround; I don't know off the top of my head.

by (80.5k points)