Opened 8 years ago

Closed 7 years ago

#11591 closed defect (fixed)

Incorrect results for integrals involving exponential functions

Reported by: mjo Owned by: burcin
Priority: major Milestone: sage-5.0
Component: calculus Keywords:
Cc: mjo Merged in: sage-5.0.beta3
Authors: Michael Orlitzky Reviewers: Aly Deines
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: Commit:
Dependencies: #12094 Stopgaps:

Description

Posted to sage-support by Robin Hankin,

http://groups.google.com/group/sage-support/browse_thread/thread/1209ff5cb106d99c

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
sage: quad(lambda x:(x^2)*exp(x)/(1+exp(x))^2,[-inf,+inf])
3.28986813369645

Attachments (1)

sage-trac_11591.patch (917 bytes) - added by mjo 7 years ago.
Doctest for the correct result.

Download all attachments as: .zip

Change History (13)

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
;;; Loading #P"/Users/wstein/sage/install/current/local/lib/ecl/sb-bsd-sockets.fas"
;;; Loading #P"/Users/wstein/sage/install/current/local/lib/ecl/sockets.fas"
;;; Loading #P"/Users/wstein/sage/install/current/local/lib/ecl/defsystem.fas"
;;; Loading #P"/Users/wstein/sage/install/current/local/lib/ecl/cmp.fas"
Maxima 5.23.2 http://maxima.sourceforge.net
using Lisp ECL 11.1.1
Distributed under the GNU Public License. See the file COPYING.
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: 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

Replying to 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.

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
  • Cc mjo added
  • 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.