Dear Carl,
I like your code; it is elegant and realy quick
but it seems that finishing your code
with Paul Zimmermann's approach

I2 = singular(I).groebner()
#print I.reduce(n12);
print singular.reduce((n12), I2)

(althout less elegant)
is a little bit faster
(0.06 -> 0.05 on my comp. :)

I want also add a question to David Harvey questions

In experimenting with Lenstra factorization method one needs
multiplication on ell.curv over the Ring Z_(p*q). GP-Pari allows
for that so I'm  doing it using gp interface. Is it difficult to
implement
a similar functionality in Sage?

Andrzej Chrzeszczyk

On 15 Sty, 03:28, David Harvey <[EMAIL PROTECTED]> wrote:
> On Jan 14, 2008, at 10:09 PM, Carl Witty wrote:
>
>
>
> > Here is a more idiomatic way to do this computation in Sage.  We work
> > in the fraction field of a multivariate polynomial ring; this means
> > that our polynomial arithmetic is handled by libSingular instead of by
> > maxima, and that we can get the numerator directly with "numerator",
> > since fraction field elements are always normalized.  Also, we use
> > Sage's wrapper of ideals and Groebner bases (which I believe is
> > implemented with libSingular), rather than calling Singular.
> > (Avoiding the call to "factor(s1-s2)" means that this version is much
> > faster.)
>
> > sage: R.<x1,y1,x2,y2,x3,y3,a,b> = QQ[]
> > sage: eq1 = y1^2 -(x1^3+a*x1+b)
> > sage: eq2 = y2^2 -(x2^3+a*x2+b)
> > sage: eq3 = y3^2 -(x3^3+a*x3+b)
> > sage: lambda12 = (y1 - y2)/(x1 - x2)
> > sage: x4       = (lambda12*lambda12 - x1 - x2)
> > sage: nu12     = (y1 - lambda12*x1)
> > sage: y4       = (-lambda12*x4 - nu12)
> > sage: lambda23 = ((y2 - y3)/(x2 - x3))
> > sage: x5       = (lambda23*lambda23 - x2 - x3)
> > sage: nu23     = (y2 - lambda23*x2)
> > sage: y5       = (-lambda23*x5 - nu23)
> > sage: s1 =(x1 - x5)*(x1 - x5)*((y3 - y4)*(y3-y4) - (x3+x4)*(x3-x4)*
> > (x3-
> > x4))
> > sage: s2 =(x3 - x4)*(x3 - x4)*((y1 - y5)*(y1-y5) - (x1+x5)*(x1-x5)*
> > (x1-
> > x5))
> > sage: n12 = numerator(s1-s2)
> > sage: I = ideal([eq1,eq2,eq3])
> > sage: I.reduce(n12)
> > 0
>
> What would be *really* nice is if we could work directly in the
> fraction field of the quotient of R.<x1,y1,x2,y2,x3,y3,a,b> by the
> appropriate ideal. (Does that even make sense? Is the ideal prime?) I
> tried to do this but Sage gave up pretty quickly on me. A nice encore
> would be to do this using Sage's elliptic curve class to do the
> actual arithmetic. After all EllipticCurves can be defined over any
> field....
>
> Here's my dream session:
>
> sage: R.<x1,y1,x2,y2,x3,y3,a,b> = QQ[]
> sage: I = R.ideal(y1^2 - x1^3 - a*x1 - b, y2^2 - x2^3 - a*x2 - b,
> y3^2 - x3^3 - a*x3 - b)
> sage: S = FractionField(R.quotient(I))     # currently barfs
> sage: E = EllipticCurve(S, [a, b])
> sage: P1 = E(x1, y1)
> sage: P2 = E(x2, y2)
> sage: P3 = E(x3, y3)
> sage: (P1 + P2) + P3 == P1 + (P2 + P3)
> True
>
> Here's the traceback in the FractionField line:
>
> /Users/david/sage-2.9/local/lib/python2.5/site-packages/sage/rings/
> fraction_field.py in FractionField(R, names)
>      104     if not ring.is_Ring(R):
>      105         raise TypeError, "R must be a ring"
> --> 106     if not R.is_integral_domain():
>      107         raise TypeError, "R must be an integral domain."
>      108     return R.fraction_field()
>
> /Users/david/sage-2.9/local/lib/python2.5/site-packages/sage/rings/
> quotient_ring.py in is_integral_domain(self)
>      226
>      227         """
> --> 228         return self.defining_ideal().is_prime()
>      229
>      230     def cover_ring(self):
>
> /Users/david/sage-2.9/local/lib/python2.5/site-packages/sage/rings/
> ideal.py in is_prime(self)
>      275
>      276     def is_prime(self):
> --> 277         raise NotImplementedError
>      278
>      279     def is_principal(self):
>
> This suggests maybe the only barrier here is checking primality of
> the ideal? After that, the fraction field magic should just work
> right? But surely there is code somewhere to check primality, isn't
> this in singular or something? I don't know anything about the
> implementation of multivariate polynomial rings, maybe someone else
> can help out here.
>
> david
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to