Constructible Number Library on PYPI
I just uploaded my library for representing constructible numbers in Python to PYPI, so you can install it with “pip install constructible”.
It was very straight forward following Peter Downs’ guide “How to submit a package to PyPI”.
Internal representations are not always stored in their simplest form, despite correctly comparing with equivalent representations. For example, sqrt(sqrt(2))*sqrt(sqrt(2)) == sqrt(2) evaluates correctly, but the internal representation of the LHS doesn’t collapse automatically to the RHS.
This causes problems when performing computations such as sqrt(1-cos_x*cos_x)==0, where the internal representation of cos_x==1 is Constructible(Constructible(Fraction(0, 1), Fraction(0, 1), ()), Constructible(Fraction(1, 2), 0, ()), (Constructible(Fraction(2, 1), 0, ()), ())); in this specific case the internal intermediate computation encounters a division by zero.
To fix this, representations should be simplified as soon as an operation is performed on a Constructible object. This could be done, for example, by converting to its str form and back; however, this may be too expensive. A more efficient method would be to adapt the internal technique utilised to obtain the irreducible string representation.