代表代数整数的环

时间:2015-03-03 19:49:18

标签: python sympy

我试图代表戒指;

enter image description here

其中theta是具有度数d的整数系数的monic不可约多项式f的根。

这个环是代数整数的子环,它本身就是场的一个子环;

enter image description here

我可以用sympy的AlgebraicField

代表这个字段
Q_theta = sympy.polys.domains.AlgebraicField(QQ,theta)

有没有办法用类似的方式表示上面的整数子环?

1 个答案:

答案 0 :(得分:7)

我怀疑这可能不是sympy中的一项功能,原因如下:

首先,如果theta在整数上不是代数,那么将theta连接到整数上的多项式环,就是同构的。

例如,pi不是整数的代数,因为没有整数系数与pi和pi的幂相结合,将等于零。

为了证明这些,实际上是同构的,只需采用评估pi的每个多项式的评估环同态。

这可能不是一个现成的功能,因为计算一个数字是否在任何环上都不是代数是非平凡的。例如,确定e + pi是否是代数仍然是一个悬而未决的问题。

这可以通过sympy

来实现
from sympy.polys.domains import ZZ, QQ, RR, FF, EX

x, y, z, t = symbols('x y z t')
ZZ['theta']

ZZ[t]

here这实际上确实为你提供了整数上的多项式环。

第二代数的数字,(虚数i之类的数字,它们是整数值多项式的根)可以通过取多项式环模和由它唯一的monic多项式生成的思想。

因此,如果theta是虚数i,它具有唯一的monic多项式x^2+1

>>> QQ.old_poly_ring(x).ideal(x**2+1)
<x**2 + 1>
>>> ZZ.old_poly_ring(x).ideal(x**2+1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/sympy/polys/domains/ring.py",               line 91, in ideal
   return ModuleImplementedIdeal(self, self.free_module(1).submodule(
   File "/usr/local/lib/python2.7/dist-            packages/sympy/polys/domains/old_polynomialring.py", line 192, in free_module
    return FreeModulePolyRing(self, rank)
    File "/usr/local/lib/python2.7/dist-packages/sympy/polys/agca/modules.py", line 455, in __init__
     + 'got %s' % ring.dom)
NotImplementedError: Ground domain must be a field, got ZZ

另外,试试这个:

>>> QQ.old_poly_ring(x).quotient_ring([x**2])
QQ[x]/<x**2>
>>> ZZ.old_poly_ring(x).quotient_ring([x**2])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/sympy/polys/domains/ring.py",     line 115, in quotient_ring
  e = self.ideal(*e)
  File "/usr/local/lib/python2.7/dist-packages/sympy/polys/domains/ring.py", line 91, in ideal
  return ModuleImplementedIdeal(self, self.free_module(1).submodule(
  File "/usr/local/lib/python2.7/dist-packages/sympy/polys/domains/old_polynomialring.py", line 192, in free_module
  return FreeModulePolyRing(self, rank)
  File "/usr/local/lib/python2.7/dist-packages/sympy/polys/agca/modules.py",     line 455, in __init__
         + 'got %s' % ring.dom)
NotImplementedError: Ground domain must be a field, got ZZ

One can easily test

  

但是,有用的功能仅适用于字段上的多项式环以及各种本地化和商。

简而言之,除非theta在整数上是非代数的,否则在sympy的框架内这可能是不可能的。

然而,以这种方式表示响铃可以通过制作类并使用Python的魔术方法来覆盖+*的常规行为来实现,这基本上是我们研究戒指所需要的。

以上是上述Looking at the docs的示例。这个代码可以很容易地重新用于给你,比如2的平方根,或整数上的任何其他代数数。