Skip to content

lim x->0 (1/x^2 - 1/sin(x)^2) answers NaN, which claims the limit does not exist #727

Description

@Rafael-SOWNet

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:

  1. 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.

  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions