Opened 7 years ago

Closed 5 months ago

#15496 closed defect (fixed)

Incorrect result for divergent integral

Reported by: ppurka Owned by:
Priority: major Milestone: sage-9.2
Component: calculus Keywords:
Cc: kcrisman, jakobkroeker, slelievre, vklein, rws, tscrim Merged in:
Authors: Frédéric Chapoton Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: u/chapoton/15496 (Commits) Commit: 0661926ece85d45ed1018fa9d508dfcf7bb90add
Dependencies: Stopgaps:

Description (last modified by chapoton)

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)

Change History (16)

comment:1 Changed 7 years ago by kcrisman

  • Cc kcrisman added

This is not a symbolic Maxima problem, as the integral is just returned, so it's something about how we evaluate n on these unevaluated integrals.

comment:2 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 4 years ago by jakobkroeker

  • Cc jakobkroeker added

comment:6 Changed 5 months ago by chapoton

  • Description modified (diff)

comment:7 Changed 5 months ago by chapoton

  • Description modified (diff)

comment:8 Changed 5 months ago by chapoton

  • Description modified (diff)

comment:9 Changed 5 months ago by chapoton

  • Description modified (diff)

comment:10 Changed 5 months ago by chapoton

  • Authors set to Frédéric Chapoton
  • Branch set to u/chapoton/15496
  • Commit set to 0661926ece85d45ed1018fa9d508dfcf7bb90add
  • Status changed from new to needs_review

here is a proposal : check that the limit is zero before doing the numerical integral


New commits:

0661926add some safety check for numerical integrals up to infinity

comment:11 Changed 5 months ago by chapoton

  • Milestone changed from sage-6.4 to sage-9.2
  • Stopgaps todo deleted

comment:12 Changed 5 months ago by chapoton

  • Cc slelievre added

green bot, please review

comment:13 Changed 5 months ago by chapoton

  • Cc vklein rws added

comment:14 Changed 5 months ago by chapoton

  • Cc tscrim added

comment:15 Changed 5 months ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM.

comment:16 Changed 5 months ago by mkoeppe

  • Resolution set to fixed
  • Status changed from positive_review to closed

These have been merged into 9.2.beta4

Note: See TracTickets for help on using tickets.