ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 29 Aug 2021 05:02:37 +0200support() and coefficients() in combinatorial free moduleshttps://ask.sagemath.org/question/58724/support-and-coefficients-in-combinatorial-free-modules/I was surprised that in the code below I could not count on the lists returned by support() and coefficients() to correspond. Is there a proper way to use these methods in conjunction with each other, or should I adopt a different approach? If I sort the list returned by support() will I be able to count on the coefficients corresponding with generators?
k3.<w3> = CyclotomicField(3)
F3 = CombinatorialFreeModule(k3,NN,prefix='v3')
v3 = F3.basis()
v3
> Lazy family (Term map from Non negative integer semiring to Free module generated by Non negative integer semiring over Cyclotomic Field of order 3 and degree 2(i))_{i in Non negative integer semiring}
expr = -2*v3[34] - (-2*w3)*v3[42] - 2*v3[58] - (2*w3+2)*v3[66]
[expr.support(),expr.coefficients()]
> [[34, 42, 66, 58], [-2, 2*w3, -2, -2*w3 - 2]]
Perhaps I should ask my real question, while I'm here. I have a list of module elements (actually vectors) and would like to find the kernel of the matrix with these vectors as rows. The matrix is likely to be sparse. I encountered the issue described above while trying to set up the matrix by hand from the list of vectors.
**Added:** The suggestion of John Palmieri in a comment and of tmonteil in an answer to use expr.monomial_coefficients() solves my problem, but I think it still worth trying to pin down the answer to the original question.
The documentation for support() says
> Return a list of the objects indexing the basis of "self.parent()"
whose corresponding coefficients of "self" are non-zero.
>
> This method returns these objects in an arbitrary order.
The documentation for coefficients() says
> Return a list of the (non-zero) coefficients appearing on the basis elements in "self" (in an arbitrary order).
>
> INPUT:
>
> * "sort" -- (default: "True") to sort the coefficients based upon the default ordering of the indexing set
Both mention that elements are returned "in an arbitrary order". Since it is not specified that the arbitrary order returned by the two functions is the same, one must assume the orders could be different. I wonder, however, whether they are intended to be the same since it is difficult to imagine many uses for a function that returns coefficients without making it possible to determine what they are coefficients of.
The other striking thing is that coefficients() actually doesn't default to the behavior described in the first line of the documentation: it defaults to "sort=True" which causes the coefficients to be returned in an order corresponding to the sorted order of the elements of the support, and not an arbitrary order. Since support() has no "sort" option, the only option is the "arbitrary" order. I strongly suspect that if one turns off the default option in coefficients() by setting "sort=False", one will get an arbitrary order that corresponds to that of support(), but, if true, it would be nice to have that documented somewhere.Will OrrickSun, 29 Aug 2021 05:02:37 +0200https://ask.sagemath.org/question/58724/Computing the ideal below in a cyclotomic fieldhttps://ask.sagemath.org/question/57601/computing-the-ideal-below-in-a-cyclotomic-field/ I have a cyclotomic field L, and I define K as a decomposition field for an ideal (non prime) I of OL. ( I made the decomposition field function ). I know that K is a subfield of L, but it just considers it as an extension of Q. I would like to calculate the intersection of I and OK or of I and K, which is supposed to be the ideal below I in K. I've tried the "intersection" function, but it doesn't work because they don't consider OK as an L-ideal. I've also tried the ideal_below function, but it tells me that a NumberFieldFractionalIdeal does not have the method.
Thank you for your help.rerouilleThu, 17 Jun 2021 10:51:01 +0200https://ask.sagemath.org/question/57601/Factoring a cyclotomic polynomial mod phttps://ask.sagemath.org/question/57099/factoring-a-cyclotomic-polynomial-mod-p/ How can I factor a cyclotomic polynomial into polynomials that are irreducible modulo p?
dtoprakhisarThu, 13 May 2021 10:18:22 +0200https://ask.sagemath.org/question/57099/tensor_product of matrices over cyclotomic fieldhttps://ask.sagemath.org/question/54762/tensor_product-of-matrices-over-cyclotomic-field/Beginner question: I have created some matrices over a cyclotomic field and attempted to compute some of their tensor products:
N = 3
k.<w> = CyclotomicField(N)
Z = diagonal_matrix(k,N,[w^j for j in range(0,N)])
X = matrix(k,N,N,[1 if (i%N - floor(i/N)) % N == N-1 else 0 for i in range(0,N*N)])
I = identity_matrix(k,N)
I.tensor_product(X)
X.tensor_product(I)
Z.tensor_product(I)
Z.tensor_product(X)
#I.tensor_product(Z)
#X.tensor_product(Z)
If I uncomment either of the last two lines I get
> AttributeError: 'sage.matrix.matrix_generic_sparse.Matrix_generic_sparse' object has no attribute '_rational_matrix'
It seems my code is working when both matrices in the tensor product are rational or when self is non-rational, but not when self is rational and the argument is non-rational. Should I be somehow instructing sagemath to regard self as a matrix over the cyclotomic field?Will OrrickSat, 19 Dec 2020 20:38:38 +0100https://ask.sagemath.org/question/54762/How to Compute $\operatorname{Pic}(\mathbb{Z}[\zeta_p,1/p])$https://ask.sagemath.org/question/50467/how-to-compute-operatornamepicmathbbzzeta_p1p/Consider the extension $\mathbb{Q}(\zeta_p)/\mathbb{Q}$, where $\zeta_p$ is a primitive $p^{\text{th}}$ root of unity (and $p$ is a prime number). Form the ring of integers $\mathbb{Z}[\zeta_p]$. Now, invert the prime $p$, to obtain the ring $R=\mathbb{Z}[\zeta_p,1/p]$. I want to compute $\operatorname{Pic}(R)$.
Is this possible to do using sagemath? If so, how? How do I construct the ring $R$ using sagemath?JoelThu, 02 Apr 2020 17:08:04 +0200https://ask.sagemath.org/question/50467/Problem with UniversalCyclotomicField?https://ask.sagemath.org/question/50145/problem-with-universalcyclotomicfield/Consider `L=[[0, 1, 0], [1, 0, 1], [0, 1, 1]]` and `M=matrix(CyclotomicField(7),L)`, then:
sage: M.eigenvalues()
[-zeta7^4 - zeta7^3, zeta7^5 + zeta7^4 + zeta7^3 + zeta7^2 + 1, -zeta7^5 - zeta7^2]
Now by taking `N=matrix(UniversalCyclotomicField(),L)` I **expected** the following:
sage: N.eigenvalues()
[-E(7)^4 - E(7)^3, E(7)^5 + E(7)^4 + E(7)^3 + E(7)^2 + 1, -E(7)^5 - E(7)^2]
but I got the following error message:
sage: N.eigenvalues()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-49-ae504b86ebb7> in <module>()
----> 1 T.eigenvalues()
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/matrix/matrix2.pyx in sage.matrix.matrix2.Matrix.eigenvalues (build/cythonized/sage/matrix/matrix2.c:44161)()
6000
6001 res = []
-> 6002 for f, e in self.charpoly().change_ring(K).factor():
6003 if f.degree() == 1:
6004 res.extend([-f.constant_coefficient()]*e)
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/rings/polynomial/polynomial_element.pyx in sage.rings.polynomial.polynomial_element.Polynomial.factor (build/cythonized/sage/rings/polynomial/polynomial_element.c:35771)()
4331 R = self._parent.base_ring()
4332 if hasattr(R, '_factor_univariate_polynomial'):
-> 4333 return R._factor_univariate_polynomial(self, **kwargs)
4334
4335 G = None
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/rings/universal_cyclotomic_field.py in _factor_univariate_polynomial(self, f)
1682 m = p.is_cyclotomic(certificate=True)
1683 if not m:
-> 1684 raise NotImplementedError('no known factorization for this polynomial')
1685 for i in range(1, m):
1686 if gcd(m, i) == 1:
NotImplementedError: no known factorization for this polynomial
Sébastien PalcouxTue, 03 Mar 2020 12:17:15 +0100https://ask.sagemath.org/question/50145/Killed Process Meaning?https://ask.sagemath.org/question/42708/killed-process-meaning/ I tried computing this -
sage : K = CyclotomicField(37^5)
But after almost a minute, the process just popped up "Killed" and automatically exited sage session.
Why does that happen and what is the meaning?
Is there any alternative way to do this? mathjainThu, 21 Jun 2018 15:54:57 +0200https://ask.sagemath.org/question/42708/how to find minimal polynomialhttps://ask.sagemath.org/question/34412/how-to-find-minimal-polynomial/How to find the minimal polynomial of an element ? Let $\zeta_n$ be a primitive $n$-th root of unity. I want to find the minimal polynomial of $\zeta_n$ over $\mathbb{Q}(\zeta_n+\zeta_{n}^{-1})$. How do I do that ?nebuckandazzerWed, 10 Aug 2016 19:45:47 +0200https://ask.sagemath.org/question/34412/Evaluating discriminant of a polynomial in Z_n[x]/<x^r-1>https://ask.sagemath.org/question/33879/evaluating-discriminant-of-a-polynomial-in-z_nxxr-1/Consider the following code
Zn=Zmod(n)
R = PolynomialRing(Zn,'x')
F = R.quotient((x**r)-1)
y=F((x+1))
f=F(y**n)
Clearly **f** will be a polynomial in xbar , I want to consider this polynomial as a polynomial in $ \mathbb{Z}[x] $ and evaluate its discriminant.
I tried **"f.polynomial()"** but it is not working. Any suggestions ? vishbWed, 22 Jun 2016 08:10:18 +0200https://ask.sagemath.org/question/33879/Taking gcd with respect to one variablehttps://ask.sagemath.org/question/33734/taking-gcd-with-respect-to-one-variable/ I want to compute $$ gcd_{X}((X-y)^2 -a , X^{\frac{q-1}{2}}-1)$$ with respect to X(taking y as a field constant).
I can't see any direct implementation of this in sage. Can any one suggest how to implement it.
Here Arithmetic is over $GF(p)$ and y is root of cyclotomic polynomial of degree r over $GF(p)$ and $q = p^r$vishbFri, 10 Jun 2016 14:17:30 +0200https://ask.sagemath.org/question/33734/How make Kummer extensionshttps://ask.sagemath.org/question/33553/how-make-kummer-extensions/ I want to calculate the relative discriminant of field extensions of this kind:
$$\mathbb{Q}(\zeta_5)(\sqrt[5]{a})$$
Where $a \in \mathbb{Q}(\zeta_5)$. So I use SAGE and make this calculations:
K.<b>=CyclotomicField(5); //my field base
alpha=1+3*b^2; //an element of my field base
f=(1+3*b^2).minpoly(); //its minimal polynomial
f.is_irreducible() //is it irreducible?
R.<a>=K.extension(f) //the field extension of my field base
R.relative_discriminant() //the calculation of the relative discriminant
But when I execute it, appears this error
defining polynomial (x^4 - x^3 + 6*x^2 + 14*x + 61) must be irreducible
But it is irreducible, what am I doing wrong? Or how can I solve this?belvedereThu, 26 May 2016 15:10:12 +0200https://ask.sagemath.org/question/33553/variable assumptionhttps://ask.sagemath.org/question/33126/variable-assumption/I have an expression in term of an independent variable $q$. Now, I would like to assume that $q$ is an arbitrary $14$-th root of unity (i.e. $q^{14}=1$).
It is not allow to evaluate in any primitive root of unity, say $\eta$, since the coefficients of my expression are in the $7$-th cyclotomic field (i.e. the field is generated by $\xi=e^{2\pi i/7}$), so $\eta$ is in the field.
I also tried with "assume(q^14==1)", but it didn't work.
How can I do?
**Added after Bruno's comment**: Here is an example. I have the expression
exp=q^16*xi^5 + (q^325-12*q^235)*xi^2.
where q is an independent variable and xi is the 7th-root of unity with least argument. In other words, I have an expression in terms of an independent variable q with coefficients in the 7-th cyclotomic field
K.<xi> = CyclotomicField(7)
Now, I want to assume that $q^{14}=1$, thus the resultant expression should be
q^2*xi^5 + (q^3-12*q^11)*xi^2
since $16\equiv 2\pmod {14}$, $325 \equiv 3\pmod {14}$ and $235\equiv 11\pmod {14}$.
How can I do that? Note that it is not sufficient to evaluate the expression in $q=$some primitive $14$-th root of unity, since $q$ can be $+1$ or $-1$.
Please, think that the expression have thousands of terms, so I cannot do it by hand as above.
emiliocbaSat, 16 Apr 2016 01:49:39 +0200https://ask.sagemath.org/question/33126/is the class field a kind of field(group,ring,feild)?https://ask.sagemath.org/question/8068/is-the-class-field-a-kind-of-fieldgroupringfeild/is the class field a kind of field(group,ring,feild)?
if it is,finite field or unfinite field?cjshThu, 26 Dec 2013 00:01:36 +0100https://ask.sagemath.org/question/8068/how to run CyclotomicField([zeta7+zeta7^-1]?https://ask.sagemath.org/question/10813/how-to-run-cyclotomicfieldzeta7zeta7-1/ - LL.<x>=CyclotomicField(7);LL
Cyclotomic Field of order 7 and
degree 6
x.conjugate()
-x^5 - x^4 - x^3 - x^2 - x - 1
LL.<c>=CyclotomicField(-x^5 - x^4 - x^3 - x^2 - 1);LL
Traceback (click to the left of this block for traceback)
...
TypeError: Unable to
coerce -x^5 - x^4 - x^3 - x^2 - 1 to
an integer
s=LL.gen() + (LL.gen()).conjugate();s
LL.<y>=CyclotomicField(s);LL
Traceback (click to the left of this
block for traceback) ... TypeError:
Unable to coerce -x^5 - x^4 - x^3 -
x^2 - 1 to an integer
KK.<s> = NumberField(-x^5 - x^4 - x^3 - x^2 - 1); KK
Traceback (click to the left of this block for traceback)
... NotImplementedError: number
fields for non-monic polynomials not
yet implemented.
KKK.<s> = NumberField(x^5 + x^4 + x^3 + x^2 + 1); KKK
Number Field in s with defining polynomial x^5 + x^4 +
x^3 + x^2 + 1
KKK is same with Q[zeta7+zeta7^-1]?cjshSat, 07 Dec 2013 02:34:12 +0100https://ask.sagemath.org/question/10813/