Ask Your Question
0

integration with 'maxima' gives different result than 'sympy' and 'mathematica_free'

asked 2024-08-30 15:18:55 +0100

Max Alekseyev gravatar image

We have

sage: q = -1/17*sqrt(-52/17*I + 47/17)/(2*x - sqrt(4*I + 1) - 1)
....: print( integrate( q, x, 0, 1, algorithm='maxima' ).n() )
....: print( integrate( q, x, 0, 1, algorithm='sympy' ).n() )
....: print( integrate( q, x, 0, 1, algorithm='mathematica_free' ).n() )
0.0400005859357106 - 0.0177639491598775*I
0.0236417600209372 - 0.0546005003074790*I
0.0236418000000000 - 0.0546005000000000*I

Is this expected?

edit retag flag offensive close merge delete

Comments

also

sage: integrate( q, x, 0, 1, algorithm='fricas' ).n()
0.0236417600209373 - 0.0546005003074790*I
FrédéricC gravatar imageFrédéricC ( 2024-08-30 16:56:36 +0100 )edit
1

symbolically

sage: integrate( q, x, algorithm='fricas')
-1/34*sqrt(-52/17*I + 47/17)*log(x - 1/2*sqrt(4*I + 1) - 1/2)
sage: integrate( q, x, algorithm='sympy')
-1/578*sqrt(-52*I + 47)*sqrt(17)*log(578*x - 289*sqrt(4*I + 1) - 289)
sage: integrate( q, x, algorithm='maxima')
-1/34*sqrt(-52/17*I + 47/17)*log(2*x - sqrt(4*I + 1) - 1)
sage: integrate( q, x, algorithm='mathematica_free')
-1/34*sqrt(-52/17*I + 47/17)*log(-2*x + sqrt(4*I + 1) + 1)
sage: integrate( q, x, algorithm='giac')
-1/34*sqrt(-52/17*I + 47/17)*log(-1/2*sqrt(2*sqrt(17) + 2)*(4*I/(sqrt(17) + 1) + 1) + 2*x - 1)
FrédéricC gravatar imageFrédéricC ( 2024-08-30 17:02:10 +0100 )edit

Indefinite integral looks fine - we have

sage: r = integrate( q, x, algorithm='maxima')
sage: print( (r.subs({x:1}) - r.subs({x:0})).n() )
0.0236417600209373 - 0.0546005003074791*I

So it looks like a bug in definite integral evaluation.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-08-30 19:42:37 +0100 )edit

This expression has some seemingly questionable symbolic indefinite integrations :

 Ints={v:q.integrate(x, algorithm=v) for v in ("maxima", "giac", "fricas", "sympy", "mathematica_free")}
sage: {v:(Ints[v].diff(x)-q).is_zero() for v in Ints.keys()}
{'maxima': True,
 'giac': False,
 'fricas': True,
 'sympy': False,
 'mathematica_free': True}
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-08-31 14:34:42 +0100 )edit

However :

sage: (q.integrate(x, algorithm="giac").diff(x)-q)._mathematica_().FullSimplify()
0
sage: (q.integrate(x, algorithm="sympy").diff(x)-q)._sympy_().simplify()
0
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-08-31 14:49:33 +0100 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2024-08-30 21:10:05 +0100

Max Alekseyev gravatar image

Apparently the reason is that in the definite integrals maxima evaluates each log(e) as log(abs(e)). I've filed a bugreport at https://github.com/sagemath/sage/issu...

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: 2024-08-30 15:18:55 +0100

Seen: 234 times

Last updated: Aug 30