本文整理汇总了Python中sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing.zero方法的典型用法代码示例。如果您正苦于以下问题:Python LaurentPolynomialRing.zero方法的具体用法?Python LaurentPolynomialRing.zero怎么用?Python LaurentPolynomialRing.zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing
的用法示例。
在下文中一共展示了LaurentPolynomialRing.zero方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: q_int
# 需要导入模块: from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing import zero [as 别名]
def q_int(n, q=None):
r"""
Return the `q`-analog of the nonnegative integer `n`.
The `q`-analog of the nonnegative integer `n` is given by
.. MATH::
[n]_q = \frac{q^n - q^{-n}}{q - q^{-1}}
= q^{n-1} + q^{n-3} + \cdots + q^{-n+3} + q^{-n+1}.
INPUT:
- ``n`` -- the nonnegative integer `n` defined above
- ``q`` -- (default: `q \in \ZZ[q, q^{-1}]`) the parameter `q`
(should be invertible)
If ``q`` is unspecified, then it defaults to using the generator `q`
for a Laurent polynomial ring over the integers.
.. NOTE::
This is not the "usual" `q`-analog of `n` (or `q`-integer) but
a variant useful for quantum groups. For the version used in
combinatorics, see :mod:`sage.combinat.q_analogues`.
EXAMPLES::
sage: from sage.algebras.quantum_groups.q_numbers import q_int
sage: q_int(2)
q^-1 + q
sage: q_int(3)
q^-2 + 1 + q^2
sage: q_int(5)
q^-4 + q^-2 + 1 + q^2 + q^4
sage: q_int(5, 1)
5
TESTS::
sage: from sage.algebras.quantum_groups.q_numbers import q_int
sage: q_int(1)
1
sage: q_int(0)
0
"""
if q is None:
R = LaurentPolynomialRing(ZZ, 'q')
q = R.gen()
else:
R = q.parent()
if n == 0:
return R.zero()
return R.sum(q**(n - 2 * i - 1) for i in range(n))
示例2: alexander_polynomial
# 需要导入模块: from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing import zero [as 别名]
def alexander_polynomial(self, var='t', normalized=True):
r"""
Return the Alexander polynomial of the closure of the braid.
INPUT:
- ``var`` -- string (default: ``'t'``); the name of the
variable in the entries of the matrix
- ``normalized`` -- boolean (default: ``True``); whether to
return the normalized Alexander polynomial
OUTPUT:
The Alexander polynomial of the braid closure of the braid.
This is computed using the reduced Burau representation. The
unnormalized Alexander polynomial is a Laurent polynomial,
which is only well-defined up to multiplication by plus or
minus times a power of `t`.
We normalize the polynomial by dividing by the largest power
of `t` and then if the resulting constant coefficient
is negative, we multiply by `-1`.
EXAMPLES:
We first construct the trefoil::
sage: B = BraidGroup(3)
sage: b = B([1,2,1,2])
sage: b.alexander_polynomial(normalized=False)
1 - t + t^2
sage: b.alexander_polynomial()
t^-2 - t^-1 + 1
Next we construct the figure 8 knot::
sage: b = B([-1,2,-1,2])
sage: b.alexander_polynomial(normalized=False)
-t^-2 + 3*t^-1 - 1
sage: b.alexander_polynomial()
t^-2 - 3*t^-1 + 1
Our last example is the Kinoshita-Terasaka knot::
sage: B = BraidGroup(4)
sage: b = B([1,1,1,3,3,2,-3,-1,-1,2,-1,-3,-2])
sage: b.alexander_polynomial(normalized=False)
-t^-1
sage: b.alexander_polynomial()
1
REFERENCES:
- :wikipedia:`Alexander_polynomial`
"""
n = self.strands()
p = (self.burau_matrix(reduced=True) - identity_matrix(n - 1)).det()
K, t = LaurentPolynomialRing(IntegerRing(), var).objgen()
if p == 0:
return K.zero()
qn = sum(t ** i for i in range(n))
p //= qn
if normalized:
p *= t ** (-p.degree())
if p.constant_coefficient() < 0:
p = -p
return p