# saraedum's profile - activity

2021-04-12 23:18:09 +0200 commented answer Power Series Ring over p-adics: TypeError: unhashable

Implementing _cache_key does not help here unfortunately. polynomial_ring_constructor.py uses an (old?) cache that does

2021-04-12 23:07:02 +0200 answered a question Power Series Ring over p-adics: TypeError: unhashable

In this case there is a specialized type for this p-adic base field which is called a "relative extension" in SageMath,

2021-03-03 23:17:41 +0200 answered a question Extension field over p-adics: how to write an element in the standard basis?

It seems you are looking for the terse printing mode: sage: K = Qp(2, print_mode='terse') sage: R.<x> = K[] sage:

2021-01-22 00:14:55 +0200 answered a question How can I compute a fixed field over the p-adics

SageMath does not yet support general extensions of p-adics yet unfortunately, it's something that we're actively working on, e.g., at https://trac.sagemath.org/ticket/28466. If you want to get involved a bit, please join us at https://sagemath.zulipchat.com/#narro....

There's a package that builds on SageMath to provide some Henselizations here that might work for such problems since it can compute in towers of fields and provides valuations. I am not sure how well that package currently works, but please let us know in the above zulip chat if you find it useful or have suggestions. Anyway, the following works on this binder with this package installed…

from henselization import *

K = QQ.henselization(3)
R.<x> = K[]
F.<ξ> = K.extension(x^4 + x^3 + x^2 + x + 1)
# Extension defined by ξ^4 + ξ^3 + ξ^2 + ξ + 1 of Henselization of Rational Field with respect to 3-adic valuation

R.<x> = F[]
f = x^4 - 3*x^2 + 18
LF.<α> = F.extension(f.factor()[0][0])
# Extension defined by α^2 + O(x^(3/4))*α + 3*ξ^3 + 3*ξ^2 + O(x^(3/4)) of Extension defined by ξ^4 + ξ^3 + ξ^2 + ξ + 1 of Henselization of Rational Field with respect to 3-adic valuation

R.<x> = LF[]
# We need to pass to approximations so we can perform arithmetic.
# Unfortunately, we cannot say ξ = ξ.approximation(20) directly. :(
ξ = -(x^4 + x^3 + x^2 + x + 1).factor()[0][0][0].approximation(20)
α = -(x^4 - 3*x^2 + 18).factor()[0][0][0].approximation(20)
basis = [ξ^i*α^j for i in range(4) for j in range(2)]

R.<x> = LF[]
# Note that if you change the first 0 to a 1, you get a different result.
sqrt27 = -((x^2 + 2/7).factor()[0][0][0].approximation(20))

# Write φ in terms of the basis given by ξ and α.
φα = (2*α^2 - 3)* sqrt27 / α
φξ = ξ^3
image = [φξ^i*φα^j for i in range(4) for j in range(2)]

# We write sqrt(3) in terms of that basis
sqrt3 = -(x^2 - 3).factor()[0][0][0].approximation(20)
A = matrix([b._vector_(base=K) for b in basis])
coefficients = A.transpose().solve_right(sqrt3._vector_(base=K))

# Map sqrt(3) through φ
φsqrt3 = sum([b * c for (b, c) in zip(image, coefficients)])
(φsqrt3 - sqrt3).valuation() # big number

# We write sqrt(-3) in terms of that basis
sqrt_3 = -(x^2 + 3).factor()[0][0][0].approximation(20)
A = matrix([b._vector_(base=K) for b in basis])
coefficients = A.transpose().solve_right(sqrt3._vector_(base=K))

φsqrt_3 = sum([b * c for (b, c) in zip(image, coefficients)])
(φsqrt_3 - sqrt_3).valuation() # small number


So, the answer is $\sqrt{3}$ since $\varphi(\sqrt{3}) - \sqrt{3}$ has "infinite" valuation but $\varphi(\sqrt{-3}) - \sqrt{-3}$ has valuation 1/2 or so. However, this depends on the choice of $\sqrt{\frac{-2}{7}}$. Choosing the other root, gives $\sqrt{-3}$.

