Skip to content

Commit

Permalink
projective_ds.py: Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
guojing0 committed Jul 30, 2023
1 parent 26f5a09 commit e488d6e
Showing 1 changed file with 58 additions and 18 deletions.
76 changes: 58 additions & 18 deletions src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4468,6 +4468,13 @@ def preperiodic_points(self, m, n, **kwds):
...
TypeError: use return_scheme=True
::
sage: P.<x,y> = ProjectiveSpace(ZZ, 1)
sage: f = DynamicalSystem_projective([x^2 - y^2, y^2])
sage: f.preperiodic_points(1, 1)
0
::
sage: P.<x,y> = ProjectiveSpace(QQ, 1)
Expand Down Expand Up @@ -4500,114 +4507,147 @@ def preperiodic_points(self, m, n, **kwds):
"""
n = ZZ(n)
m = ZZ(m)

if n <= 0:
raise ValueError("a positive integer period must be specified")
if m < 0:
raise ValueError("a non negative preperiod must be specified")

R = kwds.pop('R', None)

if R is None:
f_sub = self
R = self.base_ring()
else:
f_sub = self.change_ring(R)
R = f_sub.base_ring() #in the case when R is an embedding
R = f_sub.base_ring() # In the case when R is an embedding

if isinstance(R, FractionField_1poly_field) or is_FunctionField(R):
raise NotImplementedError('Periodic points not implemented for function fields; '
'clear denominators and use the polynomial ring instead')

CR = f_sub.coordinate_ring()
dom = f_sub.domain()
PS = f_sub.codomain().ambient_space()

if dom != PS:
f = DynamicalSystem(f_sub.defining_polynomials())
else:
f = f_sub

N = PS.dimension_relative() + 1
formal = kwds.pop('formal', False)
minimal = kwds.pop('minimal', True)
return_scheme = kwds.pop('return_scheme', False)
if formal and N == 2 and dom == PS:

if formal and (N == 2) and (dom == PS):
X = PS.subscheme([f.dynatomic_polynomial([m,n])])
else:
F_1 = f.nth_iterate_map(n+m)
F_1 = f.nth_iterate_map(n + m)
F_2 = f.nth_iterate_map(m)
L = [F_1[i]*F_2[j] - F_1[j]*F_2[i] for i in range(N)
for j in range(i+1, N)]
for j in range(i + 1, N)]
X = PS.subscheme(L + list(dom.defining_polynomials()))

if (minimal or formal) and (n != 1 or m != 0):
if not f_sub.is_morphism():
raise ValueError('dynamical system is not a morphism, cannot calculate minimal or formal preperiodic points')

if formal:
d = f.degree()
# we need a model with no preperiodic points at infinity

# We need a model with no preperiodic points at infinity
new_f, mat = f.affine_preperiodic_model(m, n, return_conjugation=True)
new_f.normalize_coordinates()
# we now deform by a parameter t

# We now deform by a parameter `t`
T = R['t']
t = T.gens()[0]
Pt = ProjectiveSpace(N-1, R=T, names=[str(i) for i in CR.gens()])
deformed_polys = [poly + t*Pt.gens()[-1]**d for poly in new_f.defining_polynomials()[:-1]]
Pt = ProjectiveSpace(N - 1, R=T, names=[str(i) for i in CR.gens()])
deformed_polys = [poly + t * Pt.gens()[-1]**d for poly in new_f.defining_polynomials()[:-1]]
deformed_polys += [new_f.defining_polynomials()[-1]]
f_deformed = DynamicalSystem(deformed_polys)

# after deforming by the parameter, the preperiodic points with multiplicity
# will separate into different points. we can now calculate the minimal preperiodic
# points with the parameter, and then specialize to get the formal preperiodic points
# After deforming by the parameter, the preperiodic points
# with multiplicity will separate into different points.
# We can now calculate the minimal preperiodic points with
# the parameter, and then specialize to get the formal
# preperiodic points.
ideal = f_deformed.preperiodic_points(m, n, return_scheme=True).defining_ideal()
L = [poly.specialization({t:0}) for poly in ideal.gens()]
X = PS.subscheme(L)
subs_list = mat.inverse()*vector(CR.gens())
subs_list = mat.inverse() * vector(CR.gens())
subs = {}

for i in range(len(subs_list)):
subs[PS.gens()[i]] = subs_list[i]

if R.is_field():
X = PS.subscheme([poly.subs(subs) for poly in L])
else:
K = [poly.subs(subs) for poly in L]
K = [poly*poly.denominator() for poly in K]
K = [poly * poly.denominator() for poly in K]

Check warning on line 4589 in src/sage/dynamics/arithmetic_dynamics/projective_ds.py

View check run for this annotation

Codecov / codecov/patch

src/sage/dynamics/arithmetic_dynamics/projective_ds.py#L4589

Added line #L4589 was not covered by tests
X = PS.subscheme(K)

elif minimal:
Sn = []

for k in ZZ(n).divisors():
if ZZ(n/k).is_prime():
Sn.append(k)
if (is_PolynomialRing(R) or is_MPolynomialRing(R)):

if is_PolynomialRing(R) or is_MPolynomialRing(R):
phi = FlatteningMorphism(CR)
flatCR = phi.codomain()
Ik = flatCR.ideal(1)

for k in Sn:
Ik *= f.preperiodic_points(m, k, return_scheme=True, minimal=False).defining_ideal()

if m != 0:
Ik *= f.preperiodic_points(m-1, n, return_scheme=True, minimal=False).defining_ideal()

psi = UnflatteningMorphism(flatCR, CR)
In = flatCR.ideal([phi(i) for i in X.defining_polynomials()])
X = PS.subscheme([psi(i) for i in In.saturation(Ik)[0].gens()])
else:
Ik = CR.ideal(1)

for k in Sn:
Ik *= f.preperiodic_points(m, k, return_scheme=True, minimal=False).defining_ideal()

if m != 0:
Ik *= f.preperiodic_points(m-1, n, return_scheme=True, minimal=False).defining_ideal()

In = X.defining_ideal()
X = PS.subscheme(In.saturation(Ik)[0])

if dom != PS:
X = PS.subscheme(list(X.defining_polynomials()) + list(dom.defining_polynomials()))
if return_scheme: # this includes the indeterminacy locus points!

# This includes the indeterminacy locus points!
if return_scheme:
return X

if X.dimension() <= 0:
if R in NumberFields() or R is QQbar or R in FiniteFields():
Z = f.base_indeterminacy_locus()
if (R in NumberFields()) or (R is QQbar) or (R in FiniteFields()):
points = [dom(Q) for Q in X.rational_points()]
good_points = []

for Q in points:
try:
Z = f.base_indeterminacy_locus()
Z(list(Q))
except TypeError:
good_points.append(Q)

good_points.sort()
return good_points
else:
raise NotImplementedError("ring must a number field or finite field")
else: #a higher dimensional scheme

# A higher dimensional scheme
else:
raise TypeError("use return_scheme=True")

def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='variety',
Expand Down

0 comments on commit e488d6e

Please sign in to comment.