ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 10 Jan 2019 19:06:35 -0600Homomorphisms lifted from base ring in PowerSeriesRing do not preserve precisionhttp://ask.sagemath.org/question/45002/homomorphisms-lifted-from-base-ring-in-powerseriesring-do-not-preserve-precision/Hi all,
Homomorphisms which are lifted from the base ring seem to be unaware that precision exists in power/Laurent series rings. For example:
sage: R.<x> = PowerSeriesRing(ZZ)
sage: f = Hom(ZZ, ZZ)([1])
sage: Rf = Hom(R, R)(f); Rf
Ring endomorphism of Power Series Ring in x over Integer Ring
Defn: Induced from base ring by
Ring endomorphism of Integer Ring
Defn: 1 |--> 1
sage: Rf(1 + x + O(x^2))
1 + x
Can someone confirm that the expected output should be 1 + x + O(x^2), and that this is a bug?
Thanks,
Henryliu.henry.hlThu, 10 Jan 2019 19:06:35 -0600http://ask.sagemath.org/question/45002/Possible bug with identity morphismhttp://ask.sagemath.org/question/42625/possible-bug-with-identity-morphism/I have a number field `U` for which I consider its automorphisms through `Hom(U,U)`.
The identity `one=Hom(U,U).identity()` behaves weirdly under right multiplication:
U = CyclotomicField(3)
f = Hom(U,U)[1]
print f
print "--------------------"
one = Hom(U,U).identity()
print f*one
print "--------------------"
print one*f
print "--------------------"
print f*f
When I run this code, I expect `f` to be printed thrice, followed by the identity morphism.
However, while the first and third output do in fact both print `f`, the second prints
Composite map:
From: Cyclotomic Field of order 3 and degree 2
To: Cyclotomic Field of order 3 and degree 2
Defn: Identity endomorphism of Cyclotomic Field of order 3 and degree 2
then
Ring endomorphism of Cyclotomic Field of order 3 and degree 2
Defn: zeta3 |--> -zeta3 - 1
Is this a bug or is this this behaviour explained somewhere in the documentation?
MadPidgeonSun, 17 Jun 2018 05:47:03 -0500http://ask.sagemath.org/question/42625/How do I define a homomorphism of a graded commutative algebra?http://ask.sagemath.org/question/42202/how-do-i-define-a-homomorphism-of-a-graded-commutative-algebra/Why does the following throw a `TypeError: images do not define a valid homomorphism`?
E = GradedCommutativeAlgebra(QQ,'x,y',degrees=(1,1))
E.inject_variables()
f = E.hom([x,y])
I expected it to define $f$ to be the identity homomorphism of $E$. What is the right way to define a homomorphism of $E$? I'm more interested in the one that switches $x$ and $y$ than the identity homomorphism, but this seemed a more obvious version of the question.ronnoSat, 28 Apr 2018 12:14:46 -0500http://ask.sagemath.org/question/42202/(how/can) i declair this isomorphismhttp://ask.sagemath.org/question/41593/howcan-i-declair-this-isomorphism/Hi,
let $U$ be a square matrix of order $m$ over $\mathbb F_{q}$, more precisely $U$ is the companion matrix of a monic irreducible polynomial over $\mathbb F_{q}$ that define $\mathbb F_{q^m}$ .
let $\alpha$ be a primitive element of $\mathbb F_{q^m}$
I wish to declare this morphism to compute some examples with SAGEMATH
$\psi$: $\mathbb F_{q^m}$ $\rightarrow$ $\mathbb{F}_{q}[U]$
$\alpha$ $\mapsto$ $\psi(\alpha)=U$
thanks in advance;TWJFri, 16 Mar 2018 18:53:34 -0500http://ask.sagemath.org/question/41593/Computation of homomorphisms of number fieldshttp://ask.sagemath.org/question/40798/computation-of-homomorphisms-of-number-fields/Given two number fields, I want to construct a morphism between them.
For this I tried to use the hom member-function of the NumberField object as follows:
R.<zeta3> = CyclotomicField(3)
P.<X> = PolynomialRing(R)
K.<gen1> = R.extension(X^3-zeta3)
L.<gen2> = R.extension(X^3-zeta3^2)
print K.gens(), L.gens()
H = K.hom( [gen2,zeta3^2], L )
print H
The help page of hom specifies:
> Return the unique homomorphism from self to codomain that
sends ``self.gens()`` to the entries of ``im_gens``.
Raises a TypeError if there is no such homomorphism.
However, instead of TypeError, I get an incomprehensible error:
> File "/home/sage/bin/sage2/local/lib/python2.7/site-packages/sage/rings/number_field/number_field.py", line 1670, in _element_constructor_
raise ValueError("Length must be equal to the degree of this number field")
ValueError: Length must be equal to the degree of this number field
What am I doing wrong? Is there a better way to define this morphism?MadPidgeonSat, 27 Jan 2018 05:24:56 -0600http://ask.sagemath.org/question/40798/Compute preimage of Idealshttp://ask.sagemath.org/question/38264/compute-preimage-of-ideals/It's me again. I am wondering how to compute the preimage of an ideal $J\subseteq B$ in a ring along a ring homomorphism $f\colon A\to B$. For simplicity I would be fine with assuming $A$ and $B$ are polynomial rings of finitely many variables over a field. As far as I know, preimages can then be computed algorithmically using GrÃ¶bner bases so I think this should be implemented in Sage. However I did not find such a possibility when browsing through the documentation. I hope you can help me (and maybe also point me to where such issues are documented). Thank you!
P.S.: The question of how to compute kernels of homorphisms of affine algebras over a field is of course equivalent.ILikeAlgebraFri, 14 Jul 2017 12:27:34 -0500http://ask.sagemath.org/question/38264/Declaring a vector space map of ringshttp://ask.sagemath.org/question/38258/declaring-a-vector-space-map-of-rings/ Hello sage community!
I am new to sage and have a question which is originally motivated from my tries to implement Berlekamp's algorithm. One is working over a finite field $K=GF(q)$ and wants to factor a polynomial $f\in K[x]$. To do so one considers the ring $R=K[x]/f$ and the map $\beta\colon g\mapsto g^q-g$ from $R$ to itself and wants to compute its kernel. The problem for me is that the definition of $\beta$ <i>uses</i> the ring multiplication of of $R$ but <i>is</i> only a map of $K$-vector spaces, not a ring homomorphism. I am wondering how I can declare this map using sage.
I know I can find a standard $K$-basis of $R$ and I know I can describe $\beta$ by describing its matrix corresponding to this base and I know how to compute the kernel of that matrix and how to translate its elements back to elements of $R$. But still I am interested in wether it is possible to declare a <i>vector space</i> homomorphism of <i>rings</i> in sage and how to work with it.
Thank you!ILikeAlgebraFri, 14 Jul 2017 05:29:00 -0500http://ask.sagemath.org/question/38258/How to extend ring homomorphism to polynomial ring (or its fraction field)http://ask.sagemath.org/question/34947/how-to-extend-ring-homomorphism-to-polynomial-ring-or-its-fraction-field/I have a homomorphism from a number field `nf` to the field of algebraic numbers `QQbar`:
`nf, alpha, hom = QQbar(sqrt(2)).as_number_field_element()`
I now work in the polynomial ring `R` over `nf`:
`R.<x> = nf[]`
`f = x - alpha; f`
How do I get a homomorphism from `R` to the polynomial ring over `QQbar` extending `hom`?
For the moment, I can use
`f.map_coefficients(hom)`
Same question about the fraction field of `R`, e.g.,
`g = f/(x+1)`
Is there a more elegant way than calling
`g.numerator().map_coefficients(hom)/g.denominator().map_coefficients(hom)`
So basically, I'd like to extend my homomorphism `hom` to the polynomial ring and its field of fractions.Clemens HeubergerMon, 26 Sep 2016 07:15:18 -0500http://ask.sagemath.org/question/34947/Can't construct automorphisms of p-adic fieldshttp://ask.sagemath.org/question/29390/cant-construct-automorphisms-of-p-adic-fields/ I'm trying to construct automorphisms of finite extensions of $\mathbb Q_p$ and getting a funny error. Here's a prototypical example:
Evaluating the cyclotomic polynomial $x^4 + x^3 + x^2 + x + 1$ at $x+1$ gives an Eisenstein polynomial for the prime $p=5$. If $\pi$ is a root of $(x+1)^4 + (x+1)^3 + (x+1)^2 + (x+1) + 1$ then $\pi+1$ will be a primitive 5th root of unity.
K.<pi> = Qp(5).ext(sum((1+x)^i for i in range(5)))
So $K=\mathbb Q_p(\zeta_5)$ with uniformizer $\pi=\zeta_5-1$. Now I want to define the automorphism $\tau:\zeta_5\mapsto\zeta_5^2$. We have $\tau(\pi)=(1+\pi)^2-1=2\pi+\pi^2$. But the following
tau = K.hom([2*pi+pi^2])
results in the error `TypeError: images do not define a valid homomorphism`. What's going on? Are `hom`'s of $p$-adic fields not really implemented yet or am I doing something wrong?siggytmWed, 02 Sep 2015 17:40:36 -0500http://ask.sagemath.org/question/29390/TypeError for hom between multivariate Laurent polynomial rings?http://ask.sagemath.org/question/26813/typeerror-for-hom-between-multivariate-laurent-polynomial-rings/I am having an error whenever I attempt to construct a homomorphism
- from a Laurent polynomial ring
- to a Laurent polynomial ring in more than one variable.
Ex (SageMath Cloud, 5/12/15):
> R.<a>=LaurentPolynomialRing(ZZ)
>
> S.<b,c>=LaurentPolynomialRing(ZZ)
>
> phi=Hom(R,S)([b])
>
>>TypeError: images do not define a valid homomorphism
Additional data:
- An identical error occurs with the variant syntax R.hom([b]).
- An identical error occurs when trying to construct the identity homomorphism on LaurentPolynomialRing(ZZ,'x,y').
- There is no error if the domain is replaced by PolynomialRing(ZZ,'a').
- There is no error if the image of 'a' is 1.
- There is no error if the codomain is replaced by its own fraction field.
It appears that Sage is incorrectly determining that the reciprocal of the image of the generator(s) is not in the codomain.Greg MullerTue, 12 May 2015 11:47:39 -0500http://ask.sagemath.org/question/26813/Homomorphisms for relative number fieldshttp://ask.sagemath.org/question/24173/homomorphisms-for-relative-number-fields/How can I define a homomorphism from a relative number field *K* (containing *F*)
to some other field *L* if I know where to send *K.gens()*?
**Example:**
F_pol = x^2-x-1
F = NumberField(F_pol, 'lam')
K_pol = x^2 + 4
K = F.extension(K_pol, 'e')
L = QQbar
lam_im = L(F_pol.roots()[1][0])
e_im = L(K_pol.roots()[1][0])
**Wrong result:**
K.hom([e_im], QQbar, check=False)
**What we want (not working):**
K.hom([e_im, lam_im], QQbar, check=False)
**A working solution (edit):**
K.Hom(L)(e_im, F.hom([lam_im], check=False))
New question/example: What if L is not exact?
----
x = PolynomialRing(QQ,'x').gen()
F_pol = x^3 - x^2 - 2*x + 1
F.<lam> = NumberField(F_pol, 'lam')
D = 4*lam^2 + 4*lam - 4
K_pol = x^2 - D
K = F.extension(K_pol, 'e')
L = CC
lam_im = F_pol.roots(L)[2][0]
e_im = F.hom([lam_im], check=False)(D).sqrt()
K.Hom(L)(e_im, F.hom([lam_im], check=False), check=False)
This gives the error:
TypeError: images do not define a valid homomorphismjjWed, 17 Sep 2014 20:36:11 -0500http://ask.sagemath.org/question/24173/morphism between permutation group and matrix grouphttp://ask.sagemath.org/question/10860/morphism-between-permutation-group-and-matrix-group/I can't figure out how to create a morphism between a permutation group and a matrix group (I know this is possible because Sage uses Gap and Gap doesn't have any problem with this, I don't imagine Sage removed the Gap functionality).
sage: flip = PermutationGroupElement("(1,2)")
sage: g = PermutationGroup([flip])
sage: flop = Matrix(GF(3), 1, 1, [2])
sage: k = MatrixGroup([flop])
sage: g.order()
2
sage: k.order()
2
sage: g.hom([flop])
<snip useless error message>
sage: k.hom([flip])
<snip another useless error message>
How can I construct the homomorphisms from g to k and k to g sending flip to flop and vice versa? (Maybe the problem is that Sage thinks g and k are a "permutation group" and "matrix group" respectively: if so, how can I get the underlying groups?)Gro-TsenThu, 26 Dec 2013 12:06:55 -0600http://ask.sagemath.org/question/10860/RingMorphism defined by a python functionhttp://ask.sagemath.org/question/10795/ringmorphism-defined-by-a-python-function/Is there a way to define a `RingHomomorphism` object that calls a user defined function? I know this is possible for `SetMorphism`, but I can't find a way to do the same for rings.
My use case: I have a python (or cython) function defining an embedding of a (finite) field into another. Of course, I could evaluate it on the generators of the domain and create a `RingHomomorphism_im_gens` object, but my function is much faster to evaluate.
LucaMon, 02 Dec 2013 11:00:15 -0600http://ask.sagemath.org/question/10795/Group algebra/matrix space homomorphismhttp://ask.sagemath.org/question/10684/group-algebramatrix-space-homomorphism/I would like to know if it is possible to define a homomorphism (of algebras) between a group algebra over the rationals and a matrix space over the rationals.
I have
sage: S3 = SymmetricGroup(3)
sage: QG = GroupAlgebra(S3, QQ)
sage: QG.gens()
Finite family {(1,2,3): (1,2,3), (1,2): (1,2)}
sage: M_3 = MatrixSpace(QQ, 2)
sage: ma = M_3([[0,-1],[1,-1]])
sage: mb = M_3([[1,-1],[0,-1]])
Now I would like to map each generator of QG to a matrix. In this case I would like to map (1,2,3) to ma and (1,2) to mb and use that to define a homomorphism. But everything I tried didn't work.
Edit:
I've encountered another issue, though I can work around it. So this is only for information. The elements of `G.gens()` don't coincide with the reduced words of length 1.
sage: S3 = SymmetricGroup(3)
sage: S3.gens()
[(1,2,3), (1,2)]
sage: {g: g.reduced_word() for g in S3}
{(): [],
(2,3): [2],
(1,2): [1],
(1,2,3): [2, 1],
(1,3,2): [1, 2],
(1,3): [1, 2, 1]}
vuurFri, 01 Nov 2013 23:49:02 -0500http://ask.sagemath.org/question/10684/How are free group homomorphisms implemented?http://ask.sagemath.org/question/10647/how-are-free-group-homomorphisms-implemented/I see from the documentation that homomorphisms are implemented for matrix groups, symmetric groups, and abelian groups. I would assume that homomorphisms would be implemented for free groups, but I get an error if I do the following:
<blockquote>
<code><p>
sage: F.<a,b> = FreeGroup(2)<p>
sage: F.hom([a,b]) # Should be unique homomorphism with a |--> a, b |--> b <p>
TypeError Traceback (most recent call last)
...<p>
TypeError: Unable to coerce x (=[a, b]) to a morphism in Set of Morphisms from Free Group on generators {a, b} to Free Group on generators {a, b} in Category of groups
</code>
</blockquote>
Do I have the syntax wrong, or are these not implemented?glaunTue, 22 Oct 2013 18:11:52 -0500http://ask.sagemath.org/question/10647/Create Morphism's between Finite Fields and VectorSpaceshttp://ask.sagemath.org/question/10379/create-morphisms-between-finite-fields-and-vectorspaces/Hallo,
I am interested in creating morphims between $GF(2^{n+1}) \stackrel{h_1}{\longrightarrow} H_u \stackrel{h_2}\longrightarrow GF(2^n)$ where $H_u=\{x^{2^i} + x : x \in GF(2^{n+1})\}$ where $gcd(i,n+1) =1$. I am interested in constructing $h_1$ and $h_2$,
My attempt to create $h_1$ is:
<pre>
<code>
n = 4
i = 1
f = lambda x : x^(2^i) + x
Kn_1 = GF(2^(n+1),'x')
H_u = map(f, Kn_1)
hs = Hom(Kn_1,H_u)
pi = SetMorphism(Hom(Kn_1,Kn), lambda y : y^(2^i) + y)
pi(Kn_1.random_element()) in Kn
</code>
</pre>
now $hs$ is a set of morphism and $h_1 \in hs$. Can I get a (the) specific $h_1$ from $hs$? My attempt is $pi$ but 'pi(Kn_1.random_element()) in Kn' fails.
To construct $h_2$ I have more success.
<pre>
<code>
n = 4
i = 2
f = lambda x: x^(2^i) + x
Kn_1 = GF(2^(n+1),'x1')
Vn_1 = Kn_1.vector_space()
Sn_1 = Vn_1.subspace([Vn_1(f(u)) for u in Kn_1])
Kn = GF(2^n,'x')
Vn = Kn.vector_space()
h_a = Sn_1.basis_matrix().transpose()
</code>
</pre>
Now $h_a : Vn\rightarrow Sn_1$ where $Vn$ and $Sn_1$ is vector space representation of $GF(2^n)$ and $H_u$. To get from $GF(2^n)$ to $Vn$ and back I am good with But to create $h_2$ I have no luck. My attempts to use
<pre>
<code>
MatrixMorphism(Hom(Vn,Sn_1), Sn_1.basis_matrix().transpose())
</code>
</pre>
but get errors with regards to the dimensions of the matrix.
RegardsJohanTue, 23 Jul 2013 10:59:05 -0500http://ask.sagemath.org/question/10379/Birational Transformationhttp://ask.sagemath.org/question/10161/birational-transformation/How do I apply a birational transformation x --> 1/x, then clear the denominators. Is there a way I could do that in SAGE?
x, y = QQ['x,y'].gens()
C = Curve(x^2+y^2)
# the code I'm looking for here
$x^2 + y^2 \mapsto 1/x^2 + y^2 \mapsto 1/x^2 + x^2y^2/x^2 \mapsto 1 + x^2y^2$guissmoTue, 28 May 2013 05:16:57 -0500http://ask.sagemath.org/question/10161/Is applying a ring homomorphism faster than symbolic substitution?http://ask.sagemath.org/question/7921/is-applying-a-ring-homomorphism-faster-than-symbolic-substitution/I'm working on a project where I need to do composition of polynomials; something like
P(Q1 + Q2)
where `P`, `Q1`, and `Q2` are univariate polynomials with several hundred terms, and large integer coefficients (on the order of 10^10 or so). I've been doing this with the `.subs()` method which, I think, moves things to the symbolic ring and does the substitutions there. (I think this because when I get errors, they have to do with coercing to or from the symbolic ring.) But it occurred to me I could also define a ring homomorphism sending the variable of `P` to `Q1 + Q2`, and then apply the homomorphism to `P`.
So my question: will this be worth my while, or are the ring homomorphism methods too slow?
nilesSat, 05 Feb 2011 04:41:57 -0600http://ask.sagemath.org/question/7921/