Ask Your Question

KittyL's profile - activity

2020-04-12 12:00:34 -0500 received badge  Famous Question (source)
2020-04-01 03:22:31 -0500 received badge  Notable Question (source)
2020-04-01 03:22:31 -0500 received badge  Popular Question (source)
2020-02-02 01:17:40 -0500 received badge  Famous Question (source)
2020-01-26 04:19:50 -0500 received badge  Famous Question (source)
2019-12-18 04:36:53 -0500 received badge  Popular Question (source)
2019-07-01 10:25:24 -0500 received badge  Famous Question (source)
2018-12-11 10:12:00 -0500 received badge  Notable Question (source)
2018-12-11 10:12:00 -0500 received badge  Popular Question (source)
2018-12-06 09:21:41 -0500 received badge  Notable Question (source)
2018-12-06 09:21:41 -0500 received badge  Popular Question (source)
2018-08-30 02:45:31 -0500 received badge  Notable Question (source)
2018-08-09 18:51:21 -0500 received badge  Notable Question (source)
2018-06-17 12:32:48 -0500 received badge  Notable Question (source)
2018-03-13 23:47:58 -0500 received badge  Popular Question (source)
2017-12-11 06:49:33 -0500 received badge  Popular Question (source)
2017-09-28 17:27:31 -0500 received badge  Nice Question (source)
2017-09-18 13:26:56 -0500 commented answer Remove a variable from a polynomial ring k(a,b)[x1,x2,x0] where a,b are parameters

Thank you! That worked! How do we report the error?

2017-09-01 14:09:49 -0500 asked a question Remove a variable from a polynomial ring k(a,b)[x1,x2,x0] where a,b are parameters

I am trying to homogenize polynomials using variable x0 in a polynomial ring k(a,b)[x1,x2] defined as follows:

R.<a,b>    = PolynomialRing( QQ, order='degrevlex' )
K = FractionField( R )
RK.<x1,x2> = PolynomialRing( K, order='degrevlex' )

After homogenization, I define the new polynomial ring with block order:

RKH.<x1,x2,x0>=PolynomialRing(K,order='degrevlex(2),degrevlex(1)')

Then in my program, I need to dehomogenize my polynomials by setting x0=1, and remove the variable x0 from the polynomial ring. This works fine in a polynomial ring without the parameter fraction field. For example

P.<x,y,z>=PolynomialRing(QQ,order='degrevlex(2),degrevlex(1)')
fp=x^2+x*y+4*z^2
R=P.remove_var(z,order='degrevlex');R
R(fp(z=1)).parent()
    Multivariate Polynomial Ring in x, y, z over Rational Field
    Multivariate Polynomial Ring in x, y over Rational Field
    Multivariate Polynomial Ring in x, y over Rational Field

However, with the fraction field k(a,b), the same method does not work any more:

R.<a,b>    = PolynomialRing( QQ, order='degrevlex' )
K = FractionField( R )
RK.<x1,x2> = PolynomialRing( K, order='degrevlex' )
RKH.<x1,x2,x0>=PolynomialRing(K,order='degrevlex(2),degrevlex(1)')
pf=a*x1^2-b*x1*x2+x0^2
RKHn=RKH.remove_var(x0,order='degrevlex')
pfn=pf(x0=1)
RKHn(pfn)
Multivariate Polynomial Ring in x1, x2, x0 over Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field
Error in lines 11-11
 TypeError: not a constant polynomial

I didn't copy down the whole error message so it doesn't look so long. Is there a way to fix this? Thank you for your help!

2017-07-24 14:20:35 -0500 received badge  Popular Question (source)
2017-05-19 07:21:03 -0500 received badge  Enthusiast
2017-05-06 05:09:57 -0500 commented question Insert children of a specified node in a binary tree and retrieve all leaves of a binary tree.

Yes, you are right. I didn't link the one with "insert" since it does not provide me the functionality I was looking for. So I found another one, which does not have "insert", and still cannot do anything since it does not provide a value for each node. Now I decide I should just make a "recursive list" to achieve my goal. It seems Sage does not have a good Binary Tree implementation, at least for my purpose. Thank you for your time!

