#MAPLE script  for computing the number of varieties defined by a net of quadrics of determinantal type #incident to the appropriate number of lines in projective space, e.g., number of twisted cubics incident to #12 lines in P^3, adapted by A. Meireles from a script by P. Meurer , The Number of Rational Quartics #on Calabi-Yau hypersurfaces in Weighted Projective Space,  Math. Scandin, 78, 63-83 1996, preprint #alg-geom/9409001.
#dual representation
dualrep:= proc(C) local i;
sort(expand(subs( seq(x.i=x.i^(-1), i=0..n), C)))
end:
# Se C* -T é um subgrupo a um parâmetro dado pelos pesos w0,...,wn, # o caracter xi restringe a t^(wi), i=0..3.
# prodwts(H) calcula o produto de todos os pesos da representação H
prodwts:= proc(H) local t, cof, mon, res, i;
cof:= [coeffs(H, [seq(x.i, i=0..n)],'mon' )]:
mon:= subs(seq(x.i=t^w.i, i=0..n),[mon]):
res:=1:
for i from 1 to nops(mon) do
res:= res*subs(t=1,diff(mon[i],t))^cof[i]: od:
res
end:
# sumwts(H) calcula a soma de todos os pesos da representação H
sumwts:= proc(H) local t, cof, mon, res, i;
cof:= [coeffs(H, [seq(x.i, i=0..n)],'mon' )]:
mon:= subs(seq(x.i=t^w.i, i=0..n), [mon]): res:=0:
for i from 1 to nops(mon) do
res:= res+subs(t=1,diff(mon[i],t))^cof[i]:
od: res
end:
# TGrass(idd,E) calcula o espaco tangente de Grass(2, E) em idd=<q1,q2
TGrass:= proc(idd_,E_)
expand( (E_ - idd_)*dualrep(idd_) ):
end:
# Blow_up(TB , TX ) calcula o espaco tangente ( e o fibrado O(B') ) blow up de X  ao longo de B
Blow_up:=proc(TB_,TX_) local Tang_, i , N_, TL_, TPN_;
N_:=expand(TX_-TB_):
for i from 1 to nops(N_) do
TL_:=op(i,N_):
TPN_:=expand( (N_-TL_)/TL_ ):
Tang_[1][i]:= expand(TB_ + TL_ + TPN_):
# Tang_[1] guarda o espaco tangente total
Tang_[2][i]:=TL_:
# Tang_[2] guarda a direcao normal
od:
Tang_[3]:=nops(N_):
Tang_[4]:=N_:
Tang_
end:
#Aqui comeca o calculo efetivo, n=2,3.4
for n from 2 to 4 do
d:= (n+2)*(n+1) - n*(n-1) -4 +2*(n-2);
xx:= seq(x.i, i=0..n);
ww:= seq(w.i, i=0..n);
# F e' o espaco gerado por  xi, i=0..n
F:=0: for i from 0 to n do F:= F + x.i od: F:=F;
# Primeiro calculamos todos os dados para X^ = terceiro blowing up de X = G(2, E|Go).
fp:= 0; ## fp contará o número de pontos fixos
chave=0:
# Calculoos para pontos fixos em X - (B U Y1 U Y2), X = G( 2 , E|Go ).# Sabemos que sao 7.
for j1 from 1 to n-1 do
 for j2 from j1+1 to n do
