Fix: Expression with square not sorted correctly #20
+50
−10,240
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Expression with square not sorted correctly because square does not get degree 2. You can see the difference before and after this PR in table below.
x^2+x^3+x
x^{3}+x+x^2
x^{3}+x^2+x
x^2+x^3+\sin(x)
x^{3}+x^2+\sin(x)
x^{3}+x^2+\sin(x)
\sin(x)+x^2+x^3
x^{3}+\sin(x)+x^2
x^{3}+x^2+\sin(x)
Some test's expected result have been changed. You can see changed test in this table.
x^2y^3+x^3y^2+xy^4+x^4y+x^2y^2
x^{4}y+xy^{4}+x^{3}y^2+x^2y^{3}+x^2y^2
x^{4}y+x^{3}y^2+x^2y^{3}+xy^{4}+x^2y^2
(b^3b^2)+(a^3a^2)+(b^6)+(a^5b)+(a^5)
a^{5}b+b^{6}+a^{5}+a^2a^{3}+b^2b^{3}
a^{5}b+b^{6}+a^2a^{3}+a^{5}+b^2b^{3}
Why I change the test's expected result?. Canocial form of those expression are inconsistent with other expressions that does not have square. You can see this table:
x^2y^3+x^3y^2+xy^4+x^4y+x^2y^2
x^{4}y+xy^{4}+x^{3}y^2+x^2y^{3}+x^2y^2
x^{4}y+x^{3}y^2+x^2y^{3}+xy^{4}+x^2y^2
(b^3b^2)+(a^3a^2)+(b^6)+(a^5b)+(a^5)
a^{5}b+b^{6}+a^{5}+a^2a^{3}+b^2b^{3}
a^{5}b+b^{6}+a^2a^{3}+a^{5}+b^2b^{3}
(b^3b^3)+(a^3a^3)+(b^6)+(a^5b)+(a^5)
a^{3}a^{3}+a^{5}b+b^{3}b^{3}+b^{6}+a^{5}
a^{3}a^{3}+a^{5}b+b^{3}b^{3}+b^{6}+a^{5
}`Also, this change fix some sorting result when there are square in expression and sin function.