# integrate on polytopes with latte : result is always equal 0

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

edit retag close merge delete

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


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.

Sort by » oldest newest most voted

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

  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
more

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