2019-11-07 18:37:57 +0200 answered a question possible bug in: _cmp_ function

Ordering of p-adics is not terribly meaningful of course but it should at least be consistent. So I think this is a bug.

If I understood things correctly, the code that eventually runs is:

    mpz_sub(holder.value, a, b)
mpz_mod(holder.value, holder.value, prime_pow.pow_mpz_t_tmp(prec))
return mpz_sgn(holder.value)


The problem here is that mpz_mod is always non-negative so mpz_sgn never returns -1.

I created https://trac.sagemath.org/ticket/2870... to track this issue.

2018-10-27 02:44:46 +0200 answered a question i want to find factorization ideal (3) in integral closure of Z_3 in Q_3(sqrt(2),sqrt(3))

It's a bit unclear what you want to achieve in general. But for the first part of your question, since https://trac.sagemath.org/ticket/23218 we have more general extensions of p-adic rings. So with Sage 8.4 you can do

sage: K.<a> = Zq(9)
sage: R.<x> = K[]
sage: L.<b> = K.extension(x^2 - 3)


In general you can create a ramified extension of an unramified extension, so if you can transform your field into this form, you can create the corresponding ring. I am not sure what you are trying to achieve in general, as of course, once you have it in this form, the question how the prime factors is trivial. Explicitly, you can then also do:

sage: L.ideal(3)
Principal ideal (b^2 + O(b^42)) of 3-adic Eisenstein Extension Ring in b defined by x^2 - 3 over its base ring


Number fields probably provide the most convenient path to currently answer this question, if you're only looking at small examples where performance does not matter:

sage: R.<x> = QQ[]
sage: K.<a> = NumberField(x^2 - 2)
sage: L.<b> = K.extension(x^2 - 3)
sage: L.ideal(3).factor()
(Fractional ideal (b))^2


If you don't mind the language of valuations, you could try with the following which might avoid some expensive calls:

sage: QQ.valuation(3).extensions(L)
sage: v = _[0]
sage: v.value_group()
Additive Abelian Group generated by 1/2


Finally, there is also the henselization package which allows you to work with Henselizations instead of $Q_p$ which you can also use to compute such factorizations:

sage: from henselization import *
sage: K = QQ.henselization(3)
sage: R.<x> = K[]
sage: L.<a> = K.extension(x^2 - 3)
sage: R.<x> = L[]
sage: M.<b> = L.extension(x^2 - 2)
sage: v = M.valuation()
sage: v.value_group()
Additive Abelian Group generated by 1/2

2018-10-24 12:25:33 +0200 answered a question Cannot get threejs rendering to work on MacOS

### Three.js in conda-forge

The ImportError: cannot import name 'THREEJS_DIR'is happening in conda-forge because there is no three.js packaged in conda yet. You could open an issue at https://github.com/conda-forge/sage-f... so we can work on a fix.

### No browser is launched

I don't know why you don't get any visible output with online=True. This seems like something is broken in your local setup. Somewhere in your .sage directory (probably ~/.sage/temp) there should be an HTML file that you could open manually in your browser in the meantime.

To debug what's going on, you could try to run something like

sage: _system = os.system
sage: def system(*args, **kwargs):
....:     print(args, kwargs)
....:     _system(*args, **kwargs)
....:
sage: os.system = system
sage: P.show(viewer='threejs', online=True)


You should then see the command that sage is trying to run.

### Python3 errors

You should probably open a ticket at trac.sagemath.org about this (after checking that no such ticket exists yet.) Python3 support in Sage is very experimental.

2014-01-30 13:39:59 +0200 commented question Sage course in Colombia

What do you mean by "teach a course"? Just for one or a few days or do you think of a course which spans a semester? Do you have any specific dates in mind?