Opened 8 years ago

Closed 7 years ago

# Incorrect results for integrals involving exponential functions

Reported by: Owned by: mjo burcin major sage-5.0 calculus mjo sage-5.0.beta3 Michael Orlitzky Aly Deines Fixed upstream, in a later stable release. #12094

### Description

Posted to sage-support by Robin Hankin,

Actual result:

```sage: f = (x^2)*exp(x) / (1+exp(x))^2
sage: integrate(f, (x, -infinity, infinity))
0
```

Expected result:

```sage: from mpmath import *
sage: mp.pretty=True
3.28986813369645
```

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

A related Maxima issue I found after a few seconds of looking into this:

```sage: y=(x^2)*exp(x)/(1+exp(x))^2
sage: N(integrate(y,(x,-1000,1000)))
;;;
;;; Stack overflow.
;;; Jumping to the outermost toplevel prompt
;;;

/Users/wstein/sage/install/current/local/bin/sage-sage: line 301: 88871 Illegal instruction     sage-ipython "\$@" -i
You have new mail in /var/mail/wstein
deep:sage wstein\$
```

### comment:2 Changed 8 years ago by was

• Milestone set to sage-4.7.1

### comment:3 Changed 8 years ago by was

• Report Upstream changed from N/A to Not yet reported upstream; Will do shortly.

### comment:4 Changed 8 years ago by was

Here's how to replicate this directly in Maxima:

```deep:sage wstein\$ sage -maxima
Maxima 5.23.2 http://maxima.sourceforge.net
using Lisp ECL 11.1.1
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) integrate(x^2*%e^x/(%e^x+1)^2,x,minf,inf);
(%o1)                                  0
```

### comment:5 Changed 8 years ago by mjo

I just realized that I left in an extra denominator in the expected output. However, zero is still obviously incorrect.

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

• Report Upstream changed from Not yet reported upstream; Will do shortly. to Fixed upstream, in a later stable release.

This is fixed in the newest Maxima (5.24.0):

Old:

```(%i1) f:(x^2)*%e^x / (1+%e^x)^2;
2   x
x  %e
(%o1)                             ----------
x     2
(%e  + 1)
(%i2) integrate(f,x,minf,inf);
(%o2)                                  0
```

New:

```(%i6) integrate(f,x,minf,inf);
2
%pi
(%o6)                                ----
3
(%i7)
```

### comment:7 Changed 8 years ago by mjo

• Dependencies set to #12094

### comment:8 follow-up: ↓ 9 Changed 7 years ago by kcrisman

Michael, do you want to make a patch for this as well? It would be nice to have an easy queue to apply for all of these update patches. Good work on all of this.

### comment:9 in reply to: ↑ 8 Changed 7 years ago by mjo

Michael, do you want to make a patch for this as well? It would be nice to have an easy queue to apply for all of these update patches. Good work on all of this.

Thanks, yes, I should be able to create separate patches for everything in the morning.

### Changed 7 years ago by mjo

Doctest for the correct result.

### comment:10 Changed 7 years ago by mjo

• Authors set to Michael Orlitzky
• Status changed from new to needs_review

The original bug is fixed in maxima-5.24, but the stack overflow that William reported is not. I've opened #12377 separately to deal with that.

This patch applies on top of #11483, not because we need abs_integrate, but because they both add doctests in the same spot.

### comment:11 Changed 7 years ago by aly.deines

• Reviewers set to Aly Deines
• Status changed from needs_review to positive_review

### comment:12 Changed 7 years ago by jdemeyer

• Merged in set to sage-5.0.beta3
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.