lim x->0 (1/x^2 - 1/sin(x)^2) comes back NaN. The limit is -1/3:
x = 1e-2 -0.33334000
x = 1e-3 -0.33333340
x = 1e-4 -0.33333333
NaN is not "unevaluated" here -- it is the claim that the limit does not exist -- so
this is a wrong answer rather than a missing one. 1/sin(x)^2 - 1/x^2 is the same, and
csc(x)^2 - 1/x^2 returns unevaluated where it is 1/3.
"1/x^2 - 1/sin(x)^2".ToEntity().Limit("x", 0) // NaN, want -1/3
"1/sin(x)^2 - 1/x^2".ToEntity().Limit("x", 0) // NaN, want 1/3
"csc(x)^2 - 1/x^2".ToEntity().Limit("x", 0) // unevaluated, want 1/3
The unsquared forms are right, so this is next to what
#714 fixed rather than a regression of
it: 1/x - 1/sin(x) gives 0.
Two separate causes, both in Limits/Transformations.cs:
-
The difference does go over a common denominator, giving
(sin(x)^2 - x^2) / (x^2 * sin(x)^2), which is an ordinary 0/0 -- but l'Hopital's
rule refuses the first step. Its growth guard allows a quotient to grow by eight
nodes, and this one goes 17 -> 26. That budget is what growth looks like when the
divisor is a power of the variable, which shrinks when differentiated. A divisor that
is a product of vanishing factors grows by the product rule instead, so the chain
grows before it collapses -- 17 -> 26 -> 33 -> 46 -- and four steps then settle it
at -1/3. With the guard widened the answer comes out in about 2 s.
-
csc(x)^2 is written (1/sin(x))^2 in front of the descent, and SplitProduct does
not look inside a power for a denominator, so that term is read as having none and
the sum is never put over a common denominator at all.
Once l'Hopital declines, the descent substitutes each half's limit and answers
+oo - +oo, which is where the NaN comes from.
lim x->0 (1/x^2 - 1/sin(x)^2)comes backNaN. The limit is-1/3:NaNis not "unevaluated" here -- it is the claim that the limit does not exist -- sothis is a wrong answer rather than a missing one.
1/sin(x)^2 - 1/x^2is the same, andcsc(x)^2 - 1/x^2returns unevaluated where it is1/3.The unsquared forms are right, so this is next to what
#714 fixed rather than a regression of
it:
1/x - 1/sin(x)gives0.Two separate causes, both in
Limits/Transformations.cs:The difference does go over a common denominator, giving
(sin(x)^2 - x^2) / (x^2 * sin(x)^2), which is an ordinary0/0-- but l'Hopital'srule refuses the first step. Its growth guard allows a quotient to grow by eight
nodes, and this one goes
17 -> 26. That budget is what growth looks like when thedivisor is a power of the variable, which shrinks when differentiated. A divisor that
is a product of vanishing factors grows by the product rule instead, so the chain
grows before it collapses --
17 -> 26 -> 33 -> 46-- and four steps then settle itat
-1/3. With the guard widened the answer comes out in about 2 s.csc(x)^2is written(1/sin(x))^2in front of the descent, andSplitProductdoesnot look inside a power for a denominator, so that term is read as having none and
the sum is never put over a common denominator at all.
Once l'Hopital declines, the descent substitutes each half's limit and answers
+oo - +oo, which is where theNaNcomes from.