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, 04 Nov 2018 15:45:21 +0100Reduce non-integral element mod idealhttps://ask.sagemath.org/question/44180/reduce-non-integral-element-mod-ideal/Suppose I have a nonzero ideal $I$ in a number field $K$, and an element $x \in K$ whose denominator ideal $\\{ \alpha \in O_K: \alpha x \in O_K\\}$ is coprime to $I$. Then x defines an element of $O_K / I$, even if $x \notin O_K$.
> How can I *efficiently* find an
> element $x' \in O_K$ which represents
> the same class in $O_K / I$ as $x$?
The first things I tried were `x % I`, `I.reduce(x)` and `I.small_residue(x)`, but these all either fail or return non-useful output if x isn't integral:
<pre>
sage: K.<a> = QuadraticField(10).objgen()
sage: I = K.ideal(3, a + 1)
sage: x = (1 - 2*a)/3
sage: x % I
[...]
TypeError: unsupported operand parent(s) for %
sage: I.reduce(x)
[...]
TypeError: reduce only defined for integral elements
sage: I.small_residue(x)
1/3*a + 4/3
</pre>
The only one-liner I could come up with was
<pre>
sage: I.reduce( x * x.denominator_ideal().element_1_mod(I) )
-a
</pre>
which works, but is a bit clumsy. Is there a simpler, cleaner Sage idiom for this?Sun, 04 Nov 2018 15:45:21 +0100https://ask.sagemath.org/question/44180/reduce-non-integral-element-mod-ideal/