I'm trying to implement with Sympy the procedure described in this lecture, where Groebner basis is used to derive Heron's formula, but I'm not able to implement the last step, the computation of the correct Groebner basis, surely because of my lack of understanding of the subject. Here is the code I wrote:
import sympy as sy
sy.init_printing(use_unicode=True, wrap_line=False)
def cross(a,b): # 2D cross product
return a[0]*b[1]-a[1]*b[0]
n = 3 # number of vertices of triangle
# defining 3n+1 symbols
P = sy.Matrix(sy.MatrixSymbol('P', n, 2)) # matrix of coordinates of vertices
s = sy.symbols(f's0:{n}') # lengths of polygon' sides
A,R,cx,cy = sy.symbols('A R cx cy') # area, radius, center coordinates
C = sy.Matrix([[cx,cy]])
P[0,0] = 0
P[0,1] = 0
P[1,1] = 0
# defining 2n+1 equations
eq_area = 2*A - sum(map(cross,*zip(*((P[i,:],P[j,:]) for i,j in zip(range(n),list(range(1,n))+[0]))))) # area of polygon
eqs_vonc = [R**2-((C-P.row(r))*sy.transpose(C-P.row(r)))[0] for r in range(P.rows)] # vertices on circumference
eqs_sides = [s[i]**2-((P[i,:]-P[j,:])*sy.transpose(P[i,:]-P[j,:]))[0] for i,j in zip(range(n),list(range(1,n))+[0])] # sides lenghts
eqs = [eq_area]+eqs_sides+eqs_vonc
# compute Groebner basis
G = sy.groebner(eqs,A,R,*s,*C) # just tried
How should the last step be implemented in order to obtain the Heron's formula?