Simplify returned the reciprocal of the right answer for a quotient whose denominator carried a negative factor.
"(1/x) / (-1 - 1/x)".ToEntity().Simplify() => -(1 + x)
At x = 1 the expression is -1/2 and that answer is -2.
The cause is in Patterns.NumericNeatRules. Four of the rules there take a negative constant out of a product and multiply the rest by it, which is right. The two that take it out of a denominator were written the same way:
Divf(var any2, Mulf(Real { IsNegative: true } num, var any1)) => -((-num) * (any1 / any2)),
but a / (-b * c) is -(a / (b * c)), not -(b * (c / a)). Simplify keeps whichever of its candidates is shortest, so the inverted form won wherever it was smaller than the correct one -- which is wherever the numerator is 1, hence the shape above.
Found from a limit rather than by hand: l'Hopital's rule simplifies the quotient of derivatives it builds, and (1/x) / (-1 - 1/x) is the shape of one. lim x->0+ (tan(x) * ln(x)) came back NaN because of it.
Filing for the record -- the fix is in #714 with five regression cases, each checking the value at a point rather than the printed form.
Simplifyreturned the reciprocal of the right answer for a quotient whose denominator carried a negative factor.At
x = 1the expression is-1/2and that answer is-2.The cause is in
Patterns.NumericNeatRules. Four of the rules there take a negative constant out of a product and multiply the rest by it, which is right. The two that take it out of a denominator were written the same way:but
a / (-b * c)is-(a / (b * c)), not-(b * (c / a)).Simplifykeeps whichever of its candidates is shortest, so the inverted form won wherever it was smaller than the correct one -- which is wherever the numerator is 1, hence the shape above.Found from a limit rather than by hand: l'Hopital's rule simplifies the quotient of derivatives it builds, and
(1/x) / (-1 - 1/x)is the shape of one.lim x->0+ (tan(x) * ln(x))came back NaN because of it.Filing for the record -- the fix is in #714 with five regression cases, each checking the value at a point rather than the printed form.