For computations over real embedded number fields with QNormaliz, first load the PyQNormaliz_cpp module
import PyQNormaliz_cpp
Now we enter a dodecahedron
dodec = PyQNormaliz_cpp.NmzCone( number_field = "min_poly (a^2 - 5) embedding [2.236067977499789 +/- 8.06e-16]",
cone = [
[ "-a + 3", "-a + 3", "-a + 3", 1 ],
[ "2*a - 4", 0, "a - 1", 1 ],
[ "-a + 3", "a - 3", "-a + 3", 1 ],
[ "a - 1", "2*a - 4", 0, 1 ],
[ "a - 1", "-2*a + 4", 0, 1 ],
[ 0, "a - 1", "2*a - 4", 1 ],
[ 0, "-a + 1", "2*a - 4", 1 ],
[ "-2*a + 4", 0, "a - 1", 1 ],
[ "a - 3", "-a + 3", "-a + 3", 1 ],
[ "a - 3", "a - 3", "-a + 3", 1 ],
[ "-a + 3", "-a + 3", "a - 3", 1 ],
[ 0, "a - 1", "-2*a + 4", 1 ],
[ "-a + 3", "a - 3", "a - 3", 1 ],
[ 0, "-a + 1", "-2*a + 4", 1 ],
[ "2*a - 4", 0, "-a + 1", 1 ],
[ "-a + 1", "2*a - 4", 0, 1 ],
[ "-a + 1", "-2*a + 4", 0, 1 ],
[ "a - 3", "-a + 3", "a - 3", 1 ],
[ "a - 3", "a - 3", "a - 3", 1 ],
[ "-2*a + 4", 0, "-a + 1", 1 ] ] )
The input for number field elements can be given as strings, or as a list of pairs of integers. The polynomial
a^2+1/2a-3/5
would be the list
[[-3,5],[1,2],[1,1]]
Now we can compute the support hyperplanes of the dodecahedron
PyQNormaliz_cpp.NmzResult(dodec,"SupportHyperplanes")
[[[[-1, 4], [-1, 4]], [[0, 1]], [[-1, 2]], [[1, 1]]], [[[-1, 4], [-1, 4]], [[0, 1]], [[1, 2]], [[1, 1]]], [[[-1, 2]], [[-1, 4], [-1, 4]], [[0, 1]], [[1, 1]]], [[[-1, 2]], [[1, 4], [1, 4]], [[0, 1]], [[1, 1]]], [[[0, 1]], [[-1, 2]], [[-1, 4], [-1, 4]], [[1, 1]]], [[[0, 1]], [[-1, 2]], [[1, 4], [1, 4]], [[1, 1]]], [[[0, 1]], [[1, 2]], [[-1, 4], [-1, 4]], [[1, 1]]], [[[0, 1]], [[1, 2]], [[1, 4], [1, 4]], [[1, 1]]], [[[1, 2]], [[-1, 4], [-1, 4]], [[0, 1]], [[1, 1]]], [[[1, 2]], [[1, 4], [1, 4]], [[0, 1]], [[1, 1]]], [[[1, 4], [1, 4]], [[0, 1]], [[-1, 2]], [[1, 1]]], [[[1, 4], [1, 4]], [[0, 1]], [[1, 2]], [[1, 1]]]]
The output might be a bit hard to read. Therefore one can pass functions to the result function.
def rational_handler(list):
return list[0]/list[1]
PyQNormaliz_cpp.NmzResult(dodec,"SupportHyperplanes",RationalHandler=rational_handler)
[[[-0.25, -0.25], [0.0], [-0.5], [1.0]], [[-0.25, -0.25], [0.0], [0.5], [1.0]], [[-0.5], [-0.25, -0.25], [0.0], [1.0]], [[-0.5], [0.25, 0.25], [0.0], [1.0]], [[0.0], [-0.5], [-0.25, -0.25], [1.0]], [[0.0], [-0.5], [0.25, 0.25], [1.0]], [[0.0], [0.5], [-0.25, -0.25], [1.0]], [[0.0], [0.5], [0.25, 0.25], [1.0]], [[0.5], [-0.25, -0.25], [0.0], [1.0]], [[0.5], [0.25, 0.25], [0.0], [1.0]], [[0.25, 0.25], [0.0], [-0.5], [1.0]], [[0.25, 0.25], [0.0], [0.5], [1.0]]]
The resulting number field elements are displayed as lists. One might want to display them as polynomial strings
def polynomial_string(list):
string = str(list[0][0]) + "/" + str(list[0][1])
for i in range(1,len(list)):
string += " + " + str(list[i][0]) + "/" + str(list[i][1]) + "*a^" + str(i)
return string
PyQNormaliz_cpp.NmzResult(dodec,"SupportHyperplanes",NumberfieldElementHandler=polynomial_string)
[['-1/4 + -1/4*a^1', '0/1', '-1/2', '1/1'], ['-1/4 + -1/4*a^1', '0/1', '1/2', '1/1'], ['-1/2', '-1/4 + -1/4*a^1', '0/1', '1/1'], ['-1/2', '1/4 + 1/4*a^1', '0/1', '1/1'], ['0/1', '-1/2', '-1/4 + -1/4*a^1', '1/1'], ['0/1', '-1/2', '1/4 + 1/4*a^1', '1/1'], ['0/1', '1/2', '-1/4 + -1/4*a^1', '1/1'], ['0/1', '1/2', '1/4 + 1/4*a^1', '1/1'], ['1/2', '-1/4 + -1/4*a^1', '0/1', '1/1'], ['1/2', '1/4 + 1/4*a^1', '0/1', '1/1'], ['1/4 + 1/4*a^1', '0/1', '-1/2', '1/1'], ['1/4 + 1/4*a^1', '0/1', '1/2', '1/1']]
Furthermore, RationalHandler
and MatrixHandler
can also be used.