Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assigning values error

I am trying to program a toy buchberger algorithm but got stuck.

import itertools
R.<x,y,z> = PolynomialRing(QQ, order="Degrevlex")
I=ideal(x^3-2*x*y+y^4,x^2*y-2*y^2+x);
def buchberger(G):
    F = list(G.gens())
    pairs=list(itertools.combinations(F, r=2)) # makes pairs of the polynomials
    while pairs:
        f,g = pairs.pop()
        h = s_poly(f, g).reduce()
        if h != 0:
            pairs.append((f, h) for f in F)
            F.append(h)
    return F

It throws an error:

ValueError: too many values to unpack (expected 2)

At the line where I .pop the elements. Weird thing is that if I just run the commands:

pairs=[(x**2,x**3)]
f,g =pairs.pop()

I get f=x^2, g=x^3 as a result an no error message.

When pairs is empty it notifies me that I can't pop from an empty list.

Assigning values error

I am trying to program a toy buchberger algorithm but got stuck.

import itertools
R.<x,y,z> = PolynomialRing(QQ, order="Degrevlex")
I=ideal(x^3-2*x*y+y^4,x^2*y-2*y^2+x);

def s_poly(f1,f2):
    return lcm(f1.lm(),f2.lm())*(1/f1.lt()*f1-1/f2.lt()*f2)

def buchberger(G):
    F = list(G.gens())
    pairs=list(itertools.combinations(F, r=2)) # makes pairs of the polynomials
r=2))
    print(pairs[0])
    while pairs:
        f,g f1,f2 = pairs.pop()
        h = s_poly(f, g).reduce()
s_poly(f1, f2).reduce()
        if h != 0:
            pairs.append((f, h) for f in F)
            F.append(h)
    return F

B=buchberger(I)

It throws an error:

ValueError: too many values to unpack (expected 2)

At the line where I .pop the elements. Weird thing is that if I just run the commands:

pairs=[(x**2,x**3)]
f,g =pairs.pop()

I get f=x^2, g=x^3 as a result an no error message.

When pairs is empty it notifies me that I can't pop from an empty list.

Assigning values error

I am trying to program a toy buchberger algorithm but got stuck.

import itertools
R.<x,y,z> = PolynomialRing(QQ, order="Degrevlex")
I=ideal(x^3-2*x*y+y^4,x^2*y-2*y^2+x);

def s_poly(f1,f2):
    return lcm(f1.lm(),f2.lm())*(1/f1.lt()*f1-1/f2.lt()*f2)

def buchberger(G):
    F = list(G.gens())
    pairs=list(itertools.combinations(F, r=2))
    print(pairs[0])
    while pairs:
        f1,f2 = pairs.pop()
        h = s_poly(f1, f2).reduce()
        if h != 0:
            pairs.append((f, h) for f in F)
            F.append(h)
    return F

B=buchberger(I)

It throws an error:

ValueError: too many values to unpack (expected 2)

At the line where I .pop the elements. Weird thing is that if I just run the commands:

pairs=[(x**2,x**3)]
f,g =pairs.pop()

I get f=x^2, g=x^3 as a result an no error message.

When pairs is empty it notifies me that I can't pop from an empty list.