ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 02 Mar 2020 11:41:23 -0600Systematically outputting sign vectors of restricted hyperplane arrangementhttp://ask.sagemath.org/question/50139/systematically-outputting-sign-vectors-of-restricted-hyperplane-arrangement/ I have a way of constructing hyperplane arrangements, which involves taking the restriction of a larger arrangement to one of the hyperplanes in it. I want to output a list of the sign vectors of the regions of this arrangement, where the order of the coordinates in the sign vector corresponds to a specific order I want to impose on the hyperplanes. This has turned out surprisingly tricky, because of a couple of seemingly arbitrary decisions Sage's hyperplane arrangement package makes:
- The hyperplane arrangement constructor seems to not preserve the order of the hyperplanes fed into it, so if I just run the built-in sign_vector method, the coordinates of the resulting vectors may be rearranged from how I want them.
- On the other hand, I'm not sure how to go about manually determining the sign vector, because I'm not sure how Sage decides to coordinatize the hyperplanes in the restricted arrangement. So while I have equations for the hyperplanes in the original ambient space, I'm not sure how I could automatically turn them into equations in the hyperplane I'm restricting to.
Does anyone have advice on how to systematically resolve either of these arbitrary decisions, or how to find a different workaround?Will DanaMon, 02 Mar 2020 11:41:23 -0600http://ask.sagemath.org/question/50139/Computing the basis of the Frobenius function fixed point spacehttp://ask.sagemath.org/question/44321/computing-the-basis-of-the-frobenius-function-fixed-point-space/Let $f\in GF_{q}[x]$ be a squarefree univariate polynomial with coefficients in a finite field, and $\bar{Fr}: \frac{F_q}{(f)}\to \frac{F_q}{(f)}: \bar h \mapsto \bar h^q$ the Frobenius application over $GF_q$ elevated to the cocient $\frac{F_q}{(f)}$.
Then we can see $\frac{F_q}{(f)}$ as a vector space over $GF_q$, and the space of fixed points of $\bar{Fr}$, that is $W = \{\bar h \in \frac{F_q}{(f)} : \bar h ^q = q \}$ is a linear subspace.
The question: how do I compute the basis of $W$ in sagemath?
EDIT:
Inspired by @rburing I wrote some (incomplete) code:
def berlekamp_basis(f):
"""
INPUT: f a monic squarefree polynomial in F_q[x]
OUTPUT: a list of polynomials hi in F_q[x] that represent
a basis of the Berlekamp algebra associated to f
"""
n = f.degree()
GFX = f.parent()
GFX_quo_f = GFX.quotient(f)
g = []
for k in range(n):
basic_image = GFX(GFX_quo_f(x)^(q*k)) - GFX(x)^k
g.append(basic_image)
H = ???
return H
So I have collected in `g` the images of a basis of `GFX_quo_f` under $\bar {Fr} - \bar {id}$. How do I compel sagemath to use this information to compute the kernel of this linear application?
EDIT 2:
Following the technical hints from @rburing below, I scrapped together this code:
def berlekamp_basis(f):
"""
INPUT: f a monic squarefree polynomial in F_q[x]
OUTPUT: a list of polynomials hi in F_q[x] that represent
a basis of the Berlekamp algebra associated to f
"""
n = f.degree()
GFX = f.parent()
x = GFX.gen()
q = GFX.base().order()
GFX_quo_f = GFX.quotient(f)
g = []
for k in range(n):
basic_image = GFX_quo_f(x^(q*k)- x^k)
g.append(vector(basic_image))
H = matrix(g).right_kernel().basis()
H = [GFX(h) for h in H]
return H
When I run the following test:
GF9.<a> = GF(3^2)
GF9X.<x> = GF9[x]
f = x**3 + x**2 + x - a
assert(f.is_squarefree())
berlekamp_basis(f)
I get a big scary error:
Error in lines 42-42
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "", line 17, in berlekamp_basis
File "sage/structure/parent.pyx", line 921, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9679)
return mor._call_(x)
File "sage/structure/coerce_maps.pyx", line 145, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4574)
raise
File "sage/structure/coerce_maps.pyx", line 140, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4442)
return C._element_constructor(x)
File "/ext/sage/sage-8.4_1804/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring.py", line 460, in _element_constructor_
return C(self, x, check, is_gen, construct=construct, **kwds)
File "sage/rings/polynomial/polynomial_zz_pex.pyx", line 145, in sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX.__init__ (build/cythonized/sage/rings/polynomial/polynomial_zz_pex.cpp:15712)
Polynomial_template.__init__(self, parent, x, check, is_gen, construct)
File "sage/rings/polynomial/polynomial_template.pxi", line 176, in sage.rings.polynomial.polynomial_zz_pex.Polynomial_template.__init__ (build/cythonized/sage/rings/polynomial/polynomial_zz_pex.cpp:8595)
x = parent.base_ring()(x)
File "sage/structure/parent.pyx", line 921, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9679)
return mor._call_(x)
File "sage/structure/coerce_maps.pyx", line 145, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4574)
raise
File "sage/structure/coerce_maps.pyx", line 140, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4442)
return C._element_constructor(x)
File "/ext/sage/sage-8.4_1804/local/lib/python2.7/site-packages/sage/rings/finite_rings/finite_field_givaro.py", line 370, in _element_constructor_
return self._cache.element_from_data(e)
File "sage/rings/finite_rings/element_givaro.pyx", line 318, in sage.rings.finite_rings.element_givaro.Cache_givaro.element_from_data (build/cythonized/sage/rings/finite_rings/element_givaro.cpp:7809)
cpdef FiniteField_givaroElement element_from_data(self, e):
File "sage/rings/finite_rings/element_givaro.pyx", line 407, in sage.rings.finite_rings.element_givaro.Cache_givaro.element_from_data (build/cythonized/sage/rings/finite_rings/element_givaro.cpp:6166)
raise TypeError("e.parent must match self.vector_space")
TypeError: e.parent must match self.vector_spaceJsevillamolSun, 18 Nov 2018 03:42:36 -0600http://ask.sagemath.org/question/44321/Dimension of a certain subspace of a matrix spacehttp://ask.sagemath.org/question/32302/dimension-of-a-certain-subspace-of-a-matrix-space/Si scriva una procedura in Sage che calcoli al variare dell'intero n>=2 la
dimensione del sottospazio vettoriale W di End(Mn(R)) costituito da tutte
e sole le applicazioni lineari F(A;B) : Mn(R) --> Mn(R) del tipo
F(A;B) : X |----> AX + XB
al variare di A e B in Mn(R).
Please help me.
**Edit**: translation contributed by @daniele:
Write a function in Sage that computes the dimension of the vector subspace
$W \subseteq \mathrm{End}(M_n(\mathbb{R}))$ constructed as following:
$W$ consists of linear maps $F(A;B) \colon M_n(\mathbb{R}) \to M_n(\mathbb{R})$
such that $F(A;B) : \colon X \mapsto AX + XB$ with $A$, $B$ in $M_n(\mathbb{R})$.
Here, $n\geq 2$.GiukkyaWed, 20 Jan 2016 09:30:22 -0600http://ask.sagemath.org/question/32302/Can sage extend bases?http://ask.sagemath.org/question/32607/can-sage-extend-bases/Say I have subspaces $X\subset Y$ of a vector space $V$. I want to extend a basis for $X$ to a basis for $Y$. Does sage have this capability?
For example, I have two matrices
sage: d1 = matrix(GF(2), [
....: [1,0,1,0,1,0,1,0,1,0],
....: [1,1,0,0,0,0,0,0,0,1],
....: [0,1,1,1,0,0,0,0,0,0],
....: [0,0,0,1,1,1,0,0,0,0],
....: [0,0,0,0,0,1,1,1,0,0],
....: [0,0,0,0,0,0,0,1,1,1]
....: ])
sage: d2 = matrix(GF(2), [[1,1,1,0,0,0,0,0,0,0],[0,0,1,1,1,0,0,0,0,0]]).transpose()
Since d1*d2=0 we know that the column space of d2 is a subspace of the null space of d1. We can obtain a basis for the column space of d2 with
sage: d2.column_space().basis()
How could we extend this basis to a basis of the null space of d1?
done_with_fishSat, 20 Feb 2016 11:44:43 -0600http://ask.sagemath.org/question/32607/