CAS Best Practices

Okay I see why the Nemo and Flint timings are so similar: Nemo just uses Flint for the calculation. This is what I meant by speed ultimately being determined by the lower-level libraries.

Yes, that is what I would do if I was making a new CAS. Not just x - x and also x/x. Also y + x would not automatically canonicalise to x + y. Functions like cos(0) should stay as cos(0). This is about both performance and usability. Many of the things that people want to use a CAS for are not necessarily about computing anything: they just want to be able to manipulate expressions in a controlled way.

In SymPy you can do that with cos(0, evaluate=False) and Add(y, x, evaluate=False). Using evaluate=False is a kludge though that tries to repair the damage caused by automatic evaluation retrospectively. It can never fully work because evaluation needs to default to False from the foundations. Any kind of automatic evaluation once introduced is very hard to remove because future code comes to depend on it.

How in Symbolics.jl do I create the expression cos(0) or sin(pi) or even sqrt(2)?

11 Likes