Ask Your Question

# 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

Thanks in advance!

edit retag 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

( 2023-06-15 20:27:48 +0100 )edit

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

( 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.
( 2023-06-16 09:14:51 +0100 )edit

## 1 Answer

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

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
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

( 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

## Stats

Asked: 2023-06-15 13:32:01 +0100

Seen: 68 times

Last updated: Jun 16 '23