integration in sagemath 8.1

I executed the following,

def integral_R(f,a,b):
from sage.symbolic.integration.integral import definite_integral
return (definite_integral(f,x,a,b)).simplify_full()
alpha = 1/sqrt(3)
H = 2*arcsin(x/(sqrt(1-x^2)))
integral_R(H,0,alpha).n()


and got

1.16869906991626


The same integral in Wolfram Alpha provides

0.38330


By inspection I know that Wolfram is right. What's wrong with sage math in the specific example?

edit retag close merge delete

Sort by » oldest newest most voted

It works for me, on 9.2.beta14 i get:

sage: def integral_R(f,a,b):
....:     from sage.symbolic.integration.integral import definite_integral
....:     return (definite_integral(f,x,a,b)).simplify_full()
....: alpha = 1/sqrt(3)
....: H = 2*arcsin(x/(sqrt(1-x^2)))
....: integral_R(H,0,alpha).n()
0.383300906518810


Which version of Sage are you using ?

By the way, if you are interested in numerical integral, a more robust way is to use numerical_integral

sage: numerical_integral(H,0,alpha)
(0.38330090651880994, 4.2554949177687755e-15)

more

wow! I use 8.1 I need to update...Although numerical integral works

( 2020-10-02 05:49:22 -0600 )edit

To get certified precision, use Arb via ComplexBallField.

Here is a way to use it to compute the integral in the question.

Define a complex ball field with, for instance, 100 bits or 200 bits of precision (which amounts to about 30 or 60 decimal digits).

Then compute the integral.

The answer is a ball given by its center and a radius around it.

sage: C = ComplexBallField(100)
sage: C.integral(lambda x, _: 2*arcsin(x/(sqrt(1-x^2))), 0, ~AA(3).sqrt())
[0.3833009065188100522199318983 +/- 6.39e-29]

sage: C = ComplexBallField(200)
sage: C.integral(lambda x, _: 2*arcsin(x/(sqrt(1-x^2))), 0, ~AA(3).sqrt())
[0.3833009065188100522199318982744940521091715574838526509558 +/- 5.35e-59]


By contrast, numerical_integral gives an error estimate which, if I understand correctly, is not certified.

more