Advertisement
JoelSjogren

nonic case

Mar 8th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. # setting poly_x0 = -1, poly_x1 = 1 (without loss of generality) we will want to reduce the open logical formula "∃ cops. ∀ p. the areas are proportional with coefficient λ" to a single equation in only λ. it is therefore important that lam comes last in the following declaration:
  2.  
  3. R.<p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, x, poly_x0, poly_x1, cops_x0, cops_x1, cops_x2, cops_x3, cops_x4, lam> = PolynomialRing(QQ, order='lex')
  4.  
  5. y = p0 + p1*x + p2*x^2 + p3*x^3 + p4*x^4 + p5*x^5 + p6*x^6 + p7*x^7 + p8*x^8 + p9*x^9
  6.  
  7. cops_y0 = y(x=cops_x0)
  8. cops_y1 = y(x=cops_x1)
  9. cops_y2 = y(x=cops_x2)
  10. cops_y3 = y(x=cops_x3)
  11. cops_y4 = y(x=cops_x4)
  12.  
  13. # sum of three triangles
  14. cops_area = (1/2) * ((-cops_x0+cops_x1)*(-cops_y0+cops_y2) - (-cops_y0+cops_y1)*(-cops_x0+cops_x2)) + (1/2) * ((-cops_x0+cops_x2)*(-cops_y0+cops_y3) - (-cops_y0+cops_y2)*(-cops_x0+cops_x3)) + (1/2) * ((-cops_x0+cops_x3)*(-cops_y0+cops_y4) - (-cops_y0+cops_y3)*(-cops_x0+cops_x4))
  15.  
  16. poly_y0 = y(x=poly_x0)
  17. poly_y1 = y(x=poly_x1)
  18.  
  19. # doing this the orthodox way
  20. poly_area = -integral(y, x)(x=poly_x0) + integral(y, x)(x=poly_x1) - (1/2) * (-poly_x0 + poly_x1) * (poly_y0 + poly_y1)
  21.  
  22. I = ideal(
  23.     # "∀ p. " is expressed in a mildly hacky way
  24.     diff(lam*cops_area-poly_area, p0),
  25.     diff(lam*cops_area-poly_area, p1),
  26.     diff(lam*cops_area-poly_area, p2),
  27.     diff(lam*cops_area-poly_area, p3),
  28.     diff(lam*cops_area-poly_area, p4),
  29.     diff(lam*cops_area-poly_area, p5),
  30.     diff(lam*cops_area-poly_area, p6),
  31.     diff(lam*cops_area-poly_area, p7),
  32.     diff(lam*cops_area-poly_area, p8),
  33.     diff(lam*cops_area-poly_area, p9)
  34. )
  35.  
  36. # convenient coordinate system
  37. J = I.subs(poly_x0=-1, poly_x1=1)
  38.  
  39. G = J.groebner_basis()
  40. for i in G:
  41.     print(str(i) + '\n')
  42.  
  43. # [1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement