Ask Your Question

BSFU's profile - activity

2024-04-16 21:17:27 +0200 received badge  Notable Question (source)
2024-03-04 08:16:08 +0200 received badge  Notable Question (source)
2023-11-14 17:06:34 +0200 received badge  Famous Question (source)
2023-11-14 17:06:34 +0200 received badge  Notable Question (source)
2023-11-14 17:06:34 +0200 received badge  Popular Question (source)
2022-11-29 19:45:03 +0200 received badge  Notable Question (source)
2022-11-29 19:45:03 +0200 received badge  Popular Question (source)
2022-04-23 11:38:37 +0200 received badge  Popular Question (source)
2022-04-08 15:46:41 +0200 marked best answer How to convert an integer to fixed length binary string in Sage?

I want to get

(192,14,100)=>8bit binary of 192 || 8bit binary of 14 ||8bit binary of 100 => 110000000000111001100100 => 12586596 (equivalent decimal of the 24bits binary sting).

I have written python code to do this, but this code does not work in sage. Here is the code :

L=(192,14,100)
a=0
for i in range(3):
    a=(a << 8) ^ (L[i])
print a
print bin(a)

What is the best way to do so in Sage?

2022-01-19 12:38:40 +0200 received badge  Popular Question (source)
2020-10-30 13:49:30 +0200 received badge  Notable Question (source)
2020-10-30 13:49:30 +0200 received badge  Popular Question (source)
2020-10-30 13:49:30 +0200 received badge  Famous Question (source)
2020-04-16 16:24:00 +0200 asked a question How do I extract base(3) and index (15) from $3^{15}$ in SageMath?

How do I extract base(3) and index (15) from $3^{15$} in SageMath?

2020-04-07 16:23:25 +0200 asked a question Why is SageMath generating errors during compilation?

Whenever compile the following codes, it generates errors. But I don't know why is such errors occurred.

 F.<x> = GF(3^15)
def NP(a):
    return F(a.digits(3))

import random
b=[0,0]
for r in srange(0,2):
    b[r]=random.randint(0,3^15-1)

for i in srange(1,4):
    q=NP(b[0])+NP(b[1])
    print q

Here are the errors:

 File "file.sage.py", line 16, in <module>
    q=NP(b[_sage_const_0 ])+NP(b[_sage_const_1 ])
  File "file.sage.py", line 8, in NP
    return F(a.digits(_sage_const_3 )) #integer 2 polynomial
AttributeError: 'int' object has no attribute 'digits'
2020-04-03 13:46:54 +0200 asked a question What is the way of integer representation of an element in $GF(3^{15})$

For each integer $i$ there is an polynomial representation in $GF(3^{15})$ by

for i in srange(F.cardinality()):
    print(i, '=>', F(i.digits(3)))

As for example $4 \implies x + 1$. What is the reverses way that is, $ x + 1\implies 4$

2020-04-03 10:55:28 +0200 commented answer Why is SageMath fail to generate elements in finite field $GF(3^{15})$

@rburing tank you very much for your solution.

2020-04-03 07:21:18 +0200 received badge  Notable Question (source)
2020-04-03 07:11:09 +0200 asked a question Why is SageMath fail to generate elements in finite field $GF(3^{15})$

I would like to generate elements of finite filed $GF(3^{15})$. To do so I have used the following code :

F.<x> = GF(3^15)
for i in range(3^15):
    print i,"=>", F.fetch_int(i)

But this code failed to generate elements, occurring errors. On there hand the above code works fine for $GF(3^{2})$ given below:

F.<x> = GF(3^2)
for i in range(3^2):
    print i,"=>", F.fetch_int(i)

Produces:

0 => 0
1 => 1
2 => 2
3 => x
4 => x + 1
5 => x + 2
6 => 2*x
7 => 2*x + 1
8 => 2*x + 2.

Where is the problem?

2019-06-02 07:48:20 +0200 marked best answer How to fix "IOError: decoder jpeg not available"

I have stuck when I compile these code in SageNotebook:

from PIL import Image
img=Image.open("/home/pmath/Music/im1.jpg") 
img2=img.convert("L")
img2.save("/home/pmath/Music/secretimage.pgm")
img=Image.open("/home/pmath/Music/secretimage.pgm")
pix=img.load()
print pix

The following errors occur :

Traceback (click to the left of this block for traceback)
...
IOError: decoder jpeg not available

But when I compile these codes with python on the same OS(ubuntu32bit 16.04) it works well. The problems occur only on Sage. How can i fix this issue?

2019-06-02 07:47:14 +0200 asked a question How to sum or product of two elements of two different fields?

I would like to sum of product two elements from different fields and the resultant operation should be in the bigger field. I have used the following codes, but it gives errors.

