###################################################################### ##NSFdms: Save this file as NSFdms. # #Also download the file DMSDATA # #To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read NSFdms : # ##Then follow the instructions given there # ## # ##Written by the students of Doron Zeilberger's class, Spring 1998, # #Math 502, Temple University , # #zeilberg@math.temple.edu. # ####################################################################### #Created: Oct. 1, 1998 #This version: Oct. 6, 1998 #NSFdms: A Maple package to study NSF Funding for MATH #Must have the data file DMSDATA #Please report bugs to zeilberg@math.temple.edu read DMSDATA: print(`This is NSFdms, a Maple package for analalyzing the funding`): print(`by the Division of Mathematical Sciences of the National Science`): print(`Foundation. It must be accompanied by a data set. The data set`): print(`for 1998 (downloaded from the NSF website 10/5/98, and converted`): print(`to Maple format), should be downloaded from `): print(` http://www.math.temple.edu/~ekhad/nsf/README.html `): print(` or directly:http://www.math.temple.edu/~ekhad/nsf/NSFDATA `): print(`Created: July. 29, 1998.`): print(`This version: Oct. 6, 1998`): lprint(``): print(`Written by Doron Zeilberger's Spring 1998 Math 502 class`): print(`Under the guidance of their beloved prof`): lprint(``): print(`Please report bugs to zeilberg@math.temple.edu`): lprint(``): print(`The most current version of this package and paper`): print(` are available from`): print(`http://www.math.temple.edu/~zeilberg/pj.html`): print(`For a list of the procedures type ezra(), for help with`): print(`a specific procedure, type ezra(procedure_name)`): print(``): print(`Disclaimer: The NSF does not give in the major heading`): print(` the names of the co-PIS `): print(`To find out the names of the co-PIs you must go to the `): print(`NSF website http://www.nsf.gov/`): print(``): ezra:=proc() if args=NULL then print(`To see the list of sets of grants available, type: `): print(`Prorgams(); To get info for ALL of MATH take the set to be`): print(` MATH `): print(`For example, to find out the ranking of the Institutions `): print(` according to Total money funded,`): print(` in Algebra and Number Theory, type InstListTM(ANT); `): print(` To see the analogous for all math, type InstListTM(MATH); `): lprint(``): lprint(``): print(`Contains the following procedures: Amts, AveAmt, FundPI, FundPol, `): print(` GrantsInInst,GrantsOfPI, INSTs, InstListAM, InstListMAX,`): print(`InstListNUGrants, InstListTM, `): print(` InstTableInfo, InstTableSet, PIList, PIs, Programs`): print(` Shorten1, STATEs `): fi: if nops([args])=1 and op(1,[args])=AveAmt then print(`AveAmt(Set1): gives the average grant-size (per year)`): print(`Investigators of the given set of grants`): fi: if nops([args])=1 and op(1,[args])=GrantsOfPI then print(`GrantsOfPI(PI,Set): Given a Principal Investigator, PI,`): print(`(as a list [PI,Inst])`): print(`and a set of grants, Set, finds all the grants that belong`): print(`to that individual that belong to the set`): print(`In particular to get all the Math grants from that`): print(`Institute do: GrantsOfPI(PI,MATH):`): fi: if nops([args])=1 and op(1,[args])=PIsI then print(`PIsI(Set1): gives the set of the funded Principal`): print(`Investigators, followed by the Institution of the given set`): print(` of grants`): fi: if nops([args])=1 and op(1,[args])=InstListMAX then print(`InstListMAX(Set1): The list of Institutions`): print(`funded in the set of grants Set1, in decreasing`): print(`order of max-amount/grant/year`): fi: if nops([args])=1 and op(1,[args])=GrantsInInst then print(`GrantsInInst(Inst,Set): Given an institutions, Inst,`): print(`and a set of grants, Set, finds all the grants from`): print(`that instition that belong to the set`): print(`In particular to get all the Math grants from that`): print(`Institute do: GrantsInInst(Inst,MATH): `): fi: if nops([args])=1 and op(1,[args])=InstListNUGrants then print(`InstListNUGrants(Set1): The list of Institutions`): print(`funded in the set of grants Set1, in decreasing`): print(`order of number of grants`): fi: if nops([args])=1 and op(1,[args])=InstListAM then print(`InstListAM(Set1): The list of Institutions`): print(`funded in the set of grants Set1, in decreasing`): print(`order of average money per PI`): fi: if nops([args])=1 and op(1,[args])=InstListTM then print(`InstListTM(Set1): The list of Institutions`): print(`funded in the set of grants Set1, in decreasing`): print(`order of total money`): fi: if nops([args])=1 and op(1,[args])=InstTableInfo then print(`InstTableInfo(Set1): A table that shows for every Instition`): print(`that participates in the set of grants, Set1, a`): print(`he total number of PIs funded, followed by`): print(`the total amount funded by PIs in that Institution,`): print(`followed by the average amt per PI`): fi: if nops([args])=1 and op(1,[args])=InstTableSet then print(`InstTableSet(Set1): A table that shows for every Institue`): print(`the set of grants`): fi: if nops([args])=1 and op(1,[args])=PIList then print(`PIList(Set1): The list of PI's according to Amt`): fi: if nops([args])=1 and op(1,[args])=FundPI then print(`FundPI(Set1,x,t)`): print(`The funding polynomial of the set of grants, Set1, which is`): print(`the weight-enumerator of all grants, where the`): print(`weight of a grant is x[PI]*t^Amount`): fi: if nops([args])=1 and op(1,[args])=FundPol then print(`FundPol(Set1,x,y,z,t)`): print(`The funding polynomial of the set of grants, Set1, which is`): print(`the weight-enumerator of all grants, where the`): print(`weight of a grant is x[PI]*y[Inst]*z[State]*t^Amount`): fi: if nops([args])=1 and op(1,[args])=STATEs then print(`STATEs(Set1): gives the set of states where the funded `): print(`Institutions of the given set of grants reside `): fi: if nops([args])=1 and op(1,[args])=INSTs then print(`INSTs(Set1): gives the set of the funded `): print(`Institutions of the given set of grants`): fi: if nops([args])=1 and op(1,[args])=Amts then print(`Amts(Set1): gives the set of the amounts per year`): print(`Investigators of the given set of grants`): fi: if nops([args])=1 and op(1,[args])=PIs then print(`PIs(Set1): gives the set of the funded Principal`): print(`Investigators of the given set of grants`): fi: if nops([args])=1 and op(1,[args])=Programs then print(`Programs(): lists the set of programs of the NSF considered here`): print(` The name of the sets are as follows (all capitals): `): print(` ANT: Algebra and Number Theory; APM: Applied Mathematics `): print(` CLA: Classical Analysis; CMP: Computational Math;`): print(` FOD: Foundations; GEA: Geometric Analysis; `): print(`MPH: Mathematical Physics; PRO: Probablity; TOP: Topology `): lprint(``): print(`Last but not least, MATH is the set of all grants in Math`): print(` Active in July 28, 1998`): print(`In addition FIELDS, is the set of grants of Fields Medalists`): fi: if nops([args])=1 and op(1,[args])=Shorten1 then print(`Shorten1(Set1): Given a set of lists of length 7, constructs`): print(`a shorter lists of length 4: [Amt per year,PI,Inst,State,Award Number]`): fi: end: #Programs(): Lists the set of programs and sets Programs:=proc(): {ant,apm,cla,fod,cmp,gea,top,mph,pro,math,fields}: end: #Shorten1(Set1): Given a set of lists of length 7, constructs #a shorter lists of length 4: [Amt per year,PI,Inst,State,Award Number] Shorten1:=proc(Set1) local gu,i,dura,mu: gu:={}: for i from 1 to nops(Set1) do mu:=op(i,Set1): dura:=mu[6]-mu[5]: if dura=0 then dura:=1: fi: gu:=gu union {[trunc(evalf(mu[2]/dura)),mu[3],mu[4],mu[7],mu[1]]}: od: gu: end: #PIs(Set1): gives the set of the funded Principal #Investigators of the given set of grants PIs:=proc(Set1) local gu,i: gu:={}: for i from 1 to nops(Set1) do gu:=gu union {[Set1[i][3],Set1[i][4]]}: od: gu: end: #PIsI(Set1): gives the set of the funded Principal #Investigators, followed by the Institution of the given set of grants PIsI:=proc(Set1) local gu,i: gu:={}: for i from 1 to nops(Set1) do gu:=gu union {[Set1[i][3],Set1[i][4]]}: od: gu: end: #AveAmt(Set1): gives the average grant-size (per year) #Investigators of the given set of grants AveAmt:=proc(Set1) local gu: gu:=Amts(Set1): evalf(convert(gu,`+`)/nops(gu)): end: #Amts(Set1): gives the lists of the amounts per year #Investigators of the given set of grants Amts:=proc(Set1) local gu,i,Set2: Set2:=Shorten1(Set1): gu:=[]: for i from 1 to nops(Set2) do gu:=[op(gu),Set2[i][1]]: od: sort(gu): end: #INSTs(Set1): gives the set of the funded #Institutions of the given set of grants INSTs:=proc(Set1) local gu,i,Set2: gu:={}: Set2:=Shorten1(Set1): for i from 1 to nops(Set2) do gu:=gu union {Set2[i][3]}: od: gu: end: #STATEs(Set1): gives the set of states where funded #Institutions of the given set of grants reside STATEs:=proc(Set1) local gu,i,Set2: gu:={}: Set2:=Shorten1(Set1): for i from 1 to nops(Set2) do gu:=gu union {Set2[i][4]}: od: gu: end: #FundPol(Set1,x,y,z,w,t) #The funding polynomial of the set of grants, Set1, which is #the weight-enumerator of all grants, where the #weight of a grant is x[PI]*y[Inst]*z[State]*w[AwardNumber]*t^Amount FundPol:=proc(Set1,x,y,z,w,t) local i,Set2,gu,mu: Set2:=Shorten1(Set1): gu:=0: for i from 1 to nops(Set2) do mu:=op(i,Set2): gu:=gu+t^mu[1]*x[mu[2]]*y[mu[3]]*z[mu[4]]*w[mu[5]]: od: gu: end: #FundPI(Set1,x,t) #The funding polynomial of the set of grants, Set1, which is #the weight-enumerator of all grants, where the #weight of a grant is x[PI]*t^Amount FundPI:=proc(Set1,x,t) local i,Set2,gu,mu: Set2:=Shorten1(Set1): gu:=0: for i from 1 to nops(Set2) do mu:=op(i,Set2): gu:=gu+(t^mu[1])*x[mu[2]]: od: gu: end: #shane(mono,x,y,z,w): Given a monomial x[a]*y[b]*z[c]*w[d] changes #it to the list [a,b,c] shane:=proc(mono,x,y,z,w) local i,a,b,c,d,lu: if not type(mono,`*`) then ERROR(`Bad input`): fi: if not nops(mono)=4 then ERROR(`Bad input`): fi: for i from 1 to 4 do lu:=op(i,mono): if op(0,lu)=x then a:=op(1,lu): elif op(0,lu)=y then b:=op(1,lu): elif op(0,lu)=z then c:=op(1,lu): elif op(0,lu)=w then d:=op(1,lu): else ERROR(`bad input`): fi: od: [a,b,c,d]: end: #PIList(Set1): The list of PI's according to #Amt PIList:=proc(Set1) local gu,pol,x,y,z,t,w,deg,co,mu,j1: pol:=FundPol(Set1,x,y,z,w,t): co:=0: gu:=[]: while pol<>0 do deg:=degree(pol,t): mu:=expand(coeff(expand(pol),t,deg)): if type(mu,`+`) then for j1 from 1 to nops(mu) do co:=co+1: gu:=[op(gu),[co,op(shane(op(j1,mu),x,y,z,w)),deg]]: od: else co:=co+1: gu:=[op(gu),[co,op(shane(mu,x,y,z,w)),deg]]: fi: pol:=expand(pol-mu*t^deg): od: gu: end: #InstTableSet(Set1): A table that shows for every Institue #the set of grants InstTableSet:=proc(Set1) local Set2,i,T,gu,mu: option remember: Set2:=Shorten1(Set1): gu:=INSTs(Set1): for i from 1 to nops(gu) do T[op(i,gu)]:={}: od: for i from 1 to nops(Set2) do mu:=op(i,Set2): T[mu[3]]:=T[mu[3]] union {mu}: od: T: end: #InstTableInfo(Set1): A table that shows for every Instition #that participates in the set of grants, Set1, #the total number of PIs funded, followed by #the total amount funded by PIs in that Institution, #followed by the average amt per PI InstTableInfo:=proc(Set1) local gu,i,T1,T,mu,lu,j: option remember: gu:=INSTs(Set1): T1:=InstTableSet(Set1): for i from 1 to nops(gu) do mu:=T1[op(i,gu)]: lu:=0: for j from 1 to nops(mu) do lu:=lu+mu[j][1]: od: T[op(i,gu)]:=[nops(mu),lu,trunc(lu/nops(mu))]: od: T: end: #InstTableAM(Set1): A table that shows for every Institution #that participates in the set of grants, Set1, #the total number of PIs funded, followed by #the total amount funded by PIs in that Institution, #followed by the average amt per PI InstTableAM:=proc(Set1) local gu,i,T1,T,mu,lu,j: option remember: gu:=INSTs(Set1): T1:=InstTableSet(Set1): for i from 1 to nops(gu) do mu:=T1[op(i,gu)]: lu:=0: for j from 1 to nops(mu) do lu:=lu+mu[j][1]: od: T[op(i,gu)]:=trunc(lu/nops(mu)): od: T: end: #InstTableTM(Set1): A table that shows for every Instition #that participates in the set of grants, Set1, #the total amount of money in dollars InstTableTM:=proc(Set1) local gu,i,T1,T,mu,lu,j: option remember: gu:=INSTs(Set1): T1:=InstTableSet(Set1): for i from 1 to nops(gu) do mu:=T1[op(i,gu)]: lu:=0: for j from 1 to nops(mu) do lu:=lu+mu[j][1]: od: T[op(i,gu)]:=lu: od: T: end: #InstListTM(Set1): The list of Institutions #funded in the set of grants Set1, in decreasing #order of total money InstListTMold:=proc(Set1) local T,gu,T1,mu,i,mu1: T:=InstTableTM(Set1): gu:=INSTs(Set1): mu:=[]: for i from 1 to nops(gu) do T1[T[op(i,gu)]]:=op(i,gu): mu:=[op(mu),T[op(i,gu)]]: od: mu:=sort(mu): mu1:=[seq(mu[nops(mu)-i+1],i=1..nops(mu))]: mu:=mu1: gu:=[]: for i from 1 to nops(mu) do gu:=[op(gu),[i,T1[op(i,mu)],op(i,mu)]]: od: gu: end: #InstListAM(Set1): The list of Institutions #funded in the set of grants Set1, in decreasing #order of average money per PI InstListAMold:=proc(Set1) local T,gu,T1,mu,i,mu1: T:=InstTableAM(Set1): gu:=INSTs(Set1): mu:=[]: for i from 1 to nops(gu) do T1[T[op(i,gu)]]:=op(i,gu): mu:=[op(mu),T[op(i,gu)]]: od: mu:=sort(mu): mu1:=[seq(mu[nops(mu)-i+1],i=1..nops(mu))]: mu:=mu1: gu:=[]: for i from 1 to nops(mu) do gu:=[op(gu),[i,T1[op(i,mu)],op(i,mu)]]: od: gu: end: #InstTableNUPI(Set1): A table that shows for every Instition #that participates in the set of grants, Set1, #the total number of PIs funded InstTableNUPI:=proc(Set1) local gu,i,T1,T,mu,j,lu: option remember: gu:=INSTs(Set1): T1:=InstTableSet(Set1): for i from 1 to nops(gu) do mu:=T1[op(i,gu)]: lu:=0: for j from 1 to nops(mu) do lu:=lu+mu[j][1]: od: T[op(i,gu)]:=nops(mu): od: T: end: #InstListNUGrants(Set1): The list of Institutions #funded in the set of grants Set1, in decreasing #order of number of Grants InstListNUGrants:=proc(Set1) local T,gu,T1,mu,i,mu1,j,co,lu: T:=InstTableNUPI(Set1): gu:=INSTs(Set1): mu:={}: for i from 1 to nops(gu) do mu:=mu union {T[op(i,gu)]}: od: for i from 1 to nops(mu) do T1[op(i,mu)]:={}: od: for i from 1 to nops(gu) do lu:=op(i,gu): T1[T[lu]]:=T1[T[lu]] union {lu}: od: mu:=sort([op(mu)]): mu1:=[seq(mu[nops(mu)-i+1],i=1..nops(mu))]: mu:=mu1: gu:=[]: co:=0: for i from 1 to nops(mu) do lu:=T1[op(i,mu)]: for j from 1 to nops(lu) do co:=co+1: gu:=[op(gu),[co,op(j,lu),op(i,mu)]]: od: od: gu: end: #InstListTM(Set1): The list of Institutions #funded in the set of grants Set1, in decreasing #order of Total Money InstListTM:=proc(Set1) local T,gu,T1,mu,i,mu1,j,co,lu: T:=InstTableTM(Set1): gu:=INSTs(Set1): mu:={}: for i from 1 to nops(gu) do mu:=mu union {T[op(i,gu)]}: od: for i from 1 to nops(mu) do T1[op(i,mu)]:={}: od: for i from 1 to nops(gu) do lu:=op(i,gu): T1[T[lu]]:=T1[T[lu]] union {lu}: od: mu:=sort([op(mu)]): mu1:=[seq(mu[nops(mu)-i+1],i=1..nops(mu))]: mu:=mu1: gu:=[]: co:=0: for i from 1 to nops(mu) do lu:=T1[op(i,mu)]: for j from 1 to nops(lu) do co:=co+1: gu:=[op(gu),[co,op(j,lu),op(i,mu)]]: od: od: gu: end: #InstListAM(Set1): The list of Institutions #funded in the set of grants Set1, in decreasing #order of Total Money InstListAM:=proc(Set1) local T,gu,T1,mu,i,mu1,j,co,lu: T:=InstTableAM(Set1): gu:=INSTs(Set1): mu:={}: for i from 1 to nops(gu) do mu:=mu union {T[op(i,gu)]}: od: for i from 1 to nops(mu) do T1[op(i,mu)]:={}: od: for i from 1 to nops(gu) do lu:=op(i,gu): T1[T[lu]]:=T1[T[lu]] union {lu}: od: mu:=sort([op(mu)]): mu1:=[seq(mu[nops(mu)-i+1],i=1..nops(mu))]: mu:=mu1: gu:=[]: co:=0: for i from 1 to nops(mu) do lu:=T1[op(i,mu)]: for j from 1 to nops(lu) do co:=co+1: gu:=[op(gu),[co,op(j,lu),op(i,mu)]]: od: od: gu: end: #GrantsInInst(Inst,Set): Given an institutions, Inst, #and a set of grants, Set, finds all the grants from #that instition that belong to the set #In particular to get all the Math grants from that #Institute do: GrantsInInst(Inst,MATH): GrantsInInst:=proc(Inst1,Set1) local gu,lu: gu:=INSTs(Set1): if not member(Inst1,gu) then RETURN({}): fi: lu:=InstTableInfo(Set1)[Inst1]: print(`The number of grants in that field in the Institution`, Inst1,`is:`): print(lu[1]): print(`The total amount funded is`): print(lu[2]): print(`The average is`): print(lu[3]): print(`The grants were:`): mu:=InstTableSet(Set1)[Inst1]: print(mu): mu: end: #kosher(entry1): checks whether the grant-info is #in the standard format kosher:=proc(entry1): if not type(entry1,list) or not (nops(entry1)=7 or nops(entry1)=8) then ERROR(entry1, `should be a list of seven entries`): fi: if not type(entry1[1],integer) then ERROR(`The first entry of`,entry1, `should be an integer (grant number)`): fi: if not (type(entry1[2],integer) or type(entry1[2],float)) then ERROR(`The second entry of`,entry1, `should be a number (amount in dollars)`): fi: if not type(entry1[3],string) then ERROR(`The third entry of`,entry1, `should be a string (name of the PI)`): fi: if not type(entry1[4],string) then ERROR(`The fourth entry of`,entry1, `should be a string (name of Institution)`): fi: if not type(entry1[5],integer) or entry1[5]<1900 or entry1[5]>2100 then ERROR(`The fifth entry of`,entry1, `should be an integer (start year)`): fi: if not type(entry1[6],integer) or entry1[6]<1900 or entry1[6]>2100 or entry1[6]