ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 02 Dec 2020 09:21:39 -0600counting number of matrices in finite fieldhttps://ask.sagemath.org/question/54520/counting-number-of-matrices-in-finite-field/I am new to sage and I want to count the number of matrices per rank in a given finite field.
Example: M=matrix([[x1, x2, x3],[ x4,-x1, x5],[x6,x7,x8]])
in Z/3ZsmokzetaWed, 02 Dec 2020 09:21:39 -0600https://ask.sagemath.org/question/54520/Cohomology ring of a Lie algebrahttps://ask.sagemath.org/question/53129/cohomology-ring-of-a-lie-algebra/I would like to compute the cup products in cohomology for certain families of nilpotent Lie algebras over R.
So far I could access to the cochain complex and compute the Betti numbers using the method chevalley_eilenberg_complex(). On the other hand, I see that the cup product of the cohomology ring of a cell complex can be computed.
So, is there a way to compute the cup products starting from the Lie algebra?
(Note that the Lie algebras that I consider are not always defined over the rational field, so that the cohomologies that I am interested in is not always that of a space of which I could describe the homotopy type by giving a cell complex.)
EDIT (2020-10-26): Problem not solved, but I found a seemingly related issue: https://trac.sagemath.org/ticket/6100 .
Namely, chain_complex().homology(generators=true) uses a basis in which the simplices are listed in an order that seems intractable (especially, not the lexicographic order).
If one could guess in which order the simplices are listed, then I would be able to compute the cup products.Gabriel PallierFri, 21 Aug 2020 07:41:36 -0500https://ask.sagemath.org/question/53129/Echelon form over finite fieldshttps://ask.sagemath.org/question/48420/echelon-form-over-finite-fields/ I need to get the transformation matrix from echelon form reduction over finite fields but I found in the documentation the following statement:
*The matrix library used for Z/p-matrices does not return the transformation matrix, so the transformation option is ignored.*
More specifically, the call:
> M.echelon_form(transformation=True)
returns only the echelon matrix E but not the transformation matrix T, so that T*M=E, when M is over a finite field.
Is there any workaround? Can I get the transformation matrix over QQ and then reduce it over the finite field?
Any advice is much appreciated.
Thanks,
BoyanBoyanFri, 18 Oct 2019 22:21:24 -0500https://ask.sagemath.org/question/48420/periodicity of a wordhttps://ask.sagemath.org/question/45104/periodicity-of-a-word/I have the following code to create words.
sage: M.<x,y,z> = FreeMonoid(3)
sage: Word(x^3*y*x*z^2*x)
word: xxxyxzzx
I want find the periodicity of a given word.
For example ababab has periodicity 3 and abcdabcde has periodicity 1.
Kindly help me with this.
Thank you.GA316Sat, 19 Jan 2019 09:39:09 -0600https://ask.sagemath.org/question/45104/How to use the divergence of a finite function as the source term of another problemhttps://ask.sagemath.org/question/44492/how-to-use-the-divergence-of-a-finite-function-as-the-source-term-of-another-problem/ I use RT element to solve problem A and denote the finite element solution by sigma, sigma is a matrix-valued finite element function. I need to use the divergence of sigma to be the source term of another problem, the trial function space is vector-valued functions. But it doesn't work. The code is
from __future__ import print_function
from fenics import *
import matplotlib.pyplot as plt
mesh = UnitSquareMesh(8,8)
RT = VectorElement("RT",mesh.ufl_cell(), 1,2)
Q = FunctionSpace(mesh, RT)
V = VectorFunctionSpace(mesh, 'CG',1)
f = Expression((('x[0]*x[1]','x[0]'),('x[0]','x[0]*x[1]')),degree=2)
sigma = TrialFunction(Q)
tau = TestFunction(Q)
a = inner(sigma, tau)*dx
L = inner(f,tau)*dx
sigma = Function(Q)
solve(a == L, sigma)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, Constant((0.0, 0.0)), boundary)
u = TrialFunction(V)
v = TestFunction(V)
au = inner(grad(u), grad(v))*dx
Lu = inner(sigma,grad(v))*dx
u = Function(V)
solve(au == Lu, u, bc)adaWed, 28 Nov 2018 12:41:43 -0600https://ask.sagemath.org/question/44492/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 10:22:22 -0500https://ask.sagemath.org/question/38403/Iterating over finite structureshttps://ask.sagemath.org/question/37903/iterating-over-finite-structures/ I am trying to use sage for some algebra computations involving finite rings. Since the structures are finite, I would like to iterate over all the elements of the structure. I know how to iterate in some cases for polynomials in polynomial rings of a certain degree (not necessarily finite):
`S.<x> = PolynomialRing(Zmod(9))`
Then I could do
`for i in S.polynomials(of_degree = 2):`
To iterate over all quadratics. What I'd like to do is iterate over all elements of a structure like the finite ring:
`R = GroupAlgebra( GL(2, Zmod(2)), Zmod(2))`
Is there a way to do this in Sage easily?Jason PolakSat, 10 Jun 2017 02:33:41 -0500https://ask.sagemath.org/question/37903/solve linear system in GF(7)https://ask.sagemath.org/question/33574/solve-linear-system-in-gf7/ hi i would like to solve a small linear system in GF(7)
whats the syntax ?
var('A0','A1','B0','B1','B2','B3')
eqns =
[-A0 + 5*A1 + B0 + 2*B1 + 4*B2 + B3 + 3 == 0,
-3*A0 + 2*A1 + B0 + 4*B1 + 2*B2 + B3 + 1 == 0,
-6*A0 + 6*A1 + B0 + 6*B1 + B2 + 6*B3 - 6 == 0,
-5*A0 + 2*A1 + B0 + B1 + B2 + B3 - 5 == 0,
-4*A0 + 2*A1 + B0 + 3*B1 + 2*B2 + 6*B3 + 6 == 0,
-2*A0 + 4*A1 + B0 + 5*B1 + 4*B2 + 6*B3 + 6 == 0]
`solve(eqns,A0,A1,B0,B1,B2,B3)` will do it in Q or R by default.
thank youfaguiSun, 29 May 2016 12:11:15 -0500https://ask.sagemath.org/question/33574/How to define finite difference approximation for first order derivativehttps://ask.sagemath.org/question/32333/how-to-define-finite-difference-approximation-for-first-order-derivative/I need to define $$y1(k)=\frac{y_{k+1}-y_{k-1}}{2*h}$$
in sage so that sage can differ between symbolic $$y_{k+1}$$ and $$y_{k}$$.
Would somebody please help?
OrangeMon, 25 Jan 2016 12:09:28 -0600https://ask.sagemath.org/question/32333/Introducing a finite monoid by giving its "multiplication" tablehttps://ask.sagemath.org/question/32064/introducing-a-finite-monoid-by-giving-its-multiplication-table/I am interested in working with some finite monoids. Looking at
http://doc.sagemath.org/html/en/reference/categories/sage/categories/monoids.html
I have not found anything about how to define a finite monoid by simply providing its (binary) "multiplication" table.
Is there some way to do so?
boumolMon, 04 Jan 2016 18:48:00 -0600https://ask.sagemath.org/question/32064/How to integrate sqrt(P(sinx)), where P(x) is a polynomhttps://ask.sagemath.org/question/8965/how-to-integrate-sqrtpsinx-where-px-is-a-polynom/Hello! I'm trying to calculate a finite parametric integral, but with no success
sage: var('a,b,c')
(a, b, c)
sage: f = a*sin(x)^2+b*sin(x)+c
sage: f
a*sin(x)^2 + b*sin(x) + c
sage: var('A')
A
sage: integrate(sqrt(f),x,-A,A)
integrate(sqrt(a*sin(x)^2 + b*sin(x) + c), x, -A, A)
Any help would be appreciated!
UPD: A < pi/2installeroThu, 10 May 2012 04:44:54 -0500https://ask.sagemath.org/question/8965/Calculate Right Cosetshttps://ask.sagemath.org/question/8024/calculate-right-cosets/How do I get sage to list the right cosets for the group G = GL2(F3) and the subgroup H consisting of the upper triangular matrices with 1 on the main diagonal?Xiola168Fri, 25 Mar 2011 11:58:22 -0500https://ask.sagemath.org/question/8024/