R.<x> = PolynomialRing(GF(2))
F = GF(2^3, name='x', modulus=x^3 + x^2 + 1)
G = GF(2^8, name='x', modulus=x^8 + x^5 + x^3 + x + 1)
print F.fetch_int(3)
print  G.fetch_int(5)
#F.fetch_int(3) => x + 1
#G.fetch_int(5) => x^2 + 1
#print F.fetch_int(3)*G.fetch_int(5) 
print (x^2 + 1)*(x + 1)
2019-06-01 12:29:34 +0200 commented question How to handle elements of two different Galois fields simultaneously?

@FrédéricC I have used different names, but this also gives error: raise ValueError("the degree of the modulus does not equal the degree of the field") ValueError: the degree of the modulus does not equal the degree of the field

2019-06-01 10:45:13 +0200 asked a question How to handle elements of two different Galois fields simultaneously?

I would like to operate the elements of two different fields simultaneously. I have used the following codes, both are not working at the same time whereas only one work at a time.

G.<x> = GF(2^8, name='x', modulus=x^8 + x^5 + x^3 + x + 1)
F.<x> = GF(2^3, name='x', modulus=x^3 + x^2 + 1)

for i in range(2^3):
    print G.fetch_int(i).integer_representation(), '=', G.fetch_int(i)
    print  F.fetch_int(i).integer_representation(), '=', F.fetch_int(i)
2019-05-28 09:24:38 +0200 received badge  Popular Question (source)
2019-04-10 07:33:28 +0200 asked a question How to access serial number corresponding to each element in $GF(2^3)$?

I would like to access serial number corresponding to each element in $GF(2^3)$? Corresponding to each serial number, I can access the element in $G(2^3)$ as follows:

F.<x> = GF(2^3, name='x', modulus=x^3 + x^2 + 1)
for i in range(2^3):
    print i,'=>',F.fetch_int(i)

This provides :

0 => 0
1 => 1
2 => x
3 => x + 1
4 => x^2
5 => x^2 + 1
6 => x^2 + x
7 => x^2 + x + 1

I would like to get the reverse process which will provide seral number corresponding to each element in $(2^3)$, that is,

0 => 0
1 => 1
x => 2
x + 1 => 3
x^2 => 4
x^2 + 1 => 5
x^2 + x => 6
x^2 + x + 1 => 7

Is there any such way?

2019-04-10 04:08:20 +0200 asked a question How to access index value of an element in $GF(2^3)$?

I would like to access the index value of the corresponding element in $GF(2^3)$. The following code generates all the elements with a unique index value, but if the field size is very large, then it takes a very long time to generate all the elements with their corresponding index value. So I don't like to generate all the elements at a time. When I call a particular element this will return the corresponding index value of this particular element.

F.<x> = GF(2^3, modulus=x^3 + x^2 + 1)
for i,a in enumerate(F):
    print  "{} {}".format(i, a)
#Output:
0   0
1   x
2   x^2
3   x^2 + 1
4   x^2 + x + 1
5   x + 1
6   x^2 + x
7   1

Suppose, If an element $p(x)$ is in enumerate(F), then it should return the corresponding index value of $p(x)$. How can I do this?

2019-04-07 04:11:02 +0200 asked a question How to access element from finite field in run time

I would like to access index value corresponding to an element and conversely access element corresponding to an index value in GF(2^24) in run time. In the following code it does the exact thing what I want. But It takes too long time. So I would like to do in run time. How is it possible?

F.<x> = GF(2^24, modulus=x^24 + x^4 + x^3 + x^1 + 1)

NP={} # Dictionary- indexvalue : polynomial
PN={} # Dictionary- polynomial : indexvalue
for i,a in enumerate(F):
    #print("{} {}".format(i, a))
    NP[i]=a
    PN[a]=i.

As for example, for a polynomial p(x), PN[p(x)]=n, then conversely NP[n]=p(x).

2019-03-02 18:34:07 +0200 received badge  Editor (source)
2019-03-02 18:24:11 +0200 asked a question How to plot ellipsoid with interact?

I would like to plot ellipsoid $\dfrac{x^2}{a^2}+\dfrac{y^2}{b^2}+\dfrac{z^2}{c^2}=1$ in SageMath, where the parameters $a,b,c$ can be changed interactively. I found it what I want here https://www.geogebra.org/m/cqtAE6Sm. But I want to do the same in Sage. How can I do it?

2019-01-27 01:28:47 +0200 commented answer How to solve a system of three polynomial equations over $GF(2^8)$

@rburing thank you so much for your answer. One more question. If the right side of my given equation generates from a loop like b0,b1,b2, then what will be the code?

2019-01-27 01:24:44 +0200 marked best answer How to solve a system of three polynomial equations over $GF(2^8)$

I would like to solve the following system of three equations of three variables $a0,a1,a2$ over GF(2^8, name='x', modulus=x^8 + x^5 + x^3 + x + 1) :

a0+a1*x+a2*x^2=x^7+x^6+x^5+x^2+x
a0+a1*x^2+a2*x^4=x^7+x^6+x^5+x^2
a0+a1*x^3+a2*x^6=x^7+x^3+x^2+1

How can I do this?