All about simplification
Jan 29 2024
In this post, we list out all the steps the Mathlify library does to "simplify" expressions.
Fraction
- "Hoist" negative denominators to the numerator if necessary so that denominators are always positive. For example, will be simplified to .
- Extract gcd such that the numerator and denominator are coprime. For example becomes and becomes .
Sum
- Combines like terms into a
Productof a numerical coefficient and the term _combine_like_terms()also combinesNumerals such that there are at most oneNumeralin aSum.- Nested sums are flattened.
- Numerals of 0s are removed.
Product
- Combines
Numerals to become acoeffat the start of the product - Nested products are flattened
- (New feature introduced 24/6/17) Product containing a quotient will be changed into a quotient with the products in the numerator
Expression
The Expression class allow us to modify the underlying type
- Any
Bracketclass are changed to the underlying type. - An empty
Sumwill be changed to aNumeralof 0. - A singleton
Sumwill be changed to the underlying type. - An empty
Productwill be changed to aNumeralof itscoeff - A product with a single factor and
coeffof 1 will be changed to the underlying type - A product with a
coeffof 0 will be changed to aNumeral0. - A
Quotientwith a numerator ofNumeral0 will be changed 0 - A
Quotientwith a denominator ofNumeral1 will be changed to the underlying numerator type - A
QuotientwithNumeralson both numerator and denominator will be changed to aNumeralclass - A
Quotientwith a negativeNumeralor a negativeProductwill be changed to a product with acoeffof-1 - An
Exponentwith positive integralNumeralpower and aProductbase will be cased of aProductofExponents