Skip to content

Incorrect result for divergent integral #15496

Closed
@ppurka

Description

@ppurka

From google spreadsheet which no one reads X-(

sage: integrate(x^2/exp(-1/(x^2+1))/(x^2+1),(x,-infinity,infinity)).n()
-3.3357920860949157

Wolfram alpha gives the correct answer.

The problem comes from here:

sage: D=1.00000000000000*x^2*e^(1/(x^2 + 1.00000000000000))/(x^2 + 1.00000000000
....: 000)
sage: numerical_integral(D,-oo,+oo)
(-3.3357920860949157, 4.262178610048295e-09)

and in one specific algorithm

sage: numerical_integral(D,-oo,+oo, algorithm="qag")
(-3.3357920860949157, 4.262178610048295e-09)
sage: numerical_integral(D,-oo,+oo, algorithm="qng")
(nan, nan)
sage: numerical_integral(D,-oo,+oo, algorithm="qags")
(nan, nan)

and this case is handled by
gsl_integration_qagi

And the problem can be cut into two parts:

sage: numerical_integral(D,0,+oo)
(-1.6678960430474579, 2.1310893050241475e-09)
sage: numerical_integral(D,-oo,0)
(-1.6678960430474579, 2.1310893050241475e-09)

CC: @kcrisman @sagetrac-jakobkroeker @slel @vinklein @rwst @tscrim

Component: calculus

Author: Frédéric Chapoton

Branch/Commit: u/chapoton/15496 @ 0661926

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/15496

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions