Answer: yes, there are certain algorithms for solving such issues.
Take a look at SymPy . SymPy is an open source library library written in pure Python. It contains many of these algorithms, and the code is available on github . Writers tried to emphasize clarity for this particular situation.
source share