Hi Andrew!

On 12 Okt., 11:34, andrew ewart <aewartma...@googlemail.com> wrote:
> If I is Ideal(x+y+z-3,x^2+y^2+z^2-5,x^3+y^3+z^3-7) and X=V(I), where
> V(I) is the variety of I
> and I have the following code
> Code:
> P.<x,y,z> = PolynomialRing(CC,order='lex')
> I = Ideal(x+y+z-3,x^2+y^2+z^2-5,x^3+y^3+z^3-7)
> ans=I.groebner_basis()

First of all, it is better to use QQ as coefficients, not CC. Even if
you eventually want to compute complex solutions, a Gröbner basis
computation in QQ would suffice - and have *theoretically* the same
result as over CC. *Practically*, a computation over CC may give you a
wrong result, because Gröbner basis computations are rather fragile if
rounding errors occur.

> how do I use this lex grobner basis to produce code that would output
> the size of the set X

What do you mean by "size"? Vector space dimension, if the Krull
dimension is zero?

Then you can proceed like this:

sage: P.<x,y,z> = QQ[]  # polynomial ring with exact coefficients
sage: I = Ideal(x+y+z-3,x^2+y^2+z^2-5,x^3+y^3+z^3-7)
sage: G = I.groebner_basis()
sage: type(G)
<class 'sage.structure.sequence.Sequence'>

In order to compute dimension etc, you need to have an ideal, not a
sequence. Hence:

sage: IG = P*G   # another syntax for creating an ideal
sage: type(IG)
<class
'sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal'>
sage: IG.dimension?  # if you like to learn what it does
sage: IG.dimension() # this is the Krull dimension
0

By the way, here is a way to learn about the existence of methods. If
you are interested into the vector space dimension, then a reasonable
guess is that the method name starts with "ve". So, you may do
sage: IG.ve<hit TAB-key>   # this shows you all possible name
extensions
IG.vector_space_dimension  IG.version
sage: IG.vector_space_dimension()  # this is (I guess) your expected
result
6

By the way, it would not work over CC:
sage: PC = PolynomialRing(CC,['x','y','z'])
sage: IC = I.gens()*PC
sage: GC = IC.groebner_basis()
sage: IGC = GC*PC
sage: IGC.dimension()
0
sage: IGC.vector_space_dimension()
Traceback (most recent call last):
...
TypeError: Cannot call Singular function 'vdim' with ring parameter of
type '<class
'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain'>'

I guess this is in order to avoid nonsensical results over inexact
fields.

Cheers
Simon

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to