Ask Your Question

# Global Dependency in Polyhedron Volume

Hi all,

I am new to sage and want to use it in one of my python scripts to calculate the volume of higher dimensional polyhedrons. When executing my script I get a "ZeroDivisionError" for some of the polyhedrons. However when run in an individual script they work perfectly fine as long as there is no other calculation beforehand.

Here is an example, the file is called DebugSageVolume.py and I execute it with "sage -python DebugSageVolume.py" under Ubuntu 18.04, SageMath version 8.1

#!/usr/lib/python2.7/dist-packages/sage -python
from sage.all import *

# this works fine
matrix1 = matrix(RR, [[0, 1, 0, 0, 0], [1, -1, 0, 0, 0],
[0, 0, 1, 0, 0], [1, 0, -1, 0, 0],
[0, 0, 0, 1, 0], [1, 0, 0, -1, 0],
[0, 0, 0, 0, 1], [1, 0, 0, 0, -1],
[0.5, -0.5, -0.5, -0.5, -0.5], [-0.5, 0.5, 0.5, 0.5, 0.5]])
poly1 = Polyhedron(ieqs=matrix1)
volume1 = poly1.volume(measure="induced")
print(volume1)

#this results in an error when executed after the above. But when commenting the above this works fine
matrix2 = matrix(RR, [[0, 1, 0, 0, 0], [1, -1, 0, 0, 0],
[0, 0, 1, 0, 0], [1, 0, -1, 0, 0],
[0, 0, 0, 1, 0], [1, 0, 0, -1, 0],
[0, 0, 0, 0, 1], [1, 0, 0, 0, -1],
[0.75, -0.5, -0.5, -0.5, -0.5], [-0.75, 0.5, 0.5, 0.5, 0.5]])
poly2 = Polyhedron(ieqs=matrix2)
volume2 = poly2.volume(measure="induced")
print(volume2)


Any help would be greatly appreciated, thank you. Michael

edit retag close merge delete

## 1 answer

Sort by » oldest newest most voted

There is a known issue with volume computations when coefficients are in RR. Try if possible to use coefficients in QQ.

See https://trac.sagemath.org/ticket/18214 for the known bug.

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2018-12-17 12:10:30 -0600

Seen: 114 times

Last updated: Dec 17 '18