Hi,

I have the following code where I am trying to substitute solution to a
previous equation in variable y into next set of equations in x,y. I would
like lhs and rhs to be variables as sometime the code might substitute, say
z into equations containing z,p etc.,

# set the ploynomial ring
R5=PolynomialRing(QQ, 2, 'xy', order='lp')
x,y = R5.gens()
# define ideal
I5 = (x^2+2*y^2-2,x^2+x*y+y^2-2)*R5;I5
print "Ideal = ",I5
# get groebner basis
B5 = I5.groebner_basis();B5;
print "Groebner basis",B5;
first_poly = [(vars,ali) for vars in R5.gens()  for ali in B5 if not
(Set(ali.variables())-Set([vars]))]
print "DEBUG: ",first_poly
print "eliminating  ",first_poly[0][0]
print "equation     ",first_poly[0][1]
init1     = first_poly[0][0]
eq1       = first_poly[0][1]
var1      = var(init1)
sol1      = solve(SR(eq1),var1)
print sol1
remEqs     = Set(B5) - Set([eq1])
remVars    = Set(R5.gens()) - Set([init1])
for sol in sol1:
    coleq = [(e1.subs(sol)).rhs() for e1 in remEqs ]
    print coleq


I get the following output.

Ideal =  Ideal (x^2 + 2*y^2 - 2, x^2 + x*y + y^2 - 2) of Multivariate
Polynomial Ring in x, y over Rational Field
Groebner basis [x^2 + 2*y^2 - 2, x*y - y^2, y^3 - 2/3*y]
DEBUG:  [(y, y^3 - 2/3*y)]
eliminating   y
equation      y^3 - 2/3*y
[
y == -1/3*sqrt(2)*sqrt(3),
y == 1/3*sqrt(2)*sqrt(3),
y == 0
]
Traceback (most recent call last):    # get groebner basis
  File "", line 1, in <module>

  File "/tmp/tmpLpvTDH/___code___.py", line 22, in <module>
    exec compile(u'for sol in sol1:\n    coleq = [(e1.subs(sol)).rhs() for
e1 in remEqs ]\n    print coleq
  File "", line 2, in <module>

  File "multi_polynomial_libsingular.pyx", line 3203, in
sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.subs
(sage/rings/polynomial/multi_polynomial_libsingular.cpp:21540)
  File "element.pyx", line 344, in
sage.structure.element.Element.__getattr__ (sage/structure/element.c:3637)
  File "misc.pyx", line 257, in
sage.structure.misc.getattr_from_other_class (sage/structure/misc.c:1507)
AttributeError: 'sage.symbolic.expression.Expression' object has no
attribute 'iteritems'


Thanks so much.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to