Local Generic Element
This file contains a common superclass for -adic elements and power
series elements.
AUTHORS:
Bases: sage.structure.element.CommutativeRingElement
INPUT:
Returns self to reduced precision prec.
Return the degree of this element as an element of a euclidean domain.
EXAMPLES:
For a field, this is always zero except for the zero element:
sage: K = Qp(2)
sage: K.one().euclidean_degree()
0
sage: K.gen().euclidean_degree()
0
sage: K.zero().euclidean_degree()
Traceback (most recent call last):
...
ValueError: euclidean degree not defined for the zero element
For a ring which is not a field, this is the valuation of the element:
sage: R = Zp(2)
sage: R.one().euclidean_degree()
0
sage: R.gen().euclidean_degree()
1
sage: R.zero().euclidean_degree()
Traceback (most recent call last):
...
ValueError: euclidean degree not defined for the zero element
Returns the inverse of self if self is a unit.
OUTPUT:
- an element in the same ring as self
EXAMPLES:
sage: R = ZpCA(3,5)
sage: a = R(2); a
2 + O(3^5)
sage: b = a.inverse_of_unit(); b
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
A ZeroDivisionError is raised if an element has no inverse in the ring:
sage: R(3).inverse_of_unit()
Traceback (most recent call last):
...
ZeroDivisionError: Inverse does not exist.
Unlike the usual inverse of an element, the result is in the same ring as self and not just in its fraction field:
sage: c = ~a; c
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
sage: a.parent()
3-adic Ring with capped absolute precision 5
sage: b.parent()
3-adic Ring with capped absolute precision 5
sage: c.parent()
3-adic Field with capped relative precision 5
For fields this does of course not make any difference:
sage: R = QpCR(3,5)
sage: a = R(2)
sage: b = a.inverse_of_unit()
sage: c = ~a
sage: a.parent()
3-adic Field with capped relative precision 5
sage: b.parent()
3-adic Field with capped relative precision 5
sage: c.parent()
3-adic Field with capped relative precision 5
TESTS:
Test that this works for all kinds of p-adic base elements:
sage: ZpCA(3,5)(2).inverse_of_unit()
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
sage: ZpCR(3,5)(2).inverse_of_unit()
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
sage: ZpFM(3,5)(2).inverse_of_unit()
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
sage: QpCR(3,5)(2).inverse_of_unit()
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
Over unramified extensions:
sage: R = ZpCA(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 + 1 )
sage: t.inverse_of_unit()
2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5)
sage: R = ZpCR(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 + 1 )
sage: t.inverse_of_unit()
2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5)
sage: R = ZpFM(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 + 1 )
sage: t.inverse_of_unit()
2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5)
sage: R = QpCR(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 + 1 )
sage: t.inverse_of_unit()
2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5)
Over Eisenstein extensions:
sage: R = ZpCA(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 - 3 )
sage: (t - 1).inverse_of_unit()
2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + O(t^8)
sage: R = ZpCR(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 - 3 )
sage: (t - 1).inverse_of_unit()
2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)
sage: R = ZpFM(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 - 3 )
sage: (t - 1).inverse_of_unit()
2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)
sage: R = QpCR(3,5); S.<t> = R[]; W.<t> = R.extension( t^2 - 3 )
sage: (t - 1).inverse_of_unit()
2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)
Returns whether self is an integral element.
INPUT:
OUTPUT:
EXAMPLES:
sage: R = Qp(3,20)
sage: a = R(7/3); a.is_integral()
False
sage: b = R(7/5); b.is_integral()
True
Returns whether self is a -adic unit. That is, whether it has zero valuation.
INPUT:
OUTPUT:
EXAMPLES:
sage: R = Zp(3,20,'capped-rel'); K = Qp(3,20,'capped-rel')
sage: R(0).is_padic_unit()
False
sage: R(1).is_padic_unit()
True
sage: R(2).is_padic_unit()
True
sage: R(3).is_padic_unit()
False
sage: Qp(5,5)(5).is_padic_unit()
False
TESTS:
sage: R(4).is_padic_unit()
True
sage: R(6).is_padic_unit()
False
sage: R(9).is_padic_unit()
False
sage: K(0).is_padic_unit()
False
sage: K(1).is_padic_unit()
True
sage: K(2).is_padic_unit()
True
sage: K(3).is_padic_unit()
False
sage: K(4).is_padic_unit()
True
sage: K(6).is_padic_unit()
False
sage: K(9).is_padic_unit()
False
sage: K(1/3).is_padic_unit()
False
sage: K(1/9).is_padic_unit()
False
sage: Qq(3^2,5,names='a')(3).is_padic_unit()
False
Returns whether self is a unit
INPUT:
OUTPUT:
NOTES:
For fields all nonzero elements are units. For DVR’s, only those elements of valuation 0 are. An older implementation ignored the case of fields, and returned always the negation of self.valuation()==0. This behavior is now supported with self.is_padic_unit().
EXAMPLES:
sage: R = Zp(3,20,'capped-rel'); K = Qp(3,20,'capped-rel')
sage: R(0).is_unit()
False
sage: R(1).is_unit()
True
sage: R(2).is_unit()
True
sage: R(3).is_unit()
False
sage: Qp(5,5)(5).is_unit() # Note that 5 is invertible in `QQ_5`, even if it has positive valuation!
True
sage: Qp(5,5)(5).is_padic_unit()
False
TESTS:
sage: R(4).is_unit()
True
sage: R(6).is_unit()
False
sage: R(9).is_unit()
False
sage: K(0).is_unit()
False
sage: K(1).is_unit()
True
sage: K(2).is_unit()
True
sage: K(3).is_unit()
True
sage: K(4).is_unit()
True
sage: K(6).is_unit()
True
sage: K(9).is_unit()
True
sage: K(1/3).is_unit()
True
sage: K(1/9).is_unit()
True
sage: Qq(3^2,5,names='a')(3).is_unit()
True
sage: R(0,0).is_unit()
False
sage: K(0,0).is_unit()
False
Returns the normalized valuation of this local ring element, i.e., the valuation divided by the absolute ramification index.
INPUT:
self – a local ring element.
OUTPUT:
rational – the normalized valuation of self.
EXAMPLES:
sage: Q7 = Qp(7)
sage: R.<x> = Q7[]
sage: F.<z> = Q7.ext(x^3+7*x+7)
sage: z.normalized_valuation()
1/3
Return the quotient with remainder of the division of this element by other.
INPUT:
EXAMPLES:
sage: R = Zp(3, 5)
sage: R(12).quo_rem(R(2))
(2*3 + O(3^6), 0)
sage: R(2).quo_rem(R(12))
(0, 2 + O(3^5))
sage: K = Qp(3, 5)
sage: K(12).quo_rem(K(2))
(2*3 + O(3^6), 0)
sage: K(2).quo_rem(K(12))
(2*3^-1 + 1 + 3 + 3^2 + 3^3 + O(3^4), 0)
Returns the sum of the terms of the series
expansion of this element, for
between i and
j-1 inclusive, and nonnegative integers
. Behaves analogously to
the slice function for lists.
INPUT:
EXAMPLES:
sage: R = Zp(5, 6, 'capped-rel')
sage: a = R(1/2); a
3 + 2*5 + 2*5^2 + 2*5^3 + 2*5^4 + 2*5^5 + O(5^6)
sage: a.slice(2, 4)
2*5^2 + 2*5^3 + O(5^4)
sage: a.slice(1, 6, 2)
2*5 + 2*5^3 + 2*5^5 + O(5^6)
The step size k has to be positive:
sage: a.slice(0, 3, 0)
Traceback (most recent call last):
...
ValueError: slice step must be positive
sage: a.slice(0, 3, -1)
Traceback (most recent call last):
...
ValueError: slice step must be positive
If i exceeds j, then the result will be zero, with the precision given by j:
sage: a.slice(5, 4)
O(5^4)
sage: a.slice(6, 5)
O(5^5)
However, the precision can not exceed the precision of the element:
sage: a.slice(101,100)
O(5^6)
sage: a.slice(0,5,2)
3 + 2*5^2 + 2*5^4 + O(5^5)
sage: a.slice(0,6,2)
3 + 2*5^2 + 2*5^4 + O(5^6)
sage: a.slice(0,7,2)
3 + 2*5^2 + 2*5^4 + O(5^6)
If start is left blank, it is set to the valuation:
sage: K = Qp(5, 6)
sage: x = K(1/25 + 5); x
5^-2 + 5 + O(5^4)
sage: x.slice(None, 3)
5^-2 + 5 + O(5^3)
sage: x[:3]
5^-2 + 5 + O(5^3)
TESTS:
Test that slices also work over fields:
sage: a = K(1/25); a
5^-2 + O(5^4)
sage: b = K(25); b
5^2 + O(5^8)
sage: a.slice(2, 4)
O(5^4)
sage: b.slice(2, 4)
5^2 + O(5^4)
sage: a.slice(-3, -1)
5^-2 + O(5^-1)
sage: b.slice(-1, 1)
O(5)
sage: b.slice(-3, -1)
O(5^-1)
sage: b.slice(101, 100)
O(5^8)
sage: b.slice(0,7,2)
5^2 + O(5^7)
sage: b.slice(0,8,2)
5^2 + O(5^8)
sage: b.slice(0,9,2)
5^2 + O(5^8)
Verify that trac ticket #14106 has been fixed:
sage: R = Zp(5,7)
sage: a = R(300)
sage: a
2*5^2 + 2*5^3 + O(5^9)
sage: a[:5]
2*5^2 + 2*5^3 + O(5^5)
sage: a.slice(None, 5, None)
2*5^2 + 2*5^3 + O(5^5)
TODO: document what “extend” and “all” do
INPUT:
OUTPUT:
EXAMPLES:
sage: R = Zp(13, 10, 'capped-rel', 'series')
sage: a = sqrt(R(-1)); a * a
12 + 12*13 + 12*13^2 + 12*13^3 + 12*13^4 + 12*13^5 + 12*13^6 + 12*13^7 + 12*13^8 + 12*13^9 + O(13^10)
sage: sqrt(R(4))
2 + O(13^10)
sage: sqrt(R(4/9)) * 3
2 + O(13^10)