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
Product
of a numerical coefficient and the term _combine_like_terms()
also combinesNumeral
s such that there are at most oneNumeral
in aSum
.- Nested sums are flattened.
- Numerals of 0s are removed.
Product
- Combines
Numeral
s to become acoeff
at 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
Bracket
class are changed to the underlying type. - An empty
Sum
will be changed to aNumeral
of 0. - A singleton
Sum
will be changed to the underlying type. - An empty
Product
will be changed to aNumeral
of itscoeff
- A product with a single factor and
coeff
of 1 will be changed to the underlying type - A product with a
coeff
of 0 will be changed to aNumeral
0. - A
Quotient
with a numerator ofNumeral
0 will be changed 0 - A
Quotient
with a denominator ofNumeral
1 will be changed to the underlying numerator type - A
Quotient
withNumerals
on both numerator and denominator will be changed to aNumeral
class - A
Quotient
with a negativeNumeral
or a negativeProduct
will be changed to a product with acoeff
of-1
- An
Exponent
with positive integralNumeral
power and aProduct
base will be cased of aProduct
ofExponents