1 comment
  1. Constructible said:
    Constructible's avatar

    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.

Leave a comment

Design a site like this with WordPress.com
Get started