2017-05-04 14:22:32 -0500 asked a question Insert children of a specified node in a binary tree and retrieve all leaves of a binary tree.

I am trying to use a binary tree to store data. When different cases happens at some step, I will need to create two children from the current node.

I also need to collect all information on the leaves (nodes with no children). I use the following definition of binary trees:

from sage.misc.binary_tree import BinaryTree
T = BinaryTree();

I can insert node the following way:

t.insert(0,[1,2,4]);
t.insert(1,[4,5]);
t.insert(2,[5,0]);

But I couldn't find a way to visualize the tree. Also I don't know how to add two children of one certain node. For example, if 0 is the root (it seems so), 1 is its left child and 2 is its right child (which I am not sure), how do I make sure I add two children for the node 2?

I also looked at this page: (http://doc.sagemath.org/html/en/refer...). I couldn't see how to insert a node with values in it, or how to retrieve information of leaves.

Do I have to define my own tree structure?

Thank you for your help!

2017-04-20 11:57:56 -0500 commented question How to compute syzygy module of an ideal in a quotient ring?

That is a very smart solution. Thank you very much!

2017-04-18 04:34:27 -0500 asked a question How to compute syzygy module of an ideal in a quotient ring?

I am trying to compute the syzygy module of an ideal generated by two polynomials <p,q> modulo I, where I is another ideal. This means to compute a generating set [(p1,q1),...,(ps,qs)] of the module {(g,h): gp+hq is in I}. I know that in Sage, we can use singular command to compute syzygy module:

R.<x,y> = PolynomialRing(QQ, order='lex')
f=2*x^2+y
g=y
h=2*f+g
I=ideal(f,g,h)
M = I.syzygy_module();M
[       -2        -1         1]
[       -y 2*x^2 + y         0]

But this does not work with modulo I:

R.<x,y> = PolynomialRing(QQ, order='lex')
S.<a,b>=R.quo(x^2+y^2)
I=ideal(a^2,b^2);I
M = I.syzygy_module();M
Ideal (-b^2, b^2) of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
Error in lines 4-4
Traceback (most recent call last):

Is there a way to do that?

2017-04-15 04:18:18 -0500 received badge  Commentator
2017-04-15 04:18:18 -0500 commented answer Division algorithm in a polynomial ring with variable coefficients

Thank you for the detailed answer! It worked!

2017-03-27 14:26:48 -0500 asked a question Division algorithm in a polynomial ring with variable coefficients

I am working on an algorithm to divide a polynomial f by a list of polynomials [g1, g2, ..., gm]. The following is my algorithm:

def div(f,g): # Division algorithm on Page 11 of Using AG by Cox;
# f is the dividend;
# g is a list of ordered divisors;
# The output consists of a list of coefficients for g and the remainder;
# p is the intermediate dividend;
n = len(g)
p, r, q = f, 0,  [0 for x in range(0,n)]
while p != 0:
    i, divisionoccured = 0, False
    print(p,r,q);
    while i < n and divisionoccured == False:
        if g[i].lt().divides(p.lt()):
            q[i] = q[i] + p.lt()//g[i].lt()
            p = p - (p.lt()//g[i].lt())*g[i]
            divisionoccured = True
        else:
            i = i + 1
    if divisionoccured == False:
        r = r + p.lt()
        p = p - p.lt()
return q, r

Here is an example of implementing the algorithm:

K.<a,b> = FractionField(PolynomialRing(QQ,'a, b'))
P.<x,y,z> = PolynomialRing(K,order='lex')
f=a*x^2*y^3+x*y+2*b
g1=a^2*x+2
g2=x*y-b
div(f,[g1,g2])

Here is the result:

(a*x^2*y^3 + x*y + 2*b, 0, [0, 0])
(((-2)/a)*x*y^3 + x*y + 2*b, 0, [1/a*x*y^3, 0])
(x*y + 4/a^3*y^3 + 2*b, 0, [1/a*x*y^3 + ((-2)/a^3)*y^3, 0])
(4/a^3*y^3 + ((-2)/a^2)*y + 2*b, 0, [1/a*x*y^3 + ((-2)/a^3)*y^3 + 1/a^2*y, 0])
(((-2)/a^2)*y + 2*b, 4/a^3*y^3, [1/a*x*y^3 + ((-2)/a^3)*y^3 + 1/a^2*y, 0])
(2*b, 4/a^3*y^3 + ((-2)/a^2)*y, [1/a*x*y^3 + ((-2)/a^3)*y^3 + 1/a^2*y, 0])
Error in lines 6-6
Traceback (most recent call last):

and some other error messages.

We can see that it worked well until the leading term is 2b. it does not recognize the 2b as a term. I tried:

(x).lt().divides(1)

It gives the answer False. But I tried

(x).lt().divides(a)

It gives error message. Is there a way to solve this? Thank you for your help!

2017-03-13 05:19:06 -0500 commented answer The computation of Groebner basis not correct?

I realized I forgot to put order='lex'. Sage must have identified the 'lex' as a variable. Thanks.

2017-03-12 16:44:16 -0500 commented answer The computation of Groebner basis not correct?

Thanks for your answer! I never set parameters. So what is the default? I thought 'lex' means lexicographical order, with whichever order placed in the '< >'. I will check the instructions.

2017-03-12 14:59:54 -0500 asked a question The computation of Groebner basis not correct?

I was trying to compute a Groebner basis for the ideal I=<xz-y, y^2+z,x+1/2yz>, using lex order.

I used the following code:

P.<x,y,z>=PolynomialRing(QQ,'lex')
I=ideal(x*z-y,y^2+z,x+(1/2)*y*z)
G=I.groebner_basis();G

The result is

[z^3 + 2*z, x^2 - 1/2*z, x*y - 1/2*z^2, y^2 + z, x*z - y, y*z + 2*x]

Since the computation is easy, I checked by hands but got different result. So I checked by Singular and got the same result as mine, which is

> groebner(I);
_[1]=z3+2z
_[2]=yz2+2y
_[3]=y2+z
_[4]=2x+yz

So the result from Sage is wrong, since yz^2+2y is in the ideal I, but is not in the Groebner basis from the first computation using I.groebner_basis(). Did I miss something in my command? Or is there a bug that needs to be fixed?

2017-02-28 16:53:33 -0500 commented question Computing square free part of a multivariate polynomial

Do you mean an example? For example, if f is in Q[x,y,z], then f could be (x-y)^2*(y-z)^2*(x+y+3). Then the square free part would be (x-y)*(y-z)*(x+y+3).

2017-02-28 14:49:14 -0500 asked a question Computing square free part of a multivariate polynomial

In one of the algorithms I am working on, there is a part asking for the square-free part of a multivariate polynomial. I can find it using a complicated way, namely,

I = ideal(f)
IRad = I.radical().groebner_basis()

But I think this must be a very inefficient way to do it. Is there a better way? Thank you!

2016-05-24 08:27:09 -0500 received badge  Editor (source)
2016-05-24 08:27:09 -0500 edited question Find the kernel of a matrix $A$ and make it a matrix.

I am trying to write a function that computes the monic genrator of an ideal $I\in k[x_1,\dots,x_n]$, i.e., the generator of $I\cap k[x_i]$ for each $i$. For this I need to use linear algebra for the set $${1, x_i, x_i^2,\dots}$$ I write each one of them in terms of the basis for the quotient ring $k[x_1,\dots,x_n]/I$, and see if they are linearly dependent.

Since I add in one more power a time, when I find a linearly dependent set, it should have nullity $1$. So if I can get the one element in basis of the kernel, I am done. But the $A.kernel()$ command in Sage gives me this:

N=M.kernel();N
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

Is there a way to assign it as a vector using the kernel command? Or do I have to write my own function to implement it? Thank you for your help!

2016-05-24 08:26:51 -0500 commented answer Find the kernel of a matrix $A$ and make it a matrix.

Thank you. This works perfectly. And I am pretty sure I'll have one element in the basis. But I'll change the title. One more question, I also defined matrix A using "A=matrix(...)" and it worked. But after I tried import scipy, it does not work anymore. I have to do "A=Matrix(...)" instead. Since I don't want to use scipy anymore, is there a way to "export" this package?