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.Tue, 03 Mar 2020 05:17:15 -0600Problem with UniversalCyclotomicField?http://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 05:17:15 -0600http://ask.sagemath.org/question/50145/How to find partial sums of dedekind zeta function of any number field?http://ask.sagemath.org/question/50135/how-to-find-partial-sums-of-dedekind-zeta-function-of-any-number-field/ I searched for my question through internet but could not find a clear way to do it. So, how can I find partial sums of the value of the Dedekind zeta function of any number field?captainMon, 02 Mar 2020 05:58:56 -0600http://ask.sagemath.org/question/50135/quotient of algebraic integer ringshttp://ask.sagemath.org/question/48603/quotient-of-algebraic-integer-rings/This is my first time using sage so this might be a stupid question:
I want to construct the field $K=\mathbb{Q}(\sqrt{2}, \frac{-1+\sqrt{3}i}{2})=\mathbb{Q}(\alpha)$, where $\alpha$ is a primitive element. Denoting its ring of algebraic integers $\mathcal{O}_K$, I want to compute the quotient ring $\mathcal{O}_K/\mathbb{Z}[\alpha]$.
My code is like:
K.<d> = QQ.extension(x^2-2)
L.<w> = K.extension(x^2+x+1)
a = L.primitive_element()
O = L.ring_of_integers()
za = ZZ[a]
print O.quotient(za)
But I always get an error:
TypeError: unable to convert Relative Order in Number Field in w0 with defining polynomial x^2 + (2*d + 1)*x + d + 3 over its base field to Number Field in w with defining polynomial x^2 + x + 1 over its base field
Any help is appreciated. Thanks.
XipanXiaoSun, 03 Nov 2019 23:39:09 -0600http://ask.sagemath.org/question/48603/Plotting polynomials defined over a number fieldhttp://ask.sagemath.org/question/48557/plotting-polynomials-defined-over-a-number-field/I have an element of a polynomial ring over a number field K. It's a pretty benign number field -- I have just adjoined a square root of 3, called 't'.
I want to be able to plot the polynomial (specifically, it's a polynomial of two variables, and I want an implicit plot of where it vanishes). How do I get Sage to coerce 't' to a real number and draw the plot? Of course this should involve fixing an embedding of my number field into RR, but it's just a square root, so this shouldn't be hard.
For a minimal example:
var('w')
K.<t> = NumberField(w^2-3)
R = PolynomialRing(K,2,'x,y')
R.inject_variables()
f = y - t*x
implicit_plot(f,(x,-3,3),(y,-3,3))
It (quite understandably) chokes with "TypeError: Unable to coerce -t to a rational". I would like to coerce t to be the positive real square root of 3 and draw the plot.ConfusedMarkWed, 30 Oct 2019 10:50:29 -0500http://ask.sagemath.org/question/48557/Constructing a number field with complex embeddinghttp://ask.sagemath.org/question/47127/constructing-a-number-field-with-complex-embedding/ I am using the function `number_field_elements_from_algebraics` in `sage.rings.qqbar` to write some algebraic numbers as elements of a number field. I am passing `embedded=True` to also construct an embedding into `QQbar`. This works fine if the algebraic numbers are real but fails if they are complex:
<pre>
sage: number_field_elements_from_algebraics([1 + sqrt(7)], embedded=True)
(Number Field in a with defining polynomial y^2 - 7 with a = 2.645751311064591?,
[a + 1],
Ring morphism:
From: Number Field in a with defining polynomial y^2 - 7 with a = 2.645751311064591?
To: Algebraic Real Field
Defn: a |--> 2.645751311064591?)
</pre>
<pre>
sage: number_field_elements_from_algebraics([1 + sqrt(-7)], embedded=True)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-1-ac220615ad5b> in <module>()
----> 1 number_field_elements_from_algebraics([Integer(1) + sqrt(-Integer(7))], embedded=True)
/usr/lib/python2.7/site-packages/sage/rings/qqbar.pyc in number_field_elements_from_algebraics(
numbers, minimal, same_field, embedded, prec)
2242 real_case = False
2243 if embedded:
-> 2244 raise NotImplementedError
2245 # Make the numbers algebraic
2246 numbers = [mk_algebraic(_) for _ in numbers]
NotImplementedError:
</pre>
What is the reason for why only embeddings of real numbers are supported?
I modified the code in `number_field_elements_from_algebraics` to support complex embeddings by essentially removing the check for whether the numbers are real and replacing `RealIntervalField` by `ComplexIntervalField`. This seems to work and the doctests still pass with these modifications. However I am worried that there was a good reason (either mathematically or related to some sage internals) for restricting this function to the real case.
The relevant code in `sage.rings.qqbar` was introduced in these commits:
- `26dc3e4e6a26f6f613a69d57929ea492c278dad0`
- `a9045bf8a3aab2d0aa00be17e91227bc1b50262a`
mvkThu, 11 Jul 2019 16:31:13 -0500http://ask.sagemath.org/question/47127/Factoring modulo prime idealhttp://ask.sagemath.org/question/45803/factoring-modulo-prime-ideal/I would like to factor a polynomial with integer coefficients modulo the prime ideal generated by $1-\sqrt{-2}$ in $O_{K},$ where $K=\mathbb{Q}[\sqrt{-2}].$ How can I do this using Sage?MattiSun, 17 Mar 2019 06:42:53 -0500http://ask.sagemath.org/question/45803/Extended Sage exampleshttp://ask.sagemath.org/question/45091/extended-sage-examples/I'm trying to learn how to use Sage to do algebraic number theory. I've read the thematic tutorials that seem related, but they are pretty bare-bones. The documentation seems to be pretty much a list of methods; I haven't found a higher-level view of what concepts are implemented and how they can be used. Are there any meatier extended examples that are available? Or is there documentation that I'm missing? (So, for example, how would I go about finding in the documentation the answer to "is the square root of two in the field K that I just defined"?)rogerlThu, 17 Jan 2019 20:33:43 -0600http://ask.sagemath.org/question/45091/Coerce an algebraic into a number field that contains ithttp://ask.sagemath.org/question/40020/coerce-an-algebraic-into-a-number-field-that-contains-it/ Consider the following code
r = QQbar.polynomial_root(x^5-x-1,CIF(RIF(0.1, 0.2), RIF(1.0, 1.1))
F,_,_ = number_field_elements_from_algebraics(r)
F(r)
Even though r can be coerced into an element of F, this coercion doesn't happen. What is the right thing for me to do? I'm interested in computing an algebraic number field that will contain a bunch of eigenvalues and want to express all the eigenvalues as elements of the number field. I've done the obvious workaround but the limitation expressed in the sample above isn't great.watson_laddFri, 08 Dec 2017 13:51:20 -0600http://ask.sagemath.org/question/40020/Substituting a complex embedding for a number field elementhttp://ask.sagemath.org/question/40006/substituting-a-complex-embedding-for-a-number-field-element/Is there a way to take an element of a number field (or a polynomial or a number field) and replace the generator of the field by one of its complex embeddings? For example, something like
sage: K.<a> = NumberField(x^2 - 3)
sage: (3*a + 5).substitute(a=a.complex_embeddings()[1])
It's feasible to do this with `sage_eval`, but hopefully there is a better way.jaebondThu, 07 Dec 2017 23:34:33 -0600http://ask.sagemath.org/question/40006/Code error in sagemathhttp://ask.sagemath.org/question/36579/code-error-in-sagemath/ My code in sagemath
def bruteforce
count = 0
s = [0, 1, 2, 4, 8]
s.each do |a|
s.each do |b|
s.each do |c|
s.each do |d|
s.each do |e|
if a+b+c+d+e == 8
count += 1
puts "#{count}.: #{a}+#{b}+#{c}+#{d}+#{e}"
end
end
end
end
end
end
count
end
but it was an error as below
File "<ipython-input-1-87370adfacc9>", line 1
def brutefor
SyntaxError: invalid syntaxdavisSat, 11 Feb 2017 20:08:47 -0600http://ask.sagemath.org/question/36579/find square root of of an algebraic numberhttp://ask.sagemath.org/question/36038/find-square-root-of-of-an-algebraic-number/ I have an algebraic number `-4536*sqrt(33)+61128`. How can I find the root of this number using Sage?ShaSat, 17 Dec 2016 00:39:15 -0600http://ask.sagemath.org/question/36038/Computations with complex algebraic numbers?http://ask.sagemath.org/question/31857/computations-with-complex-algebraic-numbers/I am trying to perform some Newton-type computations: `z-p(z)/p'(z)` where `p(z)` is a polynomial over the field of algebraic numbers.
For example, this shows the sort of thing I'm trying to do:
p = (z^2+1)*(z^2+4)
q = p/(z-I)
pd = diff(p,z)
qd = diff(q,z)
sol = solve(qd=0,solution_dict='true')
a0 = sol[0][z]
b0 = a0-p.subs(z=a0)/pd.subs(z=a0)
However, this doesn't work because the expression `z-I` is not recognized as a factor of `p`. So I might try defining
`p` as a polynomial over the field `QQbar`:
R.<z> = PolynomialRing(QQbar)
p = (z^2+1)*(z^2+4)
q = p.quo_rem(z-I)[0]
pd = p.differentiate(z)
qd = q.differentiate(z)
The trouble now is that I can only seem to solve `qd` over `CC`: that is, in numerical form. Both the commands
qd.roots()
qd.factor()
produce numerical roots; I can't use `solve` on `qd` to obtain closed-form expressions for the roots. I've also tried the first method above prefaced with `z=QQbar['z'].0` but to no avail.
Is there some way of doing this entire computation over `QQbar`, that is, with exact complex numbers instead of numerical approximations?AlasdairSun, 27 Dec 2015 02:33:06 -0600http://ask.sagemath.org/question/31857/(1-i)^(1/3),(1-i)^(1/4) is algebra interger?http://ask.sagemath.org/question/10815/1-i131-i14-is-algebra-interger/I try http://www.wolframalpha.com/input/?i=Is+cbrt%281%2Bi%29+an+algebraic+integer%3F
answer:UNKNOW
but sagemath :true,why?which is right?
K.<a> = NumberField((x^3-1)^2+1);K;a.list();a.is_integral()
Number Field in a with defining polynomial x^6 - 2*x^3 + 2
[0, 1, 0, 0, 0, 0]
True
K.<a> = NumberField((x^4-1)^2+1);K;a.list();a.is_integral()
Number Field in a with defining polynomial x^8 - 2*x^4 + 2
[0, 1, 0, 0, 0, 0, 0, 0]
True
K.<a> = NumberField((x^5-1)^2+1);K;a.list();a.is_integral()
Number Field in a with defining polynomial x^10 - 2*x^5 + 2
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
TruecjshFri, 06 Dec 2013 19:56:42 -0600http://ask.sagemath.org/question/10815/Accuracy versus precision of algebraic number calculationshttp://ask.sagemath.org/question/10054/accuracy-versus-precision-of-algebraic-number-calculations/Hi everyone - another very basic question from me ...
I am doing some calculations of absolute norms of determinants of matrices whose entries come from cyclotomic fields. The (rational) numbers which are output are sensible but occasionally have massive prime numbers as factors which I was not expecting. My question is whether I can rely upon such numbers when they are output by SAGE's calculations inside a specified number field, or whether somewhere along the way some imprecision may have been introduced which results in a "distorted" prime number being a factor of the output.
Another stylized way of asking the same thing: is it possible that the answer to some question involving a small prime p might actually contain a factor of p^100, but nevertheless because of accumulated rounding errors etc I have ended up with p^100-2 which happens to be prime? Or does SAGE "know" only to output perfect answers involving algebraic number fields, even when the heights involved are that big?
Many thanksGaryMakTue, 23 Apr 2013 00:27:41 -0500http://ask.sagemath.org/question/10054/