Opened 8 years ago

Closed 13 months ago

# Incorrect result for divergent integral

Reported by: Owned by: ppurka major sage-9.2 calculus kcrisman, jakobkroeker, slelievre, vklein, rws, tscrim Frédéric Chapoton Travis Scrimshaw N/A u/chapoton/15496 0661926ece85d45ed1018fa9d508dfcf7bb90add

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)
```

### comment:1 Changed 8 years ago by kcrisman

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 8 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 7 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

### comment:6 Changed 14 months ago by chapoton

• Description modified (diff)

### comment:7 Changed 14 months ago by chapoton

• Description modified (diff)

### comment:8 Changed 14 months ago by chapoton

• Description modified (diff)

### comment:9 Changed 14 months ago by chapoton

• Description modified (diff)

### comment:10 Changed 14 months ago by chapoton

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

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

New commits:

 ​0661926 `add some safety check for numerical integrals up to infinity`

### comment:11 Changed 14 months ago by chapoton

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

### comment:15 Changed 13 months ago by tscrim

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

LGTM.

### comment:16 Changed 13 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.