unique-y-intersect.sage 715 B

12345678910111213141516171819202122232425262728293031323334
  1. # Lets show that div(f) = [P] - [∞]
  2. # So any divisor with supp(D) = {P},
  3. # with an effective size of 1 can be represented
  4. # by the horizontal line f = y - P.y
  5. q = 47
  6. K = GF(q)
  7. E = EllipticCurve(K, (0, 5))
  8. C = E.defining_polynomial()
  9. R.<x, y> = PolynomialRing(K)
  10. for i in range(100):
  11. P = E.random_point()
  12. Px, Py = P[0], P[1]
  13. # Skip points at infinity
  14. if P[2] == 0:
  15. continue
  16. assert P[2] == 1
  17. f = y - Py
  18. I = Ideal([C(x, y, 1), f])
  19. V = I.variety()
  20. print(P, V)
  21. assert len(V) == 1
  22. assert V[0][x] == Px
  23. assert V[0][y] == Py
  24. # Note: to reduce D = [P] - [Q], just note that
  25. # D = [P] - [Q]
  26. # = ([P] - [∞]) - ([Q] - [∞])
  27. # = div(f) - div(g) = div(f/g)