incr-set prlevel 1
if #0=4 START 
incr-set prlevel -1

;;; Usage:
;;; 	<cohomology1 i M j H
;;;
;;; Computes the cohomology module
;;; H = \sum_{n >= 0} H^i(M(n))
;;; of the module M , regarded as
;;; a coherent sheaf on projective space. 
;;; The low degree parts of the module computed may 
;;; or may not mean much (see below).
incr-set prlevel 1
jump END
;;;
;;; Parameters:
;;;		i>0 the index of the cohomology group
;;;		M 
;;;		j>0 a sufficiently large integer (see below.)
;;; Output values:
;;; 	H = Ext^i(J, M), 
;;;
;;; where J is the ideal
;;; generated by the jth powers of the variables in the
;;; base ring of M.  
;;; 	The answer coincides with the cohomology (at least)
;;; in degrees >= d - numvars + 1 - j,
;;; where d is the maximum degree of a generator of a syzygy module of M,
;;; and numvars is the number of variables in the ring.

;Created 5/13/89 by D.Eisenbud
START:

setring #2
<getvars @v

;Form the koszul matrix @J
;that presents the ideal of jth powers of the variables
;with correct degrees:
<powers @v #3 @J
koszul @J 2 @J
setdegs @J
	#3
	;

<ext #1 @J #2 #4

kill @v @J 
END:
incr-set prlevel -1

$;;;;;;;; EXAMPLE SECTION ;;;;;;;;;;;;;;;;;;;;;;;;;
reset
; The cotangent bundle of a plane curve of
;degree d is 0(d-3)
;
;Here's the case of a plane quartic
int d 4

<ring 3 xyz r

ideal i
1
x^d+y^d+z^d

<cotan i w
<prune w w
type w
betti w

;The answer is not yet of depth 2, so we must
;compute H^0_*

<cohomology1
<cohomology1 0 w 3 W
type W
<prune W W
type W
betti W
; total:      1     1 
; --------------------
;    -1:      1     - 
;     0:      -     - 
;     1:      -     - 
;     2:      -     1 

;This is the depth 2 version -- its 0(1) on the quartic.
;j=3 is really the smallest value that suffices here.
