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.Fri, 19 Jun 2020 05:03:12 -0500find characteristic polynomial in a tower of extensions over Qphttps://ask.sagemath.org/question/52087/find-characteristic-polynomial-in-a-tower-of-extensions-over-qp/We have a tower of extensions W/T/U where U is an unramified extension of $Q_p$, T is given by an eisenstein polynomial $f\in U[x]$ and W is given by an eisenstein polynomial $g\in T[x]$. Hence T is an $deg(g)deg(f)-$dimensional $U-$vector space with basis consisting of products $\alpha^i \beta^j$ such that $0\leq i < deg(f), 0\leq j < deg(g)$, where $\alpha$ is a root of $f$ and $\beta$ is a root of $g$.
Let $\gamma \in W$ be arbitrary. The goal is to compute the matrix of multiplication by $\gamma$ wrt the above $U-$basis. The issue is that the field $W$ cannot be created as an extension of $T$ in Sage, it seems that at the moment you cannot create an extension given by an eisenstein polynomial if T is already an eisenstein extension.
Example of how it does not work:
sage: U = Qq(2^2,names="u")<br>
sage: R.<x> = U[]<br>
sage: f = x^2 - U.uniformizer()<br>
sage: T = U.extension(f,names="alpha")<br>
sage: S.<x> = T[]<br>
sage: g = x^2-T.uniformizer()<br>
sage: W = T.extension(g,names="beta")<br>
TypeError: Unable to coerce -alpha to a rational<br>
We can create W as a quotient ring T[x]/(g), but I don't know how to get coefficients of $\gamma$ w.r.t. the power basis $1,\bar{x},\bar{x}^2,\dots,\bar{x}^{deg(g)-1}$.
sage: U = Qq(2^2,names="u")<br>
sage: R.<x> = U[]<br>
sage: f = x^2 - U.uniformizer()<br>
sage: T = U.extension(f,names="alpha")<br>
sage: S.<x> = T[]<br>
sage: g = x^2-T.uniformizer()<br>
**sage: W = S.quotient_ring(g)<br>
sage: V, map_to_W, map_from_W, = W.free_module()<br>**
NotImplementedError:<br>
If the above were possible, we could simply map $\gamma$ to the free module, then find coefficients wrt the power basis. Then we could do the same thing for each coefficient with W replaced by T to get the U-coefficients.
wltnFri, 19 Jun 2020 05:03:12 -0500https://ask.sagemath.org/question/52087/Expressing a list of vectors in terms of basis elementshttps://ask.sagemath.org/question/52063/expressing-a-list-of-vectors-in-terms-of-basis-elements/Let's assume I have a list for my basis [a,b,c,d,e]=BasisList. We can think of a,b,c,d,e as standard basis vectors with a being (1,0,0,0,0) for example.
I also have another list of many vectors each with 5 entries. For example, ExampleList=[(1,2,3,4,5), (2,3,4,1,8),...]. Is there a fast way to express each vector in terms of my basis instead of mulitplying term by term and summing them up. In the example above, I want to end up with the a list
EndList=[a+2b+3c+4d+5e, 2a+3b+4c+d+8e,...]
I can of course make a loop and do this summing+multiplying but it gets very long and sometimes redundant if my vector has zeros. I was thinking if there is a way to tell Sage to let a be (1,0,0,0,0), b be (0,1,0,0,0), etc and just do 1 for loop with command like "for element in ExampleList, express with basis given."whatupmattWed, 17 Jun 2020 22:21:19 -0500https://ask.sagemath.org/question/52063/Basis for such a quotient vector spacehttps://ask.sagemath.org/question/51550/basis-for-such-a-quotient-vector-space/Hi all,
Here is my code:
`A = matrix(QQ, 4, 3, [1, 2, 3, 5, 10, 15, 0, 0, 0, -2, -4, -6])`
`B = matrix(QQ, 5, 4, [0, 2, 7, 5, 0, 0, 0, 0, 0, -2, -7, -5, 0, 4, 14, 10, 0, 6, 21, 15])`
`W = A.transpose().image()`
`V = B.right_kernel()`
`V/W`
This way W is the range of the linear map
$$A:\mathbb{Q}^3\longrightarrow\mathbb{Q}^4,$$
V is the nullspace of
$$B:\mathbb{Q}^4\longrightarrow\mathbb{Q}^5,$$
Since BA=0, W is a subspace of V.
and the command V/W returns in particular the dimension of the quotient vector space V/W which is equal to 2.
What I want is a basis of V/W, i.e. 2 vectors of $\mathbb{Q}^4$ which are in V,
in the form of a 2x4 matrix
the same way V.basis_matrix() returns a basis for V.
How can I do this?
Thanks!BostonMon, 25 May 2020 12:26:58 -0500https://ask.sagemath.org/question/51550/Maps of monomials to monomialshttps://ask.sagemath.org/question/50703/maps-of-monomials-to-monomials/ Let us assume I have a function F that takes say degree 1 monomials to degree 2 monomials and degree 3 monomials in variable x,y (example: multiplication by $x+y^{2}$). I have a basis for degree 1 monomials given by x,y; a basis for degree 2 given by $x^{2},xy,y^{2}$, and a basis for degree 3 monomials given by $x^{3},x^{2}y,xy^{2},y^{3}$. So if I want to express F as a matrix, I can say
g1= F(x), g2=F(y).
Then the first row of my matrix will be coefficient of $x^{2}$ in g1, coefficient of $xy$ in g1, coefficient of $y^{2}$ in g1, coefficient of $x^{3}$ in g1, ...., coefficient of $y^{3}$ in g1. The second row will just be the same with g1 replaced with g2.
The issue is if I want degree 10 monomials, the writing out each basis element is too much, especially if there were more variables. I was wondering if there was a simpler way in Sage to write this in coding language without writing out each basis element. Suppose I want degree k monomials to degree m and n monomials. Basically, I feel I need some command like the following. I feel there should be a package for this maybe?
1. Define F. Let B be a k x (m+n) matrix. Take the space of all degree k monomials (maybe ordered lexigraphically?). Apply F to that space. For each element F is applied to, in the image, extract degree m part. Write it out as a vector in the space of degree m monomials. Same for degree n part. Put vector into part of matrix B.
whatupmattSun, 12 Apr 2020 09:55:35 -0500https://ask.sagemath.org/question/50703/Number field basis containing 1https://ask.sagemath.org/question/42150/number-field-basis-containing-1/ In Sage, the default basis for a maximal order $O_K$ often does not contain the element $1$:
sage: QuadraticField(-3).ring_of_integers().basis()
[1/2*a + 1/2, a]
However, $1$ is always a primitive lattice vector in $O_K$. Is there an elegant way to produce a basis containing $1$?eodorneyTue, 24 Apr 2018 14:21:01 -0500https://ask.sagemath.org/question/42150/Pass a list of variable names as parameter to a polynomial ringhttps://ask.sagemath.org/question/33526/pass-a-list-of-variable-names-as-parameter-to-a-polynomial-ring/ I am trying to write a function that compute a vector space basis $B$ for the quotient ring $k[x_1,\dots,x_n]/I$. I want to make the list of variables as the input parameter.
I tried this:
var("x,y")
Vlist=[x,y]
P.<Vlist>=PolynomialRing(QQ,order='degrevlex')
f=x^2+y^3
f.lm()
It gave me error message. I also tried
Vlist=['x,y']
or
Vlist=["x,y"]
None of them works.
I know that
P.<x,y>=PolynomialRing(QQ,order='degrevlex')
f=x^2+y^3
f.lm()
works. So I can just type this before I run my function. But is there a way that I can make this as input of the function?KittyLMon, 23 May 2016 12:17:44 -0500https://ask.sagemath.org/question/33526/Writing elements as a linear combination in a basis in a quotient ringhttps://ask.sagemath.org/question/33322/writing-elements-as-a-linear-combination-in-a-basis-in-a-quotient-ring/I have an explicit ideal in a multivariable polynomial ring R. I know a priori that the quotient
ring R/I is finite dimensional (as a vector space). In fact I have an explicit basis in R/I. I have all this programmed into sage. Is there a way to find the linear combination for a given element in R/I in the given basis?
example:
sage: R.<e1,e2>=PolynomialRing(QQ)
sage: I = ideal(e1^3 -2 * e2 * e1 +1, e2 * e1^2 - e2^2 - e1)
sage: I.vector_space_dimension()
6
sage: f22= e2^2 - e1; f21 = e2*e1 - 1; f11 = e1^2 - e2; f1= e1; f2 = e2; f0 = 1;
sage: I.reduce(f21*f21)
e1*e2
sage: I.reduce(f21*f21) == f21 + f0
True
I have an ideal I in R and I know that the quotient ring R/I is 6 dimensional over the field. I have the basis
f22,f21,f11,f2,f1,f0 of R/I as a vector space over QQ. I would like to find the structure constants of this finite dimensional algebra. For example compute f21^2 in the quotient ring, and write it in the basis, we get f21^2=f21+f0.
But I only get it by hand and would like to compute it with sage, so that I could get the whole set of structure constants. mathworkerThu, 05 May 2016 14:07:11 -0500https://ask.sagemath.org/question/33322/Represent field element in normal basishttps://ask.sagemath.org/question/33004/represent-field-element-in-normal-basis/ Hi there
I'm having a normal basis, which is a basis of Fpn over Fp where (n=2)
NB = [zeta, zeta**p]
and a point
P = E2.change_ring(Fpn).random_element()
I would like to find a,b in Fp such that
P = a*NB[0] + b*NB[1]
Naive solutions result is memory overflow, and the Solve() function can't give me solutions with a,b in Fp. Any ideas?BelphegorTue, 05 Apr 2016 08:21:12 -0500https://ask.sagemath.org/question/33004/Separate Variable of Matix (Get Basis)https://ask.sagemath.org/question/29818/separate-variable-of-matix-get-basis/ I try to look for basis of Matrix group center. However, I have problem to separate variable. For simplicity, I have
A=Matrix([a1,a1],[0,a2])
Then, I have to get matrix `[[1,1],[0,0]]` and `[[0,0],[0,1]]` which linear combination of matrix above. Could anyone help me? Thanksnur_hamidWed, 07 Oct 2015 21:15:15 -0500https://ask.sagemath.org/question/29818/Can I get coefficients of a vector with respect to given basis for a vector space.https://ask.sagemath.org/question/24926/can-i-get-coefficients-of-a-vector-with-respect-to-given-basis-for-a-vector-space/Hello.
I have a question.
For example,
1. make vector space `V` by a basis `B=[1+x,3*x,x^2]` over the field of rationals`Q`
2. `v=3*x^2+17*x+5` in V
3. `v=a*B[0]+b*B[1]+c*B[2]` for some `a,b,c` in `Q`
4. `[a,b,c]`=?
We easily know the solution of previous example.
In general, for given basis `B` and a vector `v`, how can I get the list of coefficients?
And is it possible to the case of matrix space (`B`: the basis consists of matrices) ?
Thanks. :)SeminThu, 20 Nov 2014 05:10:29 -0600https://ask.sagemath.org/question/24926/Changing basis on a vector spacehttps://ask.sagemath.org/question/10327/changing-basis-on-a-vector-space/Dear community:
I'd like to know if it is possible use a basis other than the canonical. For example
> sage: V = VectorSpace(SR,3)
> sage: V.basis()
> [ (1, 0, 0),
> (0, 1, 0),
> (0, 0, 1) ]
is the canonical basis of `V`, but I want to use say
> [ (1, 1, 0),
> (1, -1, 0),
> (0, 0, 1)]
How could I do that?
**Edit**
More specifically, I'd like to define two different basis on a vector space. Say, a set of coordinate basis and a non-coordinate basis defined over the same vector space... and finally I'd like to express results in either of them.
I'm interested on a change of basis on Differential Forms, but I guess that if you can help me to understand the general problem I can manage the particular one! ChreesDoxSat, 06 Jul 2013 10:04:31 -0500https://ask.sagemath.org/question/10327/Defining Clifford Algebrashttps://ask.sagemath.org/question/9704/defining-clifford-algebras/Dear all.
I'm a high energy physicist, interested in using SAGE for manipulations of Clifford algebras.
Being accustomed to the architecture of SAGE, I believe that the fundamental structures of these algebras is defined somewhere (probably as an algebra with basis).
**Question(s)**
- How could I define the Clifford algebra structure from the basis elements?
- Is it possible to manipulate the order of terms like $v w u \to u v w$ ?
Thank you.DoxFri, 11 Jan 2013 06:29:58 -0600https://ask.sagemath.org/question/9704/How to reference algebra monomials?https://ask.sagemath.org/question/9130/how-to-reference-algebra-monomials/Hello. My questions are relatively easy to phrase, but first, some background.
If I have an algebra like
H = IwahoriHeckeAlgebraT("A3",1,prefix = "s")
and I ask for `H(H.basis().keys()[1])` I get s1, which is the correct ewaulr and the same result as `H.monomial(H.basis().keys()[1])`. However, with an algebra such as
A = CombinatorialFreeModule(QQ, ['a','b','c'])
`A(A.basis().keys()[1])` returns an error, whereas `A.monomial(A.basis().keys()[1])` returns B[b], which is the correct answer.
So, my question is, what is the difference between calling an Algebra Object (like A or H from above) versus calling that Algebra Object's monomial method? Furthermore, if they are different, (which they appear to be,) what method is A(x) or H(x) calling? Finally, is there any documentation on this A(x) method? Calling the documentation from the notebook interface gets me the docstring for the class.
Thank you for your help!ghseeliMon, 16 Jul 2012 10:25:26 -0500https://ask.sagemath.org/question/9130/How to get coordinates of an element of a combinatorial free module?https://ask.sagemath.org/question/8751/how-to-get-coordinates-of-an-element-of-a-combinatorial-free-module/This sounds ridiculously simple, but it seems that I don't know the right command. I have an element in a CombinatorialFreeModule, which has a finite basis. I want the coordinates of this vector as an array or a vector or in whatever way. Here is what I have tried:
---------
MRH([1,3,2]) # this is our vector
B[[1, 3, 2]]
for i in MR.homogeneous_component(3).basis():
print(i) # this prints our basis
B[[1, 2, 3]]
B[[1, 3, 2]]
B[[2, 1, 3]]
B[[2, 3, 1]]
B[[3, 1, 2]]
B[[3, 2, 1]]
(MR.homogeneous_component(3)).coordinates(MRH([1,3,2]))
# this should print [0,1,0,0,0,0] or something like this
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_82.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("KE1SLmhvbW9nZW5lb3VzX2NvbXBvbmVudCgzKSkuY29vcmRpbmF0ZXMoTVJIKFsxLDMsMl0pKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpa4FCTA/___code___.py", line 3, in <module>
exec compile(u'(MR.homogeneous_component(_sage_const_3 )).coordinates(MRH([_sage_const_1 ,_sage_const_3 ,_sage_const_2 ]))
File "", line 1, in <module>
File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6260)
File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3110)
AttributeError: 'CombinatorialFreeModule_with_category' object has no attribute 'coordinates'
---------
I have no idea what the error is supposed to tell us, unless the CombinatorialFreeModule type really doesn't have a coordinates function...darijgrinbergMon, 27 Feb 2012 13:25:45 -0600https://ask.sagemath.org/question/8751/Find polynomial in terms of idealhttps://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/Hi,
I have been reading the tutorials and experimenting with the polynomial ring code but I have not been able to find out how to express a given polynomial in terms of the generators of an ideal. For instance, if I define a few polynomial generators of an ideal, say 'f=xyz-y^2' and 'g=x^3 + z', and have a polynomial p, I would like to express p as 'p = u*f + v*g', where I need to find the polynomials u,v. I tried a bunch of solve([],u,v) commands and such but I haven't found the magic solution. Thanks. bmandenMon, 26 Sep 2011 19:24:55 -0500https://ask.sagemath.org/question/8346/Multivariate Polynomials over Rational Function Fieldshttps://ask.sagemath.org/question/7639/multivariate-polynomials-over-rational-function-fields/Is it possible to define multivariate polynomials where the coefficients lie in a rational function field and do Groebner basis computations on them? Maple, Reduce and Axiom support this. For example I would like to be able to compute the Groebner basis of the polynomials
{v * x^2 + y, u* x * y + y^2}
where the polynomials belong to the ring Q(u,v)[x,y].
I tried the following
B.<u,v> = PolynomialRing(QQ, 'u', 'v')
R.<x,y> = PolynomialRing(B, 'x', 'y')
I = R.ideal(v * x^2 + y, u* x * y + y^2)
g = I.groebner_basis()
This fails with the error
TypeError: Can only reduce polynomials over fields.
Sameer AgarwalWed, 25 Aug 2010 20:12:25 -0500https://ask.sagemath.org/question/7639/