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.Wed, 05 Jul 2023 08:24:36 +0200Checking if the given matrices will generate a finite Grouphttps://ask.sagemath.org/question/69724/checking-if-the-given-matrices-will-generate-a-finite-group/Hello,
I am a newcomer to the SageMath.
Basically, I have 100 matrices which have 4x4 dimensions in python. I want to check if this 100 matrices can generate an infinite group or not. P.S These matrices produced as SU(2) matrices and then were converted 4x4 matrices.
According to the document of sagemath, I tried to write a code but I am constantly having error:
from sage.all import *
for i in su4_np:
sage_matrix = np.matrix((i),complex)
sage_matrix = matrix(sage_matrix)
matrix_su4_np.append(sage_matrix)
#F = GL(4, 5)
F = SL(4,5) #CC ,CyclotomicField(10)
gens = matrix_su4_np #this is the matrix which contains all 100 matrices
G = MatrixGroup(F,4,gens)
#G.order
MatrixGroup(F,4,gens).is_finite()
This is the error:
> --------------------------------------------------------------------------- MemoryError
> Traceback (most recent call last)
> <ipython-input-218-8f1964d06d6d> in
> <module>
> 4
> 5 gens = matrix_su4_np
> ----> 6 G = MatrixGroup(F,4,gens)
> 7 MatrixGroup(F,4,gens).is_finite()
>
> /usr/lib/python3/dist-packages/sage/misc/lazy_import.pyx
> in
> sage.misc.lazy_import.LazyImport.__call__
> (build/cythonized/sage/misc/lazy_import.c:3686)()
> 351 True
> 352 """
> --> 353 return self.get_object()(*args, **kwds)
> 354
> 355 def __repr__(self):
>
> /usr/lib/python3/dist-packages/sage/groups/matrix_gps/finitely_generated.py
> in MatrixGroup(*gens, **kwds)
> 290 if len(gens) == 0:
> 291 raise ValueError('need at least one generator')
> --> 292 gens = normalize_square_matrices(gens)
>
> 293 if check and any(not
> g.is_invertible() for g in gens):
> 294 raise ValueError('each generator must be an invertible
> matrix')
>
> /usr/lib/python3/dist-packages/sage/groups/matrix_gps/finitely_generated.py
> in normalize_square_matrices(matrices)
> 120 continue
> 121 try:
> --> 122 m = list(m)
> 123 except TypeError:
> 124 gens.append(m)
MemoryError:
> Blockquote
I am guessing the error comes because of the ```F = SL(4,5)``` line. However, I do not know what to put instead of that line.
Do we have a function which can check if we have finite group or not just from matrices?
How to solve this error?
I tried quite a lot combination to solve this problem but I always got an errorqsageWed, 05 Jul 2023 06:13:19 +0200https://ask.sagemath.org/question/69724/Cross Product of Generator Matrixhttps://ask.sagemath.org/question/69727/cross-product-of-generator-matrix/ Hello,
I want to do the following items:
1. Take the matrices of SL(2,5)
2. Multiply them with identity
3. Add a specific matrix to the list
4. Check if the group of generatos and the specific matrix produce a finite group
or not
Here is my code:
from sage.all import *
from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
from sage.matrix.action import MatrixMatrixAction
cnot_np = matrix([[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]) #my specific matrix
print(cnot_np)
new_matrices_ = []
print(MatrixGroup(SL(2,5)))
gens_ = MatrixGroup(SL(2,5)).gens() #I got the matrix of my group (my group is binary icosahedral)
print(len(gens_))
identity_mat = matrix([[1, 0], [0, 1]]) #identity matrix
print(identity_mat.cross_product(identity_mat))
for i in gens_:
print(i)
tensor_mat_ = i.cross_product(identity_mat) #tensor product of matrices of binary icosahedral with identity
new_matrices_.append(tensor_mat_) #add them into a new list
new_matrices_.append(cnot_np) # add the specific matrix to the list
is_infinite(new_matrices) #check if it generates an infinite group
However, I can't multiply the generator matrix with identity
Here is my error message:
AttributeError: 'sage.matrix.matrix_integer_dense.Matrix_integer_dense' object has no attribute 'cross_product'
How to solve this problem?
Thanks in advance
qsageWed, 05 Jul 2023 08:24:36 +0200https://ask.sagemath.org/question/69727/How to define a subgroup and get its generators?https://ask.sagemath.org/question/64425/how-to-define-a-subgroup-and-get-its-generators/ I am trying implement the Asychronous Group Auhtnetication Scheme with Multiple Authentication,and i was stucked.
Suppose that We get two big primes p and q and q divides p-1. GF(q) is a unique subgroup of GF(p) with order q,and every gi is a generator of GF(p).
i do not know how to construct a subgroup GF(q) meets the condition above .What makes me more confused that i remember GF(p) only has one generator 1, if i was wrong, how to get those generators gi?![image description](http://) charleyhootThu, 13 Oct 2022 14:29:51 +0200https://ask.sagemath.org/question/64425/Conflict between generators in different groups with the same namehttps://ask.sagemath.org/question/61466/conflict-between-generators-in-different-groups-with-the-same-name/I wrote a relatively simple implementation of the Seifert van Kampen theorem, and I have a commutative 'cube', so to speak, meaning I want to apply it twice successively. The implementation is
# This function computes the fundamental group of a topological space X using
# the Seifert-van Kampen theorem. We decompose X into the union of two open
# connected subsets, U and V, whose fundamental groups are the free group on
# some generators along with relations alpha and beta, respectively.
# Additionally, we have the fundamental group of U \cap V, which is the free
# group on the generators gamma_i. We then have the inclusion maps
# I: \pi(U\cap V) -> \pi(U) and J: \pi(U\cap V) -> \pi(V) which gives
# us the categorical coproduct of \pi(U) * \pi(V).
def seifert_van_kampen(U, alpha, V, beta, I, J, intersection):
X = FreeGroup(U.gens() + V.gens())
relations = []
for generator in intersection.gens():
relations.append(X(I(generator))*X(J(generator))^-1)
relations = relations + alpha + beta
return X / relations
And it seems to work properly in simple cases. My problem arises when trying to apply it twice successively. My diagram looks like this:
A --- AB
/ X \
S -- B AG -- X
\ X /
G --- BG
Where S is the pairwise intersection between any of A, B, and G, and the X in the middle of the diagram represents crossing arrows. Through one application of SVK, I can get the fundamental group for AB, AG, or BG, and the problem occurs with the second step to compute the fundamental group for X.
If I have the fundamental groups for A, B, and G generated by alpha_i, beta_i, and gamma_i respectively, then the fundamental group for AB is generated by the alpha_i and beta_i, and similar for AG and BG. But if I try to use the same logic, say using AB and BG to get X, the generators would be alpha_i, beta_i from AB, and beta_i and gamma_i from BG. But my understanding is that those generators should be considered distinct, and I don't quite see how to make that happen in Sage.
In particular, the additional relations when we compute the coproduct (in the AB/BG case) come from the inclusion map of the generators for B into each of AB and BG respectively, which is exactly those duplicate generators. That part is fine, but if I want to consider those words as elements of the free group on (alpha_i, beta_i, beta_i, gamma_i), I don't know how to make those words use the 'correct' generators.
EDIT: To give the specific way I'm trying to use this, I'm studying 2-knots, and have a particular decomposition into 3 1-knots. The fundamental group of each of the knot complements are A, B, and G above, and I'm trying to recover the fundamental group for the original 2-knot complement. There's a lot of boilerplate stuff to get the knot in a particular representation I can work with, but right now I use the above function like this:
def SVK_cube(braids, b):
prefixes = ['x', 'y', 'z']
intersect_maps = []
groups = []
intersect_group = FreeGroup(2 * b, 'a')
# Boilerplate stuff
graph, _ = make_graph(braids, b)
graph = is_orientable(graph)
signs = orientation_signs(graph, b)
for i in range(3):
# hom[i] is the element that the ith generator of fundamental group for
# intersection gets sent to
hom, group = wirtinger_relations(braids[i], signs, b, prefixes[i])
print(group)
print(hom)
groups.append(group)
intersect_maps.append(intersect_group.hom(hom))
a_group, b_group, g_group = groups
a_rels = [a_group.gen(2*i)*a_group.gen(2*i+1)^-1 for i in range(b)]
b_rels = [b_group.gen(2*i)*b_group.gen(2*i+1)^-1 for i in range(b)]
g_rels = [g_group.gen(2*i)*g_group.gen(2*i+1)^-1 for i in range(b)]
ab = seifert_van_kampen(a_group, a_rels, b_group, b_rels, intersect_maps[0], intersect_maps[1], intersect_group)
ag = seifert_van_kampen(a_group, a_rels, g_group, g_rels, intersect_maps[0], intersect_maps[2], intersect_group)
bg = seifert_van_kampen(b_group, b_rels, g_group, g_rels, intersect_maps[1], intersect_maps[2], intersect_group)
print(ab.simplified())
print(ag.simplified())
print(bg.simplified())
braids = [[4,5,6,7,2,3,4,5,6,7],[2,3,4,5,6,7], [2, 3, 4, 5, 6, 7, -7, -7, -7, 1, 1, 1, 3, -5, -4]]
SVK_cube(braids, 4)
And this gives the output:
Free Group on generators {x0, x1, x2, x3, x4, x5, x6, x7}
[x0, x1^-1*x2*x1, x1^-1*x3^-1*x4^-1*x3*x1, x1^-1*x3^-1*x5*x3*x1, x1^-1*x3^-1*x6^-1*x3*x1, x1^-1*x3^-1*x7*x3*x1, x1^-1*x3^-1*x1, x1^-1]
Free Group on generators {y0, y1, y2, y3, y4, y5, y6, y7}
[y0, y1^-1*y2*y1, y1^-1*y3^-1*y1, y1^-1*y4*y1, y1^-1*y5^-1*y1, y1^-1*y6*y1, y1^-1*y7^-1*y1, y1^-1]
Free Group on generators {z0, z1, z2, z3, z4, z5, z6, z7}
[(z0*z1^-1*z2*z1)^2*z0^-1*z1^-1*z2^-1*z1*z0^-1, z0*z1^-1*z2*z1*z0*z1^-1*z2^-1*z1*z0^-1, z1^-1*z3^-1*z4^-1*z3*z1, z1^-1*z6*z1, z1^-1*z6^-1*z3^-1*z6*z1, z1^-1*z6^-1*z5*z6*z1, z7*z1^-1*z7^-1, z7*z1*z7^-1*z1^-1*z7^-1]
Finitely presented group < x0, x2 | >
Finitely presented group < x4, z0 | >
Finitely presented group < y0, y2 | >
I have the simplified group printed out for the sake of space, but the next step would be to take a pair of these groups and compute the coproduct again. I don't think I can use the simplified form because I need to know where the generators for b (for example) are sent to into ab and bg, which is lost in the simplified form.cgodfreyThu, 10 Mar 2022 05:26:31 +0100https://ask.sagemath.org/question/61466/Group elements in terms of its generatorshttps://ask.sagemath.org/question/57021/group-elements-in-terms-of-its-generators/I created a permutation group with generators [(4,5,6,7,8), (1,2,3)]. The order of this group is shown as 15. **c,f** in Cayley_table() corresponds to these generators. Is there a way to print these 15 elements a,b,c.....m,n,o in terms of these generators c,f? Anoop S K MSat, 08 May 2021 12:52:22 +0200https://ask.sagemath.org/question/57021/list_plot generatorhttps://ask.sagemath.org/question/48239/list_plot-generator/I have created a python generator that yeilds a list of single values (e.g. like [1,971,15,341,..]) up to some defined length of n,and wanted to plot them in sagemath.
When I pass the generator to list_plot, I get an error as list_plot only accepts lists, tuples and dictionaries.
Is there any way to get the list_plot behaviour from a generator without converting to a list first (To memory-hungry for my purpose)?
If not, I'm planning to request an enhancement to list_plot, if at all possible.JoalHeagneyWed, 09 Oct 2019 00:02:55 +0200https://ask.sagemath.org/question/48239/Finding the generators for automorphisms of a graphhttps://ask.sagemath.org/question/43028/finding-the-generators-for-automorphisms-of-a-graph/ Having a large graph, it will cause memory and kernel issues for SAGE to list all graph automorphisms. Is there a way to find the generators of the automorphisms instead of the whole automorphisms of a graph?ASHMon, 16 Jul 2018 03:41:18 +0200https://ask.sagemath.org/question/43028/Evaluating a list of multivariate equations at random values.https://ask.sagemath.org/question/41662/evaluating-a-list-of-multivariate-equations-at-random-values/I have a list of multivariate equations, there are `o` multivariate equations in the list where `o` is an integer and `v = 2o`, the variables that make up the equations are the generators of `P = PolynomialRing(K,'x',n)` where `n = v + o` so for example if `o = 2` then `v = 4` and `n = 6` so the variables that make up the multivariate equations in the list would be `P.gens() = (x0, x1, x2, x3, x4, x5)`. Now i need to substitute in random values from `GF(q)` for the first `v` variables in each of the multivariate equations in the list so in the example above where `v = 4` random values from `GF(q)`would be substituted in for the variables `x0, x1, x2, x3`in each of the multivariate equations in the list, leaving equations in only two variables `x4 and x5`. I have tried to implement this but i don't really know where to start as i know i am doing something wrong but what i have is the following. If the list of multivariate equations is called `eqn` for example.
for i in range(v):
xi = var('x'+str(i))
eqnsub0 = eqn[i].subs({x[i]:GF(q).random_element()})
I already know this is very wrong as the indexing will already go out of bounds since `v > o` but i don't really know where to start with this. Any help would be great, thanks. DalvirTue, 20 Mar 2018 22:51:34 +0100https://ask.sagemath.org/question/41662/Equivalent of Polynomial.list() for expression involving generator of GaloisFieldhttps://ask.sagemath.org/question/38458/equivalent-of-polynomiallist-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?Hilder Vitor Lima PereiraWed, 02 Aug 2017 00:43:08 +0200https://ask.sagemath.org/question/38458/Check if a finitely generated matrix group is finite (works with QQ and not with CC)https://ask.sagemath.org/question/38403/check-if-a-finitely-generated-matrix-group-is-finite-works-with-qq-and-not-with-cc/Dear all, I am a newbie in sage. I would like to check if a finitely generated matrix group is finite. Before to proceed with the calculation on my actual problem (where matrices have complex entries), I have tried a very simple example. Consider the group generated by the matrices [1,0,0,1] and [0,1,1,0], this group is clearly finite. Can somebody explain me why the following code works:
sage: MS = MatrixSpace(QQ, 2, 2)
sage: G = MatrixGroup([MS([1,0,0,1]),MS([0,1,1,0])])
sage: G.is_finite()
True
but if I change the field QQ -> RR (or CC), an error is generated:
sage: MS = MatrixSpace(RR, 2, 2)
sage: G = MatrixGroup([MS([1,0,0,1]),MS([0,1,1,0])])
sage: G.is_finite()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-215-0022a668c150> in <module>()
----> 1 G.is_finite()
/Applications/SageMath-7.6.app/Contents/Resources/sage/src/sage/groups/group.pyx in sage.groups.group.Group.is_finite (/Applications/SageMath-7.6.app/Contents/Resources/sage/src/build/cythonized/sage/groups/group.c:2696)()
179 NotImplementedError
180 """
--> 181 return self.order() != infinity
182
183 def is_multiplicative(self):
/Applications/SageMath-7.6.app/Contents/Resources/sage/src/sage/groups/group.pyx in sage.groups.group.Group.order (/Applications/SageMath-7.6.app/Contents/Resources/sage/src/build/cythonized/sage/groups/group.c:2623)()
164 NotImplementedError
165 """
--> 166 raise NotImplementedError
167
168 def is_finite(self):
NotImplementedError:
Is there any way to force the second piece of code to work with matrices with entries in CC?
Thank you in advance.frenkyoTue, 25 Jul 2017 17:22:22 +0200https://ask.sagemath.org/question/38403/