Ask Your Question
1

Wrong result from integral(log(1+1/(x**2+1)), x, -oo, oo)

asked 2018-08-27 12:12:20 +0100

ppp gravatar image

Symbolic integration gives result with wrong sign (integrand is positive):

sage: z = integrate(log(1 + 1/(x**2 + 1)), x, -oo, oo); z
2*pi - 2*sqrt(2)*pi
sage: z.n()
-2.60258056913715
sage: numerical_integral(log(1 + 1/(x**2 + 1)), -oo, oo)
(2.6025805691369728, 5.127078281515988e-10)

Sage 8.3

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2018-08-27 22:48:31 +0100

Sébastien gravatar image

By default, Sage uses Maxima which indeed gets it wrong.

sage: integrate(log(1 + 1/(x**2 + 1)), x, -oo, oo, algorithm='maxima')
2*pi - 2*sqrt(2)*pi

Nonetheless, Sympy and Giac both get it right:

sage: integrate(log(1 + 1/(x**2 + 1)), x, -oo, oo, algorithm='sympy')
-2*pi + 2*sqrt(2)*pi
sage: integrate(log(1 + 1/(x**2 + 1)), x, -oo, oo, algorithm='giac')
2*pi*(sqrt(2) - 1)
edit flag offensive delete link more
1

answered 2018-08-28 14:30:41 +0100

Emmanuel Charpentier gravatar image

To elaborate Sebastien's answer, which is quite correct :

sage: foo=log(1+(1/(x^2+1))).integrate(x) ; foo
x*log(1/(x^2 + 1) + 1) + 2*sqrt(2)*arctan(1/2*sqrt(2)*x) - 2*arctan(x)
sage: bar=log(1+(1/(x^2+1))).integrate(x, algorithm="sympy") ; bar
x*log(1/(x^2 + 1) + 1) + 2*sqrt(2)*arctan(1/2*sqrt(2)*x) - 2*arctan(x)
sage: bool(bar==foo)
True

Maxima and Sympy get the same primitive. But

sage: foo.limit(x=oo)
-pi + sqrt(2)*pi

Correct.

sage: foo.limit(x=-oo)
pi - sqrt(2)*pi

Also correct

sage: foo.limit(x=oo)-foo.limit(x=-oo)
-2*pi + 2*sqrt(2)*pi

Still correct.

sage: log(1+(1/(x^2+1))).integrate(x,-oo,oo)
2*pi - 2*sqrt(2)*pi

Wrong. Maxima's problem isn't about primitive determination, but its use...

edit flag offensive delete link more

Comments

So where should we fix this?

Sébastien gravatar imageSébastien ( 2018-08-29 16:10:55 +0100 )edit

So where should we fix this?

In Maxima, it seems...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-08-29 23:50:09 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-08-27 12:12:20 +0100

Seen: 425 times

Last updated: Aug 28 '18