Ask Your Question
1

integrate on polytopes with latte : result is always equal 0

asked 2023-06-15 13:54:27 +0100

Pierre-L gravatar image

I would like to compute integral of polynomial functions on polytopes. I'm using Sagemath in a Jupyter notebook and I've also installed the latte-integrale package with conda. In the notebook, I manage to import "latte", define the polytope and the function, but the result of the integral is always to 0. My script is :

from sage.features.latte import Latte 
Latte().is_present()

FeatureTestResult('latte_int', True)

P=polytopes.cube()
x,y,z = polygens(QQ,names='x,y,z')
f=x^2*y^2*z^2
P.integrate(f)

0

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Works for me in ubuntu with sage 10.1.beta3. Tell us your sage version, os, machine, etc.

sage: P.integrate(f,algorithm='latte')
8/27
FrédéricC gravatar imageFrédéricC ( 2023-06-15 20:27:48 +0100 )edit

WorksForMe and at https://sagecell.sagemath.org/ as well.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-06-15 22:36:44 +0100 )edit

I can replicate the observed bug in Ubuntu 22.04.2 LTS (jammy) with

  • conda-installed SageMath 10.0
  • conda-installed LattE integrale 1.7.5.
slelievre gravatar imageslelievre ( 2023-06-16 09:14:51 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2023-06-16 09:34:06 +0100

slelievre gravatar image

updated 2023-06-16 11:08:48 +0100

I can replicate the observed bug in Ubuntu 22.04.2 LTS (jammy) with

  • conda-installed SageMath 10.0
  • conda-installed LattE integrale 1.7.5.

But specifying algorithm=latte as in @FrédéricC's comment gives the correct integral.

sage: from sage.features.latte import Latte
sage: Latte().is_present()
FeatureTestResult('latte_int', True)

sage: P = polytopes.cube()
sage: x, y, z = polygens(QQ, names='x, y, z')
sage: f = x^2 * y^2 * z^2

sage: P.integrate(f)
0
sage: P.integrate(f, algorithm='latte')
8/27

The first example in the documentation of P.integrate, accessed with P.integrate?, or found at

reads:

  sage: P = polytopes.cube()
  sage: x, y, z = polygens(QQ, 'x, y, z')
  sage: P.integrate(x^2*y^2*z^2)    # optional - latte_int
  8/27

That example should probably be fixed to use algorithm=latte.

Without algorithm=latte, I think Sage checks whether LattE is available, and if so uses it. But apparently that detection fails in the conda setup.

In any case, at some point a "not implemented" error should be raised rather than returning a wrong result.

I'm curious

  • why the bug is observed with conda-installed Sage and LattE, but not in other setups
  • what code path leads to returning zero as an answer
edit flag offensive delete link more

Comments

Yes, indeed adding algorithm='latte' solves the problem! Thanks a lot @slelievre My current versions are sage 9.5, latte 1.7.5 and Ubuntu 22.04

Pierre-L gravatar imagePierre-L ( 2023-06-16 13:14:48 +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: 2023-06-15 13:32:01 +0100

Seen: 153 times

Last updated: Jun 16 '23