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, 23 Sep 2018 20:17:59 +0200Roots of Polynomials over finite Fieldshttps://ask.sagemath.org/question/43734/roots-of-polynomials-over-finite-fields/Hi guys,
How can I define all polynomial as this form -> `a*x^2+b*y-1` over QQ where `a` and `b` are constants.
for examples polynomials as : `2*x^2+3*y-1` or `5*x^2+y-1` , ...
I know that I have to create a PolynomialRing, but I don't understand how exactly.
Thank you so much.ZacariasSatrusteguiSun, 23 Sep 2018 20:17:59 +0200https://ask.sagemath.org/question/43734/How to compute common zeros of system of polynomial equations with dimension 2?https://ask.sagemath.org/question/42591/how-to-compute-common-zeros-of-system-of-polynomial-equations-with-dimension-2/I have some ideal of homogenous polynomials defined over some finite field:
J is the ideal of interest. However I can't call J.variety() since it is not zero dimensional. The system of equations might contain 6 or 231 polynomials in four variables:
sage: [I.gens() for I in J.minimal_associated_primes()]
[[x1 + x2, x0 + x3], [x2 + x3, x0 + x1], [x1 + x3, x0 + x2]]
sage: J.dimension()
2
Any ideas?
On request. The program computes the invariant under the group $2_{+}^{1+2\cdot2}$ homogenous polynomials of given degree. To construct the polynomials and get a list of them call: homInvar(6):
F = ZZ;
a = matrix(F, [[0,0,0,-1],[0,0,1,0],[0,-1,0,0],[1,0,0,0]])
b = matrix(F, [[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,-1]])
c = matrix(F, [[0,1,0,0],[-1,0,0,0],[0,0,0,1],[0,0,-1,0]])
d = matrix(F, [[0,1,0,0],[1,0,0,0],[0,0,0,-1],[0,0,-1,0]])
def getPart(deg):
part = []
for k in range(deg+1):
for l in range(deg+1):
for m in range(deg+1):
for n in range(deg+1):
if k+l+m+n == deg:
part.append((k,l,n,m))
return part
def p(x,part):
x = x.list()
pol = 0
for p in [part]:
mon = 1
for i in range(len(p)):
k = p[i]
mon = mon * x[i]**k
pol = pol + mon
return pol
def getGroup():
G = []
for k in range(4):
for l in range(4):
for m in range(4):
for n in range(4):
g = a**k*b**l*c**m*d**n
if G.count(g)==0:
G.append(g)
return G
def reynolds(Gr,part):
reyn = 0
n = len(part)
X = list(var('x%d' % i) for i in range(n))
x = matrix([X]).transpose()
for g in Gr:
reyn += p(g*x,part=part)
#print reyn
return 1/len(Gr)* reyn
def homInvar(deg,Gr=getGroup(),getPart=getPart):
parts = getPart(deg)
inv = set([])
for part in parts:
r = reynolds(Gr,part)
#print r
if r != 0:
inv.add(r)
return invsagemathuserThu, 14 Jun 2018 12:49:21 +0200https://ask.sagemath.org/question/42591/calculating the modulo of a "number" in a binary finite fieldhttps://ask.sagemath.org/question/38735/calculating-the-modulo-of-a-number-in-a-binary-finite-field/Polynomial equations in binary finite fields are often represented as numbers. eg. $x^2 + 1$ is basically the same thing as $1x^2 + 0x^1 + 1x^0$ and thus would be represented as $101_2$ or $5_{10}$.
In that spirit I'm trying to use a hexadecimal number to represent a polynomial equation. The polynomial equation is larger than the modulo I'm using ($x^{113} + x^9 + 1$) so I'm trying to get the result of the modulo operation.
Here's what I've tried:
BF.<a> = FiniteField(2^113);
X = Integer(0x61661990d3b1f7a608ad095a01d727380850d2592f5b9f88f66a20e8);
X_bf = BF._cache.fetch_int(X);
X_bf.mod(x^113 + x^9 + 1)
Unfortunately, this doesn't seem to work and instead gets me the following error messages:
TypeError Traceback (most recent call last)
<ipython-input-4-dba4addbde0d> in <module>()
2
3 X = Integer(Integer(0x61661990d3b1f7a608ad095a01d727380850d2592f5b9f88f66a20e8));
----> 4 X_bf = BF._cache.fetch_int(X);
5
6 X_bf.mod(x**Integer(113) + x**Integer(9) + Integer(1))
/home/sage/sage-8.0/src/sage/rings/finite_rings/element_ntl_gf2e.pyx in sage.rings.finite_rings.element_ntl_gf2e.Cache_ntl_gf2e.fetch_int (/home/sage/sage/src/build/cythonized/sage/rings/finite_rings/element_ntl_gf2e.cpp:7596)()
400 raise ValueError("Cannot coerce element %s to this field." % e)
401
--> 402 cpdef FiniteField_ntl_gf2eElement fetch_int(self, number):
403 """
404 Given an integer less than `p^n` with base `2`
/home/sage/sage-8.0/src/sage/rings/finite_rings/element_ntl_gf2e.pyx in sage.rings.finite_rings.element_ntl_gf2e.Cache_ntl_gf2e.fetch_int (/home/sage/sage/src/build/cythonized/sage/rings/finite_rings/element_ntl_gf2e.cpp:7212)()
431
432 if number < 0 or number >= self.order():
--> 433 raise TypeError("n must be between 0 and self.order()")
434
435 if isinstance(number, int) or isinstance(number, long):
TypeError: n must be between 0 and self.order()
I realize that what I'm doing isn't technically a finite field but idk how else I might get a "number" turned into a polynomial equation.
Any ideas?neubertMon, 04 Sep 2017 08:02:35 +0200https://ask.sagemath.org/question/38735/pre-reduction multiplication result in binary fieldhttps://ask.sagemath.org/question/38734/pre-reduction-multiplication-result-in-binary-field/The following will do multiplication in a finite field:
X = Integer(0x009D73616F35F4AB1407D73562C10F);
Y = Integer(0x00A52830277958EE84D1315ED31886);
F.<x> = GF(2)[];
p = x^113 + x^9 + 1;
BF = GF(2^113, 'x', modulus=p);
X_bf = BF._cache.fetch_int(X);
Y_bf = BF._cache.fetch_int(Y);
temp = Y * X; temp
The problem with this is that the result you get back has had the reduction step already ran. I'd like to see the multiplication result pre-reduction.
Any ideas?neubertMon, 04 Sep 2017 05:44:52 +0200https://ask.sagemath.org/question/38734/