Ask Your Question
1

integration in sagemath 8.1

asked 2020-10-01 23:38:23 +0200

draz gravatar image

updated 2020-10-02 13:40:13 +0200

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-10-02 11:00:55 +0200

tmonteil gravatar image

updated 2020-10-02 11:02:29 +0200

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)
edit flag offensive delete link more

Comments

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

draz gravatar imagedraz ( 2020-10-02 12:49:22 +0200 )edit
1

answered 2020-10-02 14:07:55 +0200

slelievre gravatar image

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.

edit flag offensive delete link more

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: 2020-10-01 23:30:40 +0200

Seen: 432 times

Last updated: Oct 02 '20