Ask Your Question

Hilder Vitor Lima Pereira's profile - activity

2022-10-25 17:29:01 +0100 received badge  Popular Question (source)
2021-11-15 22:12:59 +0100 received badge  Notable Question (source)
2021-04-30 18:13:51 +0100 received badge  Famous Question (source)
2021-03-09 17:32:25 +0100 commented question Create quotient group of units of mod n

Hi @JohnPalmieri. Yes, so even if I map p to an element of Zms, the command Zms.quotient will not work...

2021-02-24 23:56:07 +0100 received badge  Good Question (source)
2021-02-24 19:04:09 +0100 received badge  Nice Question (source)
2021-02-24 09:28:08 +0100 asked a question Create quotient group of units of mod n

I would like to work with the group $\mathbb{Z}_m^* / \langle p \rangle$. Do you know how I can create it?

For example:

p = 2
m = 17^2
Zm = ZZ.quotient(m)  # ring of integers mod m
Zms = Zm.unit_group() # cyclic group (Z/mZ)^* generated by 3
Zms.quotient(p)

But the last line raises a NotImplementedError.

2020-05-02 10:19:11 +0100 received badge  Popular Question (source)
2020-04-09 08:49:18 +0100 received badge  Notable Question (source)
2020-04-09 08:49:18 +0100 received badge  Popular Question (source)
2019-12-05 12:56:01 +0100 received badge  Nice Answer (source)
2019-11-29 11:09:15 +0100 received badge  Necromancer (source)
2019-11-29 11:09:15 +0100 received badge  Teacher (source)
2019-11-27 16:34:18 +0100 answered a question importing .sage files

Just to make @niles' answer more explicit: You can add the following function to the beginning of your main sage script.

## Hack to import my own sage scripts
def my_import(module_name, func_name='*'):
    import os
    os.system('sage --preparse ' + module_name + '.sage')
    os.system('mv ' + module_name + '.sage.py ' + module_name + '.py')

    from sage.misc.python import Python
    python = Python()
    python.eval('from ' + module_name + ' import ' + func_name, globals())

Then, to import all functions from my_lib.sage, you can do

my_import("my_lib")  # from my_lib import *

To import a particular function, say my_func, you can do

my_import("my_lib", "my_func") # from my_lib import my_func

(I created this function using this solution)

2019-07-02 09:00:09 +0100 asked a question Octave-like plot function, or, how to plot sequence of points?

Let's say I have the following set of points: (1, 2), (5, 8), (7, 13), (8, 10), (8.7, 9), (10, 6.3), (13, 2), (15, -1).

I would like to plot a 2D graph passing through them.

In octave, I can do the following:

octave:47> x = [1, 5, 7, 8, 8.7, 10, 13, 15]

octave:48> y = [2, 8, 13, 10, 9, 6.3, 2, -1]

octave:49> plot(x, y)

And I get this graph.

How can I do something similar in sage?

2019-02-13 16:38:18 +0100 commented question Compute xgcd over Gaussian integers

@rburing I see. Thank you very for the comment. It was very useful!

2019-02-13 10:26:39 +0100 received badge  Editor (source)
2019-02-13 10:25:35 +0100 asked a question Compute xgcd over Gaussian integers

As you can see below, I can create the ring of Gaussian integers and compute the greatest common divisor of two elements:

sage: ZZ[I]
Gaussian Integers in Number Field in I with defining polynomial x^2 + 1
sage: F = ZZ[I].random_element()
sage: G = ZZ[I].random_element()
sage: F
-I - 4
sage: G
-I + 1
sage: gcd(F, G)
1

However, when I try to find $u, v \in \mathbf{Z}[i]$ such that $u\cdot F + v\cdot G = 1$ in $\mathbf{Z}[i]$ (that is, to run the extended GCD), I get the following error:

sage: xgcd(F, G)

. . .

TypeError: Unable to coerce -I - 4 to an integer

Do you know how I can find such $u$ and $v$?

2018-12-04 16:06:03 +0100 commented answer Speed a function with hex grid and primes numbers

It is really strange that it gets slower... Could you test something like abs(n-t).is_prime(proof=False) and see if it also takes 10 seconds?

2018-02-21 10:30:23 +0100 received badge  Citizen Patrol (source)
2018-02-20 15:33:49 +0100 asked a question Speed up calculation of left kernel

Is there any way to accelerate the calculation of the left kernel of a matrix? It could be by allowing sage to use more memory or using some parallelism, for instance.

I have a 1230 x 74 dense matrix over Integer Ring

A = Matrix(ZZ, 1230, 74)

and when I try to use

A.left_kernel()

the calculations doesn't finish (it has run for three days and then I interrupted the script).

2017-11-06 09:46:16 +0100 asked a question Inverse of matrix over polynomial ring without changing ring

Let $Rq$ be the ring of polynomials with coefficients in $\mathbb{Z} / q\mathbb{Z}$, for some $q$ prime.

I have a matrix with coefficients in $Rq$ and I would like to find its inverse in $Rq$, but when I try to calculate its inverse, I got a matrix whose elements are fractions of polynomials.

For instance, the following code

q = 31
Zq = IntegerModRing(q)
Rq.<x> = Zq["x"]

P = random_matrix(Rq, 3, 3)
Pinv = P^(-1)  # calculating inverse of P

print "P00:", P[0][0]
print "P00's type:", type(P[0][0])
print "inverseP00:", Pinv[0][0]
print "inverseP00's type:", type(Pinv[0][0])

has outputs like this:

P00: 3x^2 + 13x + 17

P00's type: < type 'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint'>

inverseP00: (5x^4 + 22x^3 + 9x^2 + 24x + 28)/(x^6 + 5x^4 + 7x^3 + 19x^2 + 19x + 5)

inverseP00's type: < type 'sage.rings.fraction_field_FpT.FpTElement'>

Do you know how can I get an inverse matrix with entries also in $Rq$ instead of in that fractional field?

2017-08-02 08:33:49 +0100 commented answer Equivalent of Polynomial.list() for expression involving generator of GaloisField

That works! I had tried similar things, but not really that. Thank you!

2017-08-02 08:33:15 +0100 received badge  Scholar (source)
2017-08-02 08:33:14 +0100 received badge  Supporter (source)
2017-08-02 00:54:06 +0100 received badge  Student (source)
2017-08-02 00:51:04 +0100 asked a question Equivalent of Polynomial.list() for expression involving generator of GaloisField

I know that it is possible to use the method list() to get a list with the coefficients of a polynomial. For instance:

sage: S.<x> = PolynomialRing(ZZ, 'x')
sage: (1 - 5*x + 3*x**2 + 2*x**3).list()
[1, -5, 3, 2]

I would like to do something like that with an expression involving a generator of a Galois Field.

For example:

sage: q = 5
sage: m = 2
sage: F.<a> = GF(q**m)
sage: a**9
3*a + 1

So, ideally, I would like to do the following

(a**9).list()

and get

[1, 3]

Is there any simple way to that?