## Kristen Lew, Homework 7 ## Exp Math, Spring 2012 # Post if you wish Help:=proc(): print(' Gsomosk(Ini,k,n), IntSomos(k), LaurentSomos(k), GenHomPol(X,d,a,co), GenNonHomPol(X,d,a,co)'): end: ### Problem 1 ## Gsomosk(Ini,k,n) : outputs the n-th term of the Somos-k recurrence # where Somos-k is the natural k-th order analogy of the Somos-4 recurrence. Gsomosk:=proc(Ini,k,n) option remember: if k < 4 then 1: elif n<=k then Ini[n]: else normal((add(Gsomosk(Ini,k,n-i)*Gsomosk(Ini,k,n-k+i), i=1..k/2))/Gsomosk(Ini,k,n-k)): fi: end: ### Problem 2 ## IntSomos(k) outputs a list of integers such that the Somos-i with Ini=[1$i] # are integers with i <= k. [For reasonably sized k: k less than 45 works.] IntSomos:=proc(k) local L, i, v: option remember: L:=[]: for i from 1 to k do v:=Gsomosk([1$i],i,i+k+5): if type(v, integer)=true then L:=[op(L), i]: fi: od: L: end: ### Somos-k seems to always produce integers for k <= 7 and eventually produce fractions ### for k >= 8. ### Problem 3 ## LaurentSomos(k) outputs a list of integers such that the Somos-k, with # with Ini=[x[1],…,x[k]], seem to always produce Laurent polynomials. # [For less reasonably sized k: k less than 10 works quickly, # but 10 < k< 14 takes a while.] LaurentSomos:=proc(k) local L, Lx, i, d, x: option remember: L:=[]: for i from 1 to k do Lx:=[seq(x[j], j=1..i)]: d:=denom(Gsomosk(Lx,i,2*i+1)): if type(d,monomial)=true then L:=[op(L), i]: fi: od: L: end: ### Somos-k always seems to produce Laurent polynomials for k <= 7, ### but seems to eventually produce non-Laurent polynomials for k >= 8. ### Problem 4 ## GenHomPol(X,d,a,co) yields a homogenous polynomial of degree d. # The total degree of a monomial (x1^a1)(x2^a2)… is a1+a2+…. A homogenous polynomial # of degree d is one for which each of its term is a monomial of degree d. GenHomPol:=proc(X,d,a,co) local m,x,co1,X1,P,var,i,P1: option remember: m:=nops(X): x:=X[1]: if m=1 then RETURN(a[co]*x^d, {a[co]}, co+1): fi: co1:=co: X1:=[op(2..m,X)]: P:=0: var:={}: for i from 0 to d do P1:=GenHomPol(X1,d-i,a,co1): P:=expand(P+P1[1]*x^i): var:=var union P1[2]: co1:=P1[3]: od: P, var, co1: end: ### Problem 5 ## GenNonHomPol(X,d,a,co) outputs a polynomial of total degree d. # That is the sum of homog. polynomials of total degree i for i=0..d). GenNonHomPol:=proc(X,d,a,co) local P,var,co1,i,p: option remember: P:=0: var:={}: co1:=co: for i from 0 to d do p:=GenHomPol(X,i,a,co1): P:=expand(P+p[1]): var:=var union p[2]: co1:=p[3]: od: P,var,co1: end: