incr-set prlevel 1
if #0>=4 START
incr-set prlevel -1
;;; Usage:
;;; 	<rational_surface d pointsmat ringname I [mults]
;;;
;;; computes the ideal I of the rational surface which is the image of 
;;; P2 under a linear series of the form |dL - \sum ni pi|, where L is
;;; a line in P2, pi are points in P2 specified in pointsmat, ni are
;;; optional multiplicities specified as the degree of the generators
;;; in the ideal mults.
;;; Example of a pointsmat for the 4 coordinate points:
;;;     1 0 0 1
;;;     0 1 0 1
;;;     0 0 1 1
;;; Example of a suitable matrix for mults:
;;;     a5 a7 a a3
;;;
;;; The output I is an ideal over a new ring, formed by the program,
;;; with name "ringname"
;;;
;;; The script calls "rational_surface1" to find the linear series.
;;;
incr-set prlevel 1
jump END
;;; Parameters:
;;;        d positive = integer
;;;        pointsmat = integer 3xn matrix
;;;        [mults] = optional ideal
;;;	        ringname = name for output ring.
;;; Output values:
;;;        I an ideal over a new ring, having variables a,b,...
; created 5/10/90 DE
START:

;form the linear series:

if #0=5 withmults
<rational_surface1 #1 #2 @L
jump continue
withmults:
<rational_surface1 #1 #2 @L #5
continue:

shout echo the linear series is:
shout betti @L

;Now use it to embed P2
ncols @L @n
<ring @n a-z #3
<subring @L #4

kill @L @n
END:
incr-set prlevel -1

$;;;;;;;; EXAMPLE SECTION ;;;;;;;;;;;;;;;;;;;;;;;;;
;The del Pezzo of degree 9-e
reset
int e 5

<ring 3 a-z r
random 3 e p
<rational_surface 3 p s I
<res I I
betti I

; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;An easy example with multiplicities:
<ring 3 a-z r
random 3 3 p
<ideal mul a2 a a
<rational_surface 3 p s I mul
<res I I
betti I

listvars

; ;;;;;;;;;;;;;;;;;
;The surface of ype 3,5 on the Grassmannian:
reset
<ring 3 a-z r
<column_vector p 1 1 1
<column_vector q1 1 0 0
<column_vector q2 0 1 0
<column_vector q3 0 0 1
concat p q1
concat p q2
concat p q3
random 3 6 p2
concat p p2
type p
<ideal mul a2 a2 a2 a2 a2 a2 a a a a
set prlevel -3
<rational_surface 6 p s I mul
<res I I
betti I
