Skip to content

Commit b47402b

Browse files
author
Release Manager
committed
Trac #34212: log_embedding for number field elements
This ticket is to add `log_embedding` (logarithmic embedding) functionality for number field elements, which is then used in #32686 for implementing `points_of_bounded_height`. URL: https://trac.sagemath.org/34212 Reported by: gh-guojing0 Ticket author(s): Jing Guo Reviewer(s): Alexander Galarraga
2 parents d30d2ff + 03aabf5 commit b47402b

File tree

2 files changed

+152
-2
lines changed

2 files changed

+152
-2
lines changed

src/sage/rings/number_field/number_field.py

+77
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@
153153
from collections import Counter
154154
from builtins import zip
155155

156+
from sage.categories.homset import Hom
157+
from sage.categories.sets_cat import Sets
158+
from sage.modules.free_module import VectorSpace
159+
from sage.modules.free_module_element import vector
160+
from sage.rings.real_mpfr import RR
156161

157162
_NumberFields = NumberFields()
158163

@@ -9306,6 +9311,78 @@ def minkowski_embedding(self, B=None, prec=None):
93069311

93079312
return sage.matrix.all.matrix(d)
93089313

9314+
def logarithmic_embedding(self, prec=53):
9315+
r"""
9316+
Return the morphism of ``self`` under the logarithmic embedding
9317+
in the category Set.
9318+
9319+
The logarithmic embedding is defined as a map from the number field ``self`` to `\RR^n`.
9320+
9321+
It is defined under Definition 4.9.6 in [Coh1993]_.
9322+
9323+
INPUT:
9324+
9325+
- ``prec`` -- desired floating point precision.
9326+
9327+
OUTPUT:
9328+
9329+
- the morphism of ``self`` under the logarithmic embedding in the category Set.
9330+
9331+
EXAMPLES::
9332+
9333+
sage: CF.<a> = CyclotomicField(5)
9334+
sage: f = CF.logarithmic_embedding()
9335+
sage: f(0)
9336+
(-1, -1)
9337+
sage: f(7)
9338+
(3.89182029811063, 3.89182029811063)
9339+
9340+
::
9341+
9342+
sage: K.<a> = NumberField(x^3 + 5)
9343+
sage: f = K.logarithmic_embedding()
9344+
sage: f(0)
9345+
(-1, -1)
9346+
sage: f(7)
9347+
(1.94591014905531, 3.89182029811063)
9348+
9349+
::
9350+
9351+
sage: F.<a> = NumberField(x^4 - 8*x^2 + 3)
9352+
sage: f = F.logarithmic_embedding()
9353+
sage: f(0)
9354+
(-1, -1, -1, -1)
9355+
sage: f(7)
9356+
(1.94591014905531, 1.94591014905531, 1.94591014905531, 1.94591014905531)
9357+
"""
9358+
def closure_map(x, prec=53):
9359+
"""
9360+
The function closure of the logarithmic embedding.
9361+
"""
9362+
K = self
9363+
K_embeddings = K.places(prec)
9364+
r1, r2 = K.signature()
9365+
r = r1 + r2 - 1
9366+
9367+
from sage.rings.all import RealField
9368+
Reals = RealField(prec)
9369+
9370+
if x == 0:
9371+
return vector([-1 for _ in range(r + 1)])
9372+
9373+
x_logs = []
9374+
for i in range(r1):
9375+
sigma = K_embeddings[i]
9376+
x_logs.append(Reals(abs(sigma(x))).log())
9377+
for i in range(r1, r + 1):
9378+
tau = K_embeddings[i]
9379+
x_logs.append(2 * Reals(abs(tau(x))).log())
9380+
9381+
return vector(x_logs)
9382+
9383+
hom = Hom(self, VectorSpace(RR, len(closure_map(self(0), prec))), Sets())
9384+
return hom(closure_map)
9385+
93099386
def places(self, all_complex=False, prec=None):
93109387
r"""
93119388
Return the collection of all infinite places of self.

src/sage/rings/number_field/number_field_rel.py

+75-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@
9999
from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs
100100
from sage.libs.pari.all import pari_gen
101101

102-
from sage.rings.rational_field import QQ
103-
from sage.rings.integer_ring import ZZ
102+
from sage.categories.homset import Hom
103+
from sage.categories.sets_cat import Sets
104+
from sage.modules.free_module import VectorSpace
105+
from sage.modules.free_module_element import vector
106+
107+
from sage.rings.all import RR, QQ, ZZ
104108

105109

106110
def is_RelativeNumberField(x):
@@ -2062,6 +2066,75 @@ def automorphisms(self):
20622066
check=False, universe=self.Hom(self))
20632067
return self.__automorphisms
20642068

2069+
def logarithmic_embedding(self, prec=53):
2070+
r"""
2071+
Return the morphism of ``self`` under the logarithmic embedding
2072+
in the category Set.
2073+
2074+
The logarithmic embedding is defined as a map from the relative number field ``self`` to `\RR^n`.
2075+
2076+
It is defined under Definition 4.9.6 in [Coh1993]_.
2077+
2078+
INPUT:
2079+
2080+
- ``prec`` -- desired floating point precision.
2081+
2082+
OUTPUT:
2083+
2084+
- the morphism of ``self`` under the logarithmic embedding in the category Set.
2085+
2086+
EXAMPLES::
2087+
2088+
sage: K.<k> = CyclotomicField(3)
2089+
sage: R.<x> = K[]
2090+
sage: L.<l> = K.extension(x^5 + 5)
2091+
sage: f = L.logarithmic_embedding()
2092+
sage: f(0)
2093+
(-1, -1, -1, -1, -1)
2094+
sage: f(5)
2095+
(3.21887582486820, 3.21887582486820, 3.21887582486820,
2096+
3.21887582486820, 3.21887582486820)
2097+
2098+
::
2099+
2100+
sage: K.<i> = NumberField(x^2 + 1)
2101+
sage: t = K['t'].gen()
2102+
sage: L.<a> = K.extension(t^4 - i)
2103+
sage: f = L.logarithmic_embedding()
2104+
sage: f(0)
2105+
(-1, -1, -1, -1, -1, -1, -1, -1)
2106+
sage: f(3)
2107+
(2.19722457733622, 2.19722457733622, 2.19722457733622, 2.19722457733622,
2108+
2.19722457733622, 2.19722457733622, 2.19722457733622, 2.19722457733622)
2109+
"""
2110+
def closure_map(x, prec=53):
2111+
"""
2112+
The function closure of the logarithmic embedding.
2113+
"""
2114+
K = self
2115+
K_embeddings = K.places(prec)
2116+
r1, r2 = K.signature()
2117+
r = r1 + r2 - 1
2118+
2119+
from sage.rings.all import RealField
2120+
Reals = RealField(prec)
2121+
2122+
if x == 0:
2123+
return vector([-1 for _ in range(r + 1)])
2124+
2125+
x_logs = []
2126+
for i in range(r1):
2127+
sigma = K_embeddings[i]
2128+
x_logs.append(Reals(abs(sigma(x))).log())
2129+
for i in range(r1, r + 1):
2130+
tau = K_embeddings[i]
2131+
x_logs.append(2 * Reals(abs(tau(x))).log())
2132+
2133+
return vector(x_logs)
2134+
2135+
hom = Hom(self, VectorSpace(RR, len(closure_map(self(0), prec))), Sets())
2136+
return hom(closure_map)
2137+
20652138
def places(self, all_complex=False, prec=None):
20662139
"""
20672140
Return the collection of all infinite places of self.

0 commit comments

Comments
 (0)