1)
R.<z,a1,a2,b1,b2,c1,c2> = PolynomialRing(QQ)
A = vector((a1, a2))
B = vector((b1, b2))
C = vector((c1, c2))
$\vec{AB} \perp \vec{BC}$
eq1 = (A - B) * (B - C)
eq1
Centre of circle is central point of $\overline{AC}$.
M = 1/2 * (A + C)
All three points lie on a circle: \begin{align*} ||\vec{AM}|| = ||\vec{BM}|| = ||\vec{CM}|| \end{align*}
By definition of $M$:
\begin{align*} ||\vec{AM}|| = ||\vec{CM}|| \end{align*}We can also take the squared norm instead of the norm. Hence, we obtain \begin{align*} ||\vec{BM}||^2 - \underbrace{||\vec{AM}||^2}_{=:r} = 0 \end{align*}
# r radius of circle
r = (A - M).dot_product(A - M)
dist = (B - M).dot_product(B - M)
eq2 = r - dist
$\vec{AB} \perp \vec{BC} \Rightarrow ||\vec{BM}||^2 - ||\vec{AM}||^2 = 0$
$\vec{AB} \perp \vec{BC} \land ||\vec{BM}||^2 - ||\vec{AM}||^2 \neq 0$
I = ideal(eq1, eq2*z - 1)
I.groebner_basis()
$||\vec{BM}||^2 - ||\vec{AM}||^2 = 0 \Rightarrow \vec{AB} \perp \vec{BC}$
$||\vec{BM}||^2 - ||\vec{AM}||^2 = 0 \land \vec{AB} \not\perp \vec{BC}$
I2 = ideal(eq1*z - 1, eq2)
I2.groebner_basis()
2)
# colinear
def cl(P1, P2, P3):
return det(matrix([P1, P2, P3]))
R.<z1,z2,z3,z4,z5,s1,s2,a1,a2,b1,b2,c1,c2,d1,d2,e1,e2,f1,f2,h1,h2,i1,i2,j1,j2> = PolynomialRing(QQ, order = 'deglex')
S = [s1, s2, 1]
A = [a1, a2, 1]
B = [b1, b2, 1]
C = [c1, c2, 1]
D = [d1, d2, 1]
E = [e1, e2, 1]
F = [f1, f2, 1]
H = [h1, h2, 1]
I = [i1, i2, 1]
J = [j1, j2, 1]
Sys1 = [cl(S,A,D),
cl(S,B,E),
cl(S,C,F),
cl(A,B,H),
cl(D,E,H),
cl(A,C,J),
cl(D,F,J),
cl(B,C,I),
cl(E,F,I),
cl(E,A,D) * z1 - 1,
cl(F,A,D) * z2 - 1,
cl(F,B,E) * z3 - 1,
cl(C,A,D) * z4 - 1,
cl(H,I,J) * z5 - 1]
Sys1
I = ideal(Sys1)
I.groebner_basis() # takes long
4)
R.<z,x,y> = PolynomialRing(QQ)
f = x^4*y + x^3*y^2 - 2*x^2*y^2 - 2*x*y^3 + x + y
g = x^4*y - x^3*y^3 - 2*x^2*y^2 + 2*x*y^4 + x - y^2
I = ideal(z*f, (z-1)*g)
I.elimination_ideal(z)
I.elimination_ideal(z).groebner_basis()
LCM = I.elimination_ideal(z).groebner_basis()[0]
LCM
f*g/LCM
f.gcd(g)