X1:=x.j1: X2:=x.j2:
F_:=expand(X1+X2):
X3:=op(1,F-X1-X2-x0):X4:=expand(F-X1-X2-X3-x0):
EGo:=expand(X1*F+X2*F-X1*X2):
# TGo(r) calcula o espaco tangente de Go em r
TBase:=
expand( (F- (X1+X2) - x0)*dualrep( (X1+X2) ) ): q_:=dualrep(X1+X2):
cont1:=0: cont2:=0: cont3:=0:
################### # Na base
for i0 from 0 to n do
for i1 from i0 to n do
if ( (x.i0=X1) or (x.i0=X2) or (x.i1=X1) or (x.i1=X2) )then
for i2 from i0 to n do
for i3 from i2 to n do
if ( (x.i2=X1) or (x.i2=X2) or (x.i3=X1) or (x.i3=X2) ) then
if ( (x.i0*x.i1<>x.i2*x.i3) and (i0<>i2) and (i0<>i3) and (i1<>i2) and (i1<>i3) ) then
fp:=fp+1:
A[fp]:=x.i0*x.i1+x.i2*x.i3:
Q[fp]:=q_: id[fp]:=[A[fp],0,0,0]:
T[fp]:=expand(TGrass(A[fp],EGo) + TBase):
E1[fp]:=1: E2[fp]:=1: E3[fp]:=1:
fi: fi: od: od: fi: od: od:
# Na primeira explosao
# Primeiro tipo: Por exemplo: x1x0 + x1x2
for k from 1 to 2 do
for i0 from 0 to n-1 do
for i1 from (i0+1) to n do
X:=X.k: Y:=expand(F_-X):
TB:=expand( (F- x.i0 - x.i1)*dualrep(x.i0+x.i1) + Y/X ):
Tang:=Blow_up( TB,TGrass(X*x.i0+X*x.i1,EGo)):
T1:=Tang[1]:
T2:=Tang[2]:
for i from 1 to Tang[3] do
# Procurando pontos em Y1 inter B = Y1 inter Y2 que estarao em Y1' (ou Y2')
if ( ( ((x.i0=X) and (x.i1=Y)) or ((x.i0=Y) and (x.i1=X)) ) and ( member(x.i0*x.i1*T2[i]/Y,{op(F)}) ) ) then cont1:=cont1+1:
Taux1[1][cont1]:=T1[i]: Taux1[2][cont1]:=T2[i]:
Taux1[3][cont1]:=[X,Y,x.i0,x.i1,x.i0*x.i1*T2[i]/Y]:
elif ( ( (x.i0=X) or (x.i1=X) ) and ( member(x.i0*x.i1*T2[i]/Y, {op(F)}) ) ) then
cont3:=cont3+1:
Taux3[1][cont3]:=T1[i]: Taux3[2][cont3]:=T2[i]: Taux3[3][cont3]:=1:
Taux3[4][cont3]:=[X,Y,x.i0,x.i1, x.i0*x.i1*T2[i]/Y]:
else
fp:=fp+1:
A[fp]:=X*x.i0+X*x.i1:
Q[fp]:=q_: id[fp]:=[A[fp],X*x.i0*x.i1*T2[i]/Y,0,0]:
E1[fp]:=T2[i]:
E2[fp]:=1: E3[fp]:=1:
T[fp]:=expand(T1[i]+TBase):
fi: od: od: od: od:
# Na segunda explosao
# primeiro tipo: X^2 + XY + XZ
for k from 1 to cont1 do
X:=Taux1[3][k][1]: Y:=Taux1[3][k][2]:Z1:=Taux1[3][k][3]:Z2:=Taux1[3][k][4]: Z:=Taux1[3][k][5]:
Tang:=Blow_up( expand( Y/X + Z/X + (F-F_- Z)/Z ), expand(Taux1[1][k]) ):
T1:=Tang[1]:
T2:=Tang[2]:
for i from 1 to Tang[3] do
if ( member(T2[i]*Y,{op(F)}) ) then
cont2:=cont2+1:
Taux2[1][cont2]:=T1[i]: Taux2[2][cont2]:=Taux1[2][k]: Taux2[3][cont2]:=T2[i]:
Taux2[4][cont2]:=[X,Y,Z1,Z2,Z,T2[i]*Y]:
else
fp:=fp+1:
A[fp]:=X^2+X*Y:
Q[fp]:=q_: id[fp]:=[A[fp],X*Z, T2[i]*X*Y*Z,0] :
E1[fp]:=Taux1[2][k]:
E2[fp]:=T2[i]: E3[fp]:=1:
T[fp]:=expand(T1[i]+TBase):
fi: od: od:
# segundo tipo: WX + WY ( + W^2 )
for k from 0 to n do
if ( (x.k<>X1) and (x.k<>X2) ) then
idd:=x.k*X1+x.k*X2:
Tang:=Blow_up(expand((F-x.k)/x.k) ,TGrass(idd,EGo) ):
T1:=Tang[1]:
T2:=Tang[2]:
for i from 1 to Tang[3] do
fp:=fp+1:
A[fp]:=idd:
Q[fp]:=q_: id[fp]:=[A[fp],x.k^2,T2[i]*x.k*X1*X2,0]:
E1[fp]:=1:
E2[fp]:=T2[i]: E3[fp]:=1:
T[fp]:=expand(T1[i]+TBase):
od:fi:od:
# Na terceira explosao
# primeiro tipo: por exemplo: X^2 + XY + XZ + XZK
for k from 1 to cont2 do
X:=Taux2[4][k][1]: Y:=Taux2[4][k][2]:
Z1:=Taux2[4][k][3]: Z2:=Taux2[4][k][4]:
Z:=Taux2[4][k][5]: K:=Taux2[4][k][6]:
idd:=X^2+X*Y:
Tang:=Blow_up( expand( (F-F_-K)/K + K/Y +(F-F_-Z)/Z + Y/X), Taux2[1][k]):
for i from 1 to Tang[3] do
fp:=fp+1:
A[fp]:= idd:
Q[fp]:=q_:
id[fp]:= [X,Y,Z,K, X*Z*K, Tang[2][i]*K*Z*X, Tang[2][i]]: #[idd, X*Z, X*Z*K, Tang[2][i]*X*Z*K^2 ]:
E1[fp]:=Taux2[2][k]:
E2[fp]:=Taux2[3][k]:
E3[fp]:=Tang[2][i]:
T[fp]:=expand(Tang[1][i] + TBase):
od:od:
# segundo tipo: por exemplo: X^2 + XK + XZ #print(cont3);
for k from 1 to cont3 do
X:=Taux3[4][k][1]: Y:=Taux3[4][k][2]:
Z1:=Taux3[4][k][3]: Z2:=Taux3[4][k][4]:
Z:=Taux3[4][k][5]:
if (Z1=X) then K:=Z2 else K:=Z1 fi:
idd:=X^2+X*K:
Tang:=Blow_up( expand( Y/X + (F-X-K-Z)/Z + (F-X-K)/K ) , Taux3[1][k]):
for i from 1 to Tang[3] do
fp:=fp+1:
A[fp]:= idd:
Q[fp]:=q_:
id[fp]:= [X,Y,Z,K, Tang[2][i]*X*Z*K] :
E1[fp]:=Taux3[2][k]:
E2[fp]:=Taux3[3][k]:
E3[fp]:=Tang[2][i]:
T[fp]:=expand( Tang[1][i] + TBase):
od:od:od:od:
#WG:=#linalg[randvector](n+1,entries=rand(1..20));#
  #       [-2,7,13,17,39,97];
#wg:= seq(w.(i-1)=WG[i], i=1..n+1);
wg := w0 = 45, w1 = -8, w2 = -93, w3 = 91, w4 = 43, w5 = -67;
resultado:=0:
for i from 1 to fp do if i mod 100=1 then print(i,fp-i)fi;
den:=subs(wg,prodwts(T[i])):
f1:=subs(wg,sumwts(A[i])):
f2:=subs(wg,sumwts(Q[i])):
f3:=subs(wg,sumwts(E1[i])):
f4:=subs(wg,sumwts(E2[i])):
f5:=subs(wg,sumwts(E3[i])):
f:= -2*f1-f2-f3-f4-f5: # incidencia ( OK )
f:=(f^d)/den:
resultado:=simplify(resultado+f):
od:
lprint(`num ptos fixos calculados:`,fp);
if n=2 then lprint(`Number of triangles incident to `, d,` lines in P^`.n,` = `,resultado);
elif n=3 then lprint(`Number of twisted cubics incident to `, d,` lines in P^`.n,` = `,resultado);
elif n=4 then lprint( `Number of rational ruled cubics incident to `, d,` lines in P^`.n):
lprint(` = `,resultado);
fi; resultado; od: