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.Tue, 24 Apr 2018 14:21:01 -0500Number field basis containing 1http://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 -0500http://ask.sagemath.org/question/42150/Pass a list of variable names as parameter to a polynomial ringhttp://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 -0500http://ask.sagemath.org/question/33526/Writing elements as a linear combination in a basis in a quotient ringhttp://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 -0500http://ask.sagemath.org/question/33322/Represent field element in normal basishttp://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 -0500http://ask.sagemath.org/question/33004/Separate Variable of Matix (Get Basis)http://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 -0500http://ask.sagemath.org/question/29818/Can I get coefficients of a vector with respect to given basis for a vector space.http://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 -0600http://ask.sagemath.org/question/24926/Changing basis on a vector spacehttp://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 -0500http://ask.sagemath.org/question/10327/Defining Clifford Algebrashttp://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 -0600http://ask.sagemath.org/question/9704/How to reference algebra monomials?http://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 -0500http://ask.sagemath.org/question/9130/How to get coordinates of an element of a combinatorial free module?http://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 -0600http://ask.sagemath.org/question/8751/Find polynomial in terms of idealhttp://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 -0500http://ask.sagemath.org/question/8346/Multivariate Polynomials over Rational Function Fieldshttp://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 -0500http://ask.sagemath.org/question/7639/