def small_rhombicuboctahedron(self, exact=True, base_ring=None): """ Return the (small) rhombicuboctahedron. The rhombicuboctahedron is an Archimedean solid with 24 vertices and 26 faces. See the :wikipedia:`Rhombicuboctahedron` for more information. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. - ``base_ring`` -- the ring in which the coordinates will belong to. If it is not provided and ``exact=True`` it will be a the number field `\QQ[\phi]` where `\phi` is the golden ratio and if ``exact=False`` it will be the real double field. EXAMPLES:: sage: sr = polytopes.small_rhombicuboctahedron() sage: sr.f_vector() (1, 24, 48, 26, 1) sage: sr.volume() 80/3*sqrt2 + 32 The faces are `8` equilateral triangles and `18` squares:: sage: sum(1 for f in sr.faces(2) if len(f.vertices()) == 3) 8 sage: sum(1 for f in sr.faces(2) if len(f.vertices()) == 4) 18 Its non exact version:: sage: sr = polytopes.small_rhombicuboctahedron(False) sage: sr A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 24 vertices sage: sr.f_vector() (1, 24, 48, 26, 1) """ if base_ring is None and exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(2, 'sqrt2') sqrt2 = K.gen() base_ring = K else: if base_ring is None: base_ring = RDF sqrt2 = base_ring(2).sqrt() one = base_ring.one() a = sqrt2 + one verts = [] verts.extend([s1*one, s2*one, s3*a] for s1,s2,s3 in itertools.product([1,-1], repeat=3)) verts.extend([s1*one, s3*a, s2*one] for s1,s2,s3 in itertools.product([1,-1], repeat=3)) verts.extend([s1*a, s2*one, s3*one] for s1,s2,s3 in itertools.product([1,-1], repeat=3)) return Polyhedron(vertices=verts)
def great_rhombicuboctahedron(self, exact=True, base_ring=None): """ Return the great rhombicuboctahedron. The great rohombicuboctahedron (or truncated cuboctahedron) is an Archimedean solid with 48 vertices and 26 faces. For more information see the :wikipedia:`Truncated_cuboctahedron`. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. - ``base_ring`` -- the ring in which the coordinates will belong to. If it is not provided and ``exact=True`` it will be a the number field `\QQ[\phi]` where `\phi` is the golden ratio and if ``exact=False`` it will be the real double field. EXAMPLES:: sage: gr = polytopes.great_rhombicuboctahedron() # long time ~ 3sec sage: gr.f_vector() # long time (1, 48, 72, 26, 1) A faster implementation is obtained by setting ``exact=False``:: sage: gr = polytopes.great_rhombicuboctahedron(exact=False) sage: gr.f_vector() (1, 48, 72, 26, 1) Its faces are 4 squares, 8 regular hexagons and 6 regular octagons:: sage: sum(1 for f in gr.faces(2) if len(f.vertices()) == 4) 12 sage: sum(1 for f in gr.faces(2) if len(f.vertices()) == 6) 8 sage: sum(1 for f in gr.faces(2) if len(f.vertices()) == 8) 6 """ if base_ring is None and exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(2, 'sqrt2') sqrt2 = K.gen() base_ring = K else: if base_ring is None: base_ring = RDF sqrt2 = base_ring(2).sqrt() one = base_ring.one() v1 = sqrt2 + 1 v2 = 2*sqrt2 + 1 verts = [ [s1*z1, s2*z2, s3*z3] for z1,z2,z3 in itertools.permutations([one,v1,v2]) for s1,s2,s3 in itertools.product([1,-1], repeat=3)] return Polyhedron(vertices=verts, base_ring=base_ring)
def great_rhombicuboctahedron(self, exact=True, base_ring=None): """ Return the great rhombicuboctahedron. The great rohombicuboctahedron (or truncated cuboctahedron) is an Archimedean solid with 48 vertices and 26 faces. For more information see the :wikipedia:`Truncated_cuboctahedron`. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. - ``base_ring`` -- the ring in which the coordinates will belong to. If it is not provided and ``exact=True`` it will be a the number field `\QQ[\phi]` where `\phi` is the golden ratio and if ``exact=False`` it will be the real double field. EXAMPLES:: sage: gr = polytopes.great_rhombicuboctahedron() # long time ~ 3sec sage: gr.f_vector() # long time (1, 48, 72, 26, 1) A faster implementation is obtained by setting ``exact=False``:: sage: gr = polytopes.great_rhombicuboctahedron(exact=False) sage: gr.f_vector() (1, 48, 72, 26, 1) Its faces are 4 squares, 8 regular hexagons and 6 regular octagons:: sage: sum(1 for f in gr.faces(2) if len(f.vertices()) == 4) 12 sage: sum(1 for f in gr.faces(2) if len(f.vertices()) == 6) 8 sage: sum(1 for f in gr.faces(2) if len(f.vertices()) == 8) 6 """ if base_ring is None and exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(2, 'sqrt2') sqrt2 = K.gen() base_ring = K else: if base_ring is None: base_ring = RDF sqrt2 = base_ring(2).sqrt() one = base_ring.one() v1 = sqrt2 + 1 v2 = 2 * sqrt2 + 1 verts = [[s1 * z1, s2 * z2, s3 * z3] for z1, z2, z3 in itertools.permutations([one, v1, v2]) for s1, s2, s3 in itertools.product([1, -1], repeat=3)] return Polyhedron(vertices=verts, base_ring=base_ring)
def six_hundred_cell(self, exact=False): """ Return the standard 600-cell polytope. The 600-cell is a 4-dimensional regular polytope. In many ways this is an analogue of the icosahedron. .. WARNING:: The coordinates are not exact by default. The computation with exact coordinates takes a huge amount of time. INPUT: - ``exact`` - (boolean, default ``False``) if ``True`` use exact coordinates instead of floating point approximations EXAMPLES:: sage: p600 = polytopes.six_hundred_cell() sage: p600 A 4-dimensional polyhedron in RDF^4 defined as the convex hull of 120 vertices sage: p600.f_vector() (1, 120, 720, 1200, 600, 1) Computation with exact coordinates is currently too long to be useful:: sage: p600 = polytopes.six_hundred_cell(exact=True) # not tested - very long time sage: len(list(p600.bounded_edges())) # not tested - very long time 120 """ if exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(5, 'sqrt5') sqrt5 = K.gen() g = (1 + sqrt5) / 2 base_ring = K else: g = (1 + RDF(5).sqrt()) / 2 base_ring = RDF q12 = base_ring(1) / base_ring(2) z = base_ring.zero() verts = [[s1 * q12, s2 * q12, s3 * q12, s4 * q12] for s1, s2, s3, s4 in itertools.product([1, -1], repeat=4)] V = (base_ring)**4 verts.extend(V.basis()) verts.extend(-v for v in V.basis()) pts = [[s1 * q12, s2 * g / 2, s3 / (2 * g), z] for (s1, s2, s3) in itertools.product([1, -1], repeat=3)] for p in AlternatingGroup(4): verts.extend(p(x) for x in pts) return Polyhedron(vertices=verts, base_ring=base_ring)
def six_hundred_cell(self, exact=False): """ Return the standard 600-cell polytope. The 600-cell is a 4-dimensional regular polytope. In many ways this is an analogue of the icosahedron. .. WARNING:: The coordinates are not exact by default. The computation with exact coordinates takes a huge amount of time. INPUT: - ``exact`` - (boolean, default ``False``) if ``True`` use exact coordinates instead of floating point approximations EXAMPLES:: sage: p600 = polytopes.six_hundred_cell() sage: p600 A 4-dimensional polyhedron in RDF^4 defined as the convex hull of 120 vertices sage: p600.f_vector() (1, 120, 720, 1200, 600, 1) Computation with exact coordinates is currently too long to be useful:: sage: p600 = polytopes.six_hundred_cell(exact=True) # not tested - very long time sage: len(list(p600.bounded_edges())) # not tested - very long time 120 """ if exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(5, 'sqrt5') sqrt5 = K.gen() g = (1 + sqrt5) / 2 base_ring = K else: g = (1 + RDF(5).sqrt()) / 2 base_ring = RDF q12 = base_ring(1) / base_ring(2) z = base_ring.zero() verts = [[s1*q12, s2*q12, s3*q12, s4*q12] for s1,s2,s3,s4 in itertools.product([1,-1], repeat=4)] V = (base_ring)**4 verts.extend(V.basis()) verts.extend(-v for v in V.basis()) pts = [[s1 * q12, s2*g/2, s3/(2*g), z] for (s1,s2,s3) in itertools.product([1,-1], repeat=3)] for p in AlternatingGroup(4): verts.extend(p(x) for x in pts) return Polyhedron(vertices=verts, base_ring=base_ring)
def is_quasigeometric(self): """ Decide whether the binary recurrence sequence is degenerate and similar to a geometric sequence, i.e. the union of multiple geometric sequences, or geometric after term ``u0``. If `\\alpha/\\beta` is a `k` th root of unity, where `k>1`, then necessarily `k = 2, 3, 4, 6`. Then `F = [[0,1],[c,b]` is diagonalizable, and `F^k = [[\\alpha^k, 0], [0,\\beta^k]]` is scaler matrix. Thus for all values of `j` mod `k`, the `j` mod `k` terms of `u_n` form a geometric series. If `\\alpha` or `\\beta` is zero, this implies that `c=0`. This is the case when `F` is singular. In this case, `u_1, u_2, u_3, ...` is geometric. EXAMPLES:: sage: S = BinaryRecurrenceSequence(0,1) sage: [S(i) for i in range(10)] [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] sage: S.is_quasigeometric() True sage: R = BinaryRecurrenceSequence(3,0) sage: [R(i) for i in range(10)] [0, 1, 3, 9, 27, 81, 243, 729, 2187, 6561] sage: R.is_quasigeometric() True """ #First test if F is singular... i.e. beta = 0 if self.c == 0: return True #Otherwise test if alpha/beta is a root of unity that is not 1 else: if (self.b**2 + 4 * self.c) != 0: #thus alpha/beta != 1 if (self.b**2 + 4 * self.c).is_square(): A = sqrt((self.b**2 + 4 * self.c)) else: K = QuadraticField((self.b**2 + 4 * self.c), 'x') A = K.gen() if ((self.b + A) / (self.b - A))**(6) == 1: return True return False
def is_quasigeometric(self): """ Decide whether the binary recurrence sequence is degenerate and similar to a geometric sequence, i.e. the union of multiple geometric sequences, or geometric after term ``u0``. If `\\alpha/\\beta` is a `k` th root of unity, where `k>1`, then necessarily `k = 2, 3, 4, 6`. Then `F = [[0,1],[c,b]` is diagonalizable, and `F^k = [[\\alpha^k, 0], [0,\\beta^k]]` is scaler matrix. Thus for all values of `j` mod `k`, the `j` mod `k` terms of `u_n` form a geometric series. If `\\alpha` or `\\beta` is zero, this implies that `c=0`. This is the case when `F` is singular. In this case, `u_1, u_2, u_3, ...` is geometric. EXAMPLES:: sage: S = BinaryRecurrenceSequence(0,1) sage: [S(i) for i in range(10)] [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] sage: S.is_quasigeometric() True sage: R = BinaryRecurrenceSequence(3,0) sage: [R(i) for i in range(10)] [0, 1, 3, 9, 27, 81, 243, 729, 2187, 6561] sage: R.is_quasigeometric() True """ #First test if F is singular... i.e. beta = 0 if self.c == 0: return True #Otherwise test if alpha/beta is a root of unity that is not 1 else: if (self.b**2+4*self.c) != 0: #thus alpha/beta != 1 if (self.b**2+4*self.c).is_square(): A = sqrt((self.b**2+4*self.c)) else: K = QuadraticField((self.b**2+4*self.c), 'x') A = K.gen() if ((self.b+A)/(self.b-A))**(6) == 1: return True return False
def icosidodecahedron(self, exact=True): """ Return the Icosidodecahedron The Icosidodecahedron is a polyhedron with twenty triangular faces and twelve pentagonal faces. For more information see the :wikipedia:`Icosidodecahedron`. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. EXAMPLES:: sage: gr = polytopes.icosidodecahedron() sage: gr.f_vector() (1, 30, 60, 32, 1) TESTS:: sage: polytopes.icosidodecahedron(exact=False) A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 30 vertices """ from sage.rings.number_field.number_field import QuadraticField from itertools import product K = QuadraticField(5, 'sqrt5') one = K.one() phi = (one + K.gen()) / 2 gens = [((-1)**a * one / 2, (-1)**b * phi / 2, (-1)**c * (one + phi) / 2) for a, b, c in product([0, 1], repeat=3)] gens.extend([(0, 0, phi), (0, 0, -phi)]) verts = [] for p in AlternatingGroup(3): verts.extend(p(x) for x in gens) if exact: return Polyhedron(vertices=verts, base_ring=K) else: verts = [(RR(x), RR(y), RR(z)) for x, y, z in verts] return Polyhedron(vertices=verts)
def icosidodecahedron(self, exact=True): """ Return the Icosidodecahedron The Icosidodecahedron is a polyhedron with twenty triangular faces and twelve pentagonal faces. For more information see the :wikipedia:`Icosidodecahedron`. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. EXAMPLES:: sage: gr = polytopes.icosidodecahedron() sage: gr.f_vector() (1, 30, 60, 32, 1) TESTS:: sage: polytopes.icosidodecahedron(exact=False) A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 30 vertices """ from sage.rings.number_field.number_field import QuadraticField from itertools import product K = QuadraticField(5, 'sqrt5') one = K.one() phi = (one+K.gen())/2 gens = [((-1)**a*one/2, (-1)**b*phi/2, (-1)**c*(one+phi)/2) for a,b,c in product([0,1],repeat=3)] gens.extend([(0,0,phi), (0,0,-phi)]) verts = [] for p in AlternatingGroup(3): verts.extend(p(x) for x in gens) if exact: return Polyhedron(vertices=verts,base_ring=K) else: verts = [(RR(x),RR(y),RR(z)) for x,y,z in verts] return Polyhedron(vertices=verts)
def is_degenerate(self): """ Decide whether the binary recurrence sequence is degenerate. Let `\\alpha` and `\\beta` denote the roots of the characteristic polynomial `p(x) = x^2-bx -c`. Let `a = u_1-u_0\\beta/(\\beta - \\alpha)` and `b = u_1-u_0\\alpha/(\\beta - \\alpha)`. The sequence is, thus, given by `u_n = a \\alpha^n - b\\beta^n`. Then we say that the sequence is nondegenerate if and only if `a*b*\\alpha*\\beta \\neq 0` and `\\alpha/\\beta` is not a root of unity. More concretely, there are 4 classes of degeneracy, that can all be formulated in terms of the matrix `F = [[0,1], [c, b]]`. - `F` is singular -- this corresponds to ``c`` = 0, and thus `\\alpha*\\beta = 0`. This sequence is geometric after term ``u0`` and so we call it ``quasigeometric``. - `v = [[u_0], [u_1]]` is an eigenvector of `F` -- this corresponds to a ``geometric`` sequence with `a*b = 0`. - `F` is nondiagonalizable -- this corresponds to `\\alpha = \\beta`. This sequence will be the point-wise product of an arithmetic and geometric sequence. - `F^k` is scaler, for some `k>1` -- this corresponds to `\\alpha/\\beta` a `k` th root of unity. This sequence is a union of several geometric sequences, and so we again call it ``quasigeometric``. EXAMPLES:: sage: S = BinaryRecurrenceSequence(0,1) sage: S.is_degenerate() True sage: S.is_geometric() False sage: S.is_quasigeometric() True sage: R = BinaryRecurrenceSequence(3,-2) sage: R.is_degenerate() False sage: T = BinaryRecurrenceSequence(2,-1) sage: T.is_degenerate() True sage: T.is_arithmetic() True """ if (self.b**2 + 4 * self.c) != 0: if (self.b**2 + 4 * self.c).is_square(): A = sqrt((self.b**2 + 4 * self.c)) else: K = QuadraticField((self.b**2 + 4 * self.c), 'x') A = K.gen() aa = (self.u1 - self.u0 * (self.b + A) / 2) / (A) #called `a` in Docstring bb = (self.u1 - self.u0 * (self.b - A) / 2) / (A) #called `b` in Docstring #(b+A)/2 is called alpha in Docstring, (b-A)/2 is called beta in Docstring if (self.b - A) != 0: if ((self.b + A) / (self.b - A))**(6) == 1: return True else: return True if aa * bb * (self.b + A) * (self.b - A) == 0: return True return False return True
def icosahedron(self, exact=True, base_ring=None): """ Return an icosahedron with edge length 1. The icosahedron is one of the Platonic sold. It has 20 faces and is dual to the :meth:`dodecahedron`. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. - ``base_ring`` -- (optional) the ring in which the coordinates will belong to. Note that this ring must contain `\sqrt(5)`. If it is not provided and ``exact=True`` it will be the number field `\QQ[\sqrt(5)]` and if ``exact=False`` it will be the real double field. EXAMPLES:: sage: ico = polytopes.icosahedron() sage: ico.f_vector() (1, 12, 30, 20, 1) sage: ico.volume() 5/12*sqrt5 + 5/4 Its non exact version:: sage: ico = polytopes.icosahedron(exact=False) sage: ico.base_ring() Real Double Field sage: ico.volume() 2.1816949907715726 A version using `AA <sage.rings.qqbar.AlgebraicRealField>`:: sage: ico = polytopes.icosahedron(base_ring=AA) # long time sage: ico.base_ring() # long time Algebraic Real Field sage: ico.volume() # long time 2.181694990624913? Note that if base ring is provided it must contain the square root of `5`. Otherwise you will get an error:: sage: polytopes.icosahedron(base_ring=QQ) Traceback (most recent call last): ... TypeError: unable to convert 1/4*sqrt(5) + 1/4 to a rational """ if base_ring is None and exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(5, 'sqrt5') sqrt5 = K.gen() g = (1 + sqrt5) / 2 base_ring = K else: if base_ring is None: base_ring = RDF g = (1 + base_ring(5).sqrt()) / 2 r12 = base_ring.one() / 2 z = base_ring.zero() pts = [[z, s1*r12, s2*g/2] for s1,s2 in itertools.product([1,-1],repeat=2)] verts = [p(v) for p in AlternatingGroup(3) for v in pts] return Polyhedron(vertices=verts, base_ring=base_ring)
def is_degenerate(self): """ Decide whether the binary recurrence sequence is degenerate. Let `\\alpha` and `\\beta` denote the roots of the characteristic polynomial `p(x) = x^2-bx -c`. Let `a = u_1-u_0\\beta/(\\beta - \\alpha)` and `b = u_1-u_0\\alpha/(\\beta - \\alpha)`. The sequence is, thus, given by `u_n = a \\alpha^n - b\\beta^n`. Then we say that the sequence is nondegenerate if and only if `a*b*\\alpha*\\beta \\neq 0` and `\\alpha/\\beta` is not a root of unity. More concretely, there are 4 classes of degeneracy, that can all be formulated in terms of the matrix `F = [[0,1], [c, b]]`. - `F` is singular -- this corresponds to ``c`` = 0, and thus `\\alpha*\\beta = 0`. This sequence is geometric after term ``u0`` and so we call it ``quasigeometric``. - `v = [[u_0], [u_1]]` is an eigenvector of `F` -- this corresponds to a ``geometric`` sequence with `a*b = 0`. - `F` is nondiagonalizable -- this corresponds to `\\alpha = \\beta`. This sequence will be the point-wise product of an arithmetic and geometric sequence. - `F^k` is scaler, for some `k>1` -- this corresponds to `\\alpha/\\beta` a `k` th root of unity. This sequence is a union of several geometric sequences, and so we again call it ``quasigeometric``. EXAMPLES:: sage: S = BinaryRecurrenceSequence(0,1) sage: S.is_degenerate() True sage: S.is_geometric() False sage: S.is_quasigeometric() True sage: R = BinaryRecurrenceSequence(3,-2) sage: R.is_degenerate() False sage: T = BinaryRecurrenceSequence(2,-1) sage: T.is_degenerate() True sage: T.is_arithmetic() True """ if (self.b**2+4*self.c) != 0: if (self.b**2+4*self.c).is_square(): A = sqrt((self.b**2+4*self.c)) else: K = QuadraticField((self.b**2+4*self.c), 'x') A = K.gen() aa = (self.u1 - self.u0*(self.b + A)/2)/(A) #called `a` in Docstring bb = (self.u1 - self.u0*(self.b - A)/2)/(A) #called `b` in Docstring #(b+A)/2 is called alpha in Docstring, (b-A)/2 is called beta in Docstring if (self.b - A) != 0: if ((self.b+A)/(self.b-A))**(6) == 1: return True else: return True if aa*bb*(self.b + A)*(self.b - A) == 0: return True return False return True
def small_rhombicuboctahedron(self, exact=True, base_ring=None): """ Return the (small) rhombicuboctahedron. The rhombicuboctahedron is an Archimedean solid with 24 vertices and 26 faces. See the :wikipedia:`Rhombicuboctahedron` for more information. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. - ``base_ring`` -- the ring in which the coordinates will belong to. If it is not provided and ``exact=True`` it will be a the number field `\QQ[\phi]` where `\phi` is the golden ratio and if ``exact=False`` it will be the real double field. EXAMPLES:: sage: sr = polytopes.small_rhombicuboctahedron() sage: sr.f_vector() (1, 24, 48, 26, 1) sage: sr.volume() 80/3*sqrt2 + 32 The faces are `8` equilateral triangles and `18` squares:: sage: sum(1 for f in sr.faces(2) if len(f.vertices()) == 3) 8 sage: sum(1 for f in sr.faces(2) if len(f.vertices()) == 4) 18 Its non exact version:: sage: sr = polytopes.small_rhombicuboctahedron(False) sage: sr A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 24 vertices sage: sr.f_vector() (1, 24, 48, 26, 1) """ if base_ring is None and exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(2, 'sqrt2') sqrt2 = K.gen() base_ring = K else: if base_ring is None: base_ring = RDF sqrt2 = base_ring(2).sqrt() one = base_ring.one() a = sqrt2 + one verts = [] verts.extend([s1 * one, s2 * one, s3 * a] for s1, s2, s3 in itertools.product([1, -1], repeat=3)) verts.extend([s1 * one, s3 * a, s2 * one] for s1, s2, s3 in itertools.product([1, -1], repeat=3)) verts.extend([s1 * a, s2 * one, s3 * one] for s1, s2, s3 in itertools.product([1, -1], repeat=3)) return Polyhedron(vertices=verts)
def icosahedron(self, exact=True, base_ring=None): """ Return an icosahedron with edge length 1. The icosahedron is one of the Platonic sold. It has 20 faces and is dual to the :meth:`dodecahedron`. INPUT: - ``exact`` -- (boolean, default ``True``) If ``False`` use an approximate ring for the coordinates. - ``base_ring`` -- (optional) the ring in which the coordinates will belong to. Note that this ring must contain `\sqrt(5)`. If it is not provided and ``exact=True`` it will be the number field `\QQ[\sqrt(5)]` and if ``exact=False`` it will be the real double field. EXAMPLES:: sage: ico = polytopes.icosahedron() sage: ico.f_vector() (1, 12, 30, 20, 1) sage: ico.volume() 5/12*sqrt5 + 5/4 Its non exact version:: sage: ico = polytopes.icosahedron(exact=False) sage: ico.base_ring() Real Double Field sage: ico.volume() 2.1816949907715726 A version using `AA <sage.rings.qqbar.AlgebraicRealField>`:: sage: ico = polytopes.icosahedron(base_ring=AA) # long time sage: ico.base_ring() # long time Algebraic Real Field sage: ico.volume() # long time 2.181694990624913? Note that if base ring is provided it must contain the square root of `5`. Otherwise you will get an error:: sage: polytopes.icosahedron(base_ring=QQ) Traceback (most recent call last): ... TypeError: unable to convert 1/4*sqrt(5) + 1/4 to a rational """ if base_ring is None and exact: from sage.rings.number_field.number_field import QuadraticField K = QuadraticField(5, 'sqrt5') sqrt5 = K.gen() g = (1 + sqrt5) / 2 base_ring = K else: if base_ring is None: base_ring = RDF g = (1 + base_ring(5).sqrt()) / 2 r12 = base_ring.one() / 2 z = base_ring.zero() pts = [[z, s1 * r12, s2 * g / 2] for s1, s2 in itertools.product([1, -1], repeat=2)] verts = [p(v) for p in AlternatingGroup(3) for v in pts] return Polyhedron(vertices=verts, base_ring=base_ring)