def _repr_(self): """ EXAMPLES:: sage: K = KontsevichGraphSums(QQ) sage: KG = KontsevichGraph(ground_vertices=(), immutable=True) sage: KontsevichGraphSum(K, [(1/2, KG)]) 1/2*(Kontsevich graph with 0 vertices on 0 ground vertices) """ self.reduce() if self._terms == []: return '0' parenthesize = lambda c: str(c) if is_SymbolicExpressionRing(self.base_ring()): from sage.symbolic.operators import add_vararg is_sum = lambda x: self.base_ring()(x).operator() == add_vararg parenthesize = lambda c: '(%s)' % c if is_sum(c) else c return ' + '.join('%s*(%s)' % (parenthesize(c), g) for (c,g) in self._terms)
def dynatomic_polynomial(self, period): r""" Compute the (affine) dynatomic polynomial of a dynamical system `f: \mathbb{A}^1 \to \mathbb{A}^1`. The dynatomic polynomial is the analog of the cyclotomic polynomial and its roots are the points of formal period `n`. ALGORITHM: Homogenize to a map `f: \mathbb{P}^1 \to \mathbb{P}^1` and compute the dynatomic polynomial there. Then, dehomogenize. INPUT: - ``period`` -- a positive integer or a list/tuple `[m,n]`, where `m` is the preperiod and `n` is the period OUTPUT: If possible, a single variable polynomial in the coordinate ring of the polynomial. Otherwise a fraction field element of the coordinate ring of the polynomial. EXAMPLES:: sage: A.<x,y> = AffineSpace(QQ, 2) sage: f = DynamicalSystem_affine([x^2+y^2, y^2]) sage: f.dynatomic_polynomial(2) Traceback (most recent call last): ... TypeError: does not make sense in dimension >1 :: sage: A.<x> = AffineSpace(ZZ, 1) sage: f = DynamicalSystem_affine([(x^2+1)/x]) sage: f.dynatomic_polynomial(4) 2*x^12 + 18*x^10 + 57*x^8 + 79*x^6 + 48*x^4 + 12*x^2 + 1 :: sage: A.<x> = AffineSpace(CC, 1) sage: f = DynamicalSystem_affine([(x^2+1)/(3*x)]) sage: f.dynatomic_polynomial(3) 13.0000000000000*x^6 + 117.000000000000*x^4 + 78.0000000000000*x^2 + 1.00000000000000 :: sage: A.<x> = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([x^2-10/9]) sage: f.dynatomic_polynomial([2, 1]) 531441*x^4 - 649539*x^2 - 524880 :: sage: A.<x> = AffineSpace(CC, 1) sage: f = DynamicalSystem_affine([x^2+CC.0]) sage: f.dynatomic_polynomial(2) x^2 + x + 1.00000000000000 + 1.00000000000000*I :: sage: K.<c> = FunctionField(QQ) sage: A.<x> = AffineSpace(K, 1) sage: f = DynamicalSystem_affine([x^2 + c]) sage: f.dynatomic_polynomial(4) x^12 + 6*c*x^10 + x^9 + (15*c^2 + 3*c)*x^8 + 4*c*x^7 + (20*c^3 + 12*c^2 + 1)*x^6 + (6*c^2 + 2*c)*x^5 + (15*c^4 + 18*c^3 + 3*c^2 + 4*c)*x^4 + (4*c^3 + 4*c^2 + 1)*x^3 + (6*c^5 + 12*c^4 + 6*c^3 + 5*c^2 + c)*x^2 + (c^4 + 2*c^3 + c^2 + 2*c)*x + c^6 + 3*c^5 + 3*c^4 + 3*c^3 + 2*c^2 + 1 :: sage: A.<z> = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([z^2+3/z+1/7]) sage: f.dynatomic_polynomial(1).parent() Multivariate Polynomial Ring in z over Rational Field :: sage: R.<c> = QQ[] sage: A.<z> = AffineSpace(R,1) sage: f = DynamicalSystem_affine([z^2 + c]) sage: f.dynatomic_polynomial([1,1]) z^2 + z + c :: sage: A.<x> = AffineSpace(CC,1) sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) sage: F.dynatomic_polynomial([1,1]) (0.125000000000000*x^4 + 0.366025403784439*x^2 + 1.50000000000000)/(0.500000000000000*x^2 - x + 1.73205080756888) TESTS:: sage: R.<c> = QQ[] sage: Pc.<x,y> = ProjectiveSpace(R, 1) sage: G = DynamicalSystem_projective([(1/2*c + 1/2)*x^2 + (-2*c)*x*y + 2*c*y^2 , \ (1/4*c + 1/2)*x^2 + (-c - 1)*x*y + (c + 1)*y^2]) sage: G.dehomogenize(1).dynatomic_polynomial(2) (1/4*c + 1/4)*x^2 + (-c - 1/2)*x + c + 1 """ from sage.schemes.affine.affine_space import is_AffineSpace if not is_AffineSpace(self.domain()): raise NotImplementedError("not implemented for subschemes") if self.domain().dimension_relative() > 1: raise TypeError("does not make sense in dimension >1") G = self.homogenize(1) F = G.dynatomic_polynomial(period) T = G.domain().coordinate_ring() S = self.domain().coordinate_ring() if is_SymbolicExpressionRing(F.parent()): u = var(self.domain().coordinate_ring().variable_name()) return F.subs({F.variables()[0]: u, F.variables()[1]: 1}) elif T(F.denominator()).degree() == 0: R = F.parent() phi = R.hom([S.gen(0), 1], S) return phi(F) else: R = F.numerator().parent() phi = R.hom([S.gen(0), 1], S) return phi(F.numerator()) / phi(F.denominator())
def dynatomic_polynomial(self, period): r""" Compute the (affine) dynatomic polynomial of a dynamical system `f: \mathbb{A}^1 \to \mathbb{A}^1`. The dynatomic polynomial is the analog of the cyclotomic polynomial and its roots are the points of formal period `n`. ALGORITHM: Homogenize to a map `f: \mathbb{P}^1 \to \mathbb{P}^1` and compute the dynatomic polynomial there. Then, dehomogenize. INPUT: - ``period`` -- a positive integer or a list/tuple `[m,n]`, where `m` is the preperiod and `n` is the period OUTPUT: If possible, a single variable polynomial in the coordinate ring of the polynomial. Otherwise a fraction field element of the coordinate ring of the polynomial. EXAMPLES:: sage: A.<x,y> = AffineSpace(QQ, 2) sage: f = DynamicalSystem_affine([x^2+y^2, y^2]) sage: f.dynatomic_polynomial(2) Traceback (most recent call last): ... TypeError: does not make sense in dimension >1 :: sage: A.<x> = AffineSpace(ZZ, 1) sage: f = DynamicalSystem_affine([(x^2+1)/x]) sage: f.dynatomic_polynomial(4) 2*x^12 + 18*x^10 + 57*x^8 + 79*x^6 + 48*x^4 + 12*x^2 + 1 :: sage: A.<x> = AffineSpace(CC, 1) sage: f = DynamicalSystem_affine([(x^2+1)/(3*x)]) sage: f.dynatomic_polynomial(3) 13.0000000000000*x^6 + 117.000000000000*x^4 + 78.0000000000000*x^2 + 1.00000000000000 :: sage: A.<x> = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([x^2-10/9]) sage: f.dynatomic_polynomial([2, 1]) 531441*x^4 - 649539*x^2 - 524880 :: sage: A.<x> = AffineSpace(CC, 1) sage: f = DynamicalSystem_affine([x^2+CC.0]) sage: f.dynatomic_polynomial(2) x^2 + x + 1.00000000000000 + 1.00000000000000*I :: sage: K.<c> = FunctionField(QQ) sage: A.<x> = AffineSpace(K, 1) sage: f = DynamicalSystem_affine([x^2 + c]) sage: f.dynatomic_polynomial(4) x^12 + 6*c*x^10 + x^9 + (15*c^2 + 3*c)*x^8 + 4*c*x^7 + (20*c^3 + 12*c^2 + 1)*x^6 + (6*c^2 + 2*c)*x^5 + (15*c^4 + 18*c^3 + 3*c^2 + 4*c)*x^4 + (4*c^3 + 4*c^2 + 1)*x^3 + (6*c^5 + 12*c^4 + 6*c^3 + 5*c^2 + c)*x^2 + (c^4 + 2*c^3 + c^2 + 2*c)*x + c^6 + 3*c^5 + 3*c^4 + 3*c^3 + 2*c^2 + 1 :: sage: A.<z> = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([z^2+3/z+1/7]) sage: f.dynatomic_polynomial(1).parent() Multivariate Polynomial Ring in z over Rational Field :: sage: R.<c> = QQ[] sage: A.<z> = AffineSpace(R,1) sage: f = DynamicalSystem_affine([z^2 + c]) sage: f.dynatomic_polynomial([1,1]) z^2 + z + c :: sage: A.<x> = AffineSpace(CC,1) sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) sage: F.dynatomic_polynomial([1,1]) (0.125000000000000*x^4 + 0.366025403784439*x^2 + 1.50000000000000)/(0.500000000000000*x^2 - x + 1.73205080756888) """ from sage.schemes.affine.affine_space import is_AffineSpace if not is_AffineSpace(self.domain()): raise NotImplementedError("not implemented for subschemes") if self.domain().dimension_relative() > 1: raise TypeError("does not make sense in dimension >1") G = self.homogenize(1) F = G.dynatomic_polynomial(period) T = G.domain().coordinate_ring() S = self.domain().coordinate_ring() if is_SymbolicExpressionRing(F.parent()): u = var(self.domain().coordinate_ring().variable_name()) return F.subs({F.variables()[0]:u,F.variables()[1]:1}) elif T(F.denominator()).degree() == 0: R = F.parent() phi = R.hom([S.gen(0), 1], S) return phi(F) else: R = F.numerator().parent() phi = R.hom([S.gen(0), 1], S) return phi(F.numerator())/phi(F.denominator())
def dynatomic_polynomial(self, period): r""" For a map `f:\mathbb{A}^1 \to \mathbb{A}^1` this function computes the (affine) dynatomic polynomial. The dynatomic polynomial is the analog of the cyclotomic polynomial and its roots are the points of formal period `n`. ALGORITHM: Homogenize to a map `f:\mathbb{P}^1 \to \mathbb{P}^1` and compute the dynatomic polynomial there. Then, dehomogenize. INPUT: - ``period`` -- a positive integer or a list/tuple `[m,n]`, where `m` is the preperiod and `n` is the period. OUTPUT: - If possible, a single variable polynomial in the coordinate ring of the polynomial. \ Otherwise a fraction field element of the coordinate ring of the polynomial. EXAMPLES:: sage: A.<x,y> = AffineSpace(QQ, 2) sage: H = Hom(A, A) sage: f = H([x^2+y^2, y^2]) sage: f.dynatomic_polynomial(2) Traceback (most recent call last): ... TypeError: does not make sense in dimension >1 :: sage: A.<x> = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([(x^2+1)/x]) sage: f.dynatomic_polynomial(4) 2*x^12 + 18*x^10 + 57*x^8 + 79*x^6 + 48*x^4 + 12*x^2 + 1 :: sage: A.<x> = AffineSpace(CC, 1) sage: H = Hom(A, A) sage: f = H([(x^2+1)/(3*x)]) sage: f.dynatomic_polynomial(3) 13.0000000000000*x^6 + 117.000000000000*x^4 + 78.0000000000000*x^2 + 1.00000000000000 :: sage: A.<x> = AffineSpace(QQ, 1) sage: H = Hom(A, A) sage: f = H([x^2-10/9]) sage: f.dynatomic_polynomial([2, 1]) 531441*x^4 - 649539*x^2 - 524880 :: sage: A.<x> = AffineSpace(CC, 1) sage: H = Hom(A, A) sage: f = H([x^2+CC.0]) sage: f.dynatomic_polynomial(2) x^2 + x + 1.00000000000000 + 1.00000000000000*I :: sage: K.<c> = FunctionField(QQ) sage: A.<x> = AffineSpace(K, 1) sage: H = Hom(A, A) sage: f = H([x^2 + c]) sage: f.dynatomic_polynomial(4) x^12 + 6*c*x^10 + x^9 + (15*c^2 + 3*c)*x^8 + 4*c*x^7 + (20*c^3 + 12*c^2 + 1)*x^6 + (6*c^2 + 2*c)*x^5 + (15*c^4 + 18*c^3 + 3*c^2 + 4*c)*x^4 + (4*c^3 + 4*c^2 + 1)*x^3 + (6*c^5 + 12*c^4 + 6*c^3 + 5*c^2 + c)*x^2 + (c^4 + 2*c^3 + c^2 + 2*c)*x + c^6 + 3*c^5 + 3*c^4 + 3*c^3 + 2*c^2 + 1 :: sage: A.<z> = AffineSpace(QQ, 1) sage: H = End(A) sage: f = H([z^2+3/z+1/7]) sage: f.dynatomic_polynomial(1).parent() Multivariate Polynomial Ring in z over Rational Field :: sage: R.<c> = QQ[] sage: A.<z> = AffineSpace(R,1) sage: H = End(A) sage: f = H([z^2 + c]) sage: f.dynatomic_polynomial([1,1]) z^2 + z + c :: sage: A.<x> = AffineSpace(CC,1) sage: H = Hom(A,A) sage: F = H([1/2*x^2 + sqrt(3)]) sage: F.dynatomic_polynomial([1,1]) (2.00000000000000*x^4 + 5.85640646055102*x^2 + 24.0000000000000)/(x^2 + (-2.00000000000000)*x + 3.46410161513775) """ if self.domain() != self.codomain(): raise TypeError("must have same domain and codomain to iterate") from sage.schemes.affine.affine_space import is_AffineSpace if is_AffineSpace(self.domain())==False: raise NotImplementedError("not implemented for subschemes") if self.domain().dimension_relative()>1: raise TypeError("does not make sense in dimension >1") G = self.homogenize(1) F = G.dynatomic_polynomial(period) T = G.domain().coordinate_ring() S = self.domain().coordinate_ring() if is_SymbolicExpressionRing(F.parent()): u = var(self.domain().coordinate_ring().variable_name()) return F.subs({F.variables()[0]:u,F.variables()[1]:1}) elif T(F.denominator()).degree() == 0: R = F.parent() phi = R.hom([S.gen(0), 1], S) return(phi(F)) else: R = F.numerator().parent() phi = R.hom([S.gen(0), 1], S) return(phi(F.numerator())/phi(F.denominator()))