Incorrect definite integral

4 views
Skip to first unread message

Harald Schilly

unread,
Oct 16, 2009, 7:39:47 PM10/16/09
to sage-...@googlegroups.com, rsch...@gmail.com
this report came in from the "report a problem" link for 4.1.1.

-------------------------

Sage gives an incorrect value when calculating a definite integral analytically:

sage: integrate(cos(x)^2 * (1 + sin(x)^2)^-3,x,0,pi/2)
21/64*pi*sqrt(2)
sage: _.n()
1.45782096408321

The correct answer is 7/64*pi*sqrt(2) = 0.48594. Sage gets this when
doing the integral numerically, or when going not quite to pi/2:

sage: numerical_integral(cos(x)^2 * (1 + sin(x)^2)^-3,0,pi/2)
(0.48594032136107129, 5.3950213336880916e-15)
sage: integrate(cos(x)^2 * (1 + sin(x)^2)^-3,x,0,pi/2-0.0001).n()
0.485940321361

The integrand is perfectly well-behaved at pi/2. The problem may be
related to the fact that the indefinite integral contains a term like
arctan(sqrt(2)*tan(x)), which is ill-defined at x=pi/2.

-------------------------

Harald

kcrisman

unread,
Oct 16, 2009, 9:04:06 PM10/16/09
to sage-devel


On Oct 16, 7:39 pm, Harald Schilly <harald.schi...@gmail.com> wrote:
> this report came in from the "report a problem" link for 4.1.1.
>
> -------------------------
>
> Sage gives an incorrect value when calculating a definite integral analytically:
>
> sage: integrate(cos(x)^2 * (1 + sin(x)^2)^-3,x,0,pi/2)
> 21/64*pi*sqrt(2)
> sage: _.n()
> 1.45782096408321
>

This is also present in the Maxima current CVS version. Someone may
want to report this to the Maxima bug tracker - I cannot right now.

- kcrisman

ma...@mendelu.cz

unread,
Oct 17, 2009, 2:18:05 AM10/17/09
to sage-devel
>
> This is also present in the Maxima current CVS version.  Someone may
> want to report this to the Maxima bug tracker - I cannot right now.
>

Old Maxima 5.18 has the same problem.

I reported this as ID 2880886, since the problem seems to be different
one than https://sourceforge.net/tracker/?func=detail&aid=2880797&group_id=4933&atid=104933

Robert

Harald Schilly

unread,
Oct 17, 2009, 6:42:31 AM10/17/09
to sage-devel
On Oct 17, 8:18 am, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote:
> I reported this as ID 2880886, ...

Thanks. Out of curiosity, i tried this integral with sympy. This ends
up to take minutes or longer. Should we report this as a bug, too?

integrate(cos(x)^2 * (1 + sin(x)^2)^-3,x,0,pi/2, algorithm='sympy')

H

ma...@mendelu.cz

unread,
Oct 17, 2009, 9:14:26 AM10/17/09
to sage-devel
and woflram alpha does not evaluate the integral (returns numerical
approximation)
R.

> H

Martin Rubey

unread,
Oct 17, 2009, 9:23:10 AM10/17/09
to sage-...@googlegroups.com, fricas-devel
Harald Schilly <harald....@gmail.com> writes:

For what it's worth, fricas seems to give a correct answer, although not
as simple as it could be (please excuse the ascii art, view with fixed
width font...):

(1) -> r := integrate(cos(x)^2 * (1 + sin(x)^2)^-3,x=0..%pi/2, "noPole")

+-+
\|2 4
7atan(----) + 7atan(----)
4 +-+
\|2
(1) -------------------------
+-+
16\|2
Type: Union(f1: OrderedCompletion(Expression(Integer)),...)
(2) -> numeric %

(2) 0.4859403213 6107130827
Type: Float

What I find interesting is that fricas does not even detect equality
with the correctly simplified answer:

(3) -> normalize(r - 7/64*%pi*sqrt(2))

+-+
\|2 4
14atan(----) + 14atan(----) - 7%pi
4 +-+
\|2
(3) ----------------------------------
+-+
32\|2
Type: Expression(Integer)
(4) -> numeric %

(4) 0.0
Type: Float

Martin

Reply all
Reply to author
Forward
0 new messages