On Wed, Jun 3, 2009 at 5:54 PM, James Parson wrote: > > Thanks to David Joyner for his response to my original question. His > method worked nicely. Incidentally, here is the original Maple code > from the lecture of Doron Zeilberger that I was trying to translate > into Sage: > > with(combinat): P:=(d,x,y)->add(add(a[i,j]*x**i*y**j,i=0..d- > j),j=0..d); > V:=d->fseq(seq(a[i,j],i=0..d-j),j=0..d)g; > E:=d->fseq(P(d,fibonacci(n),fibonacci(n+1)),n=1..nops(V(d))+5) g: > Q:=(d,x,y)->subs(solve(E(d),V(d)),P(d,x,y)); > > These lines feature the sort of indexed variables a[i,j] discussed > above. > > (The full lecture from which I took these lines can be found at > http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimhtml/em.html.) >
There is some pdf cut-and-paste corruption of the example above. The correct Maple code is: with(combinat): P:=(d,x,y)->add(add(a[i,j]*x**i*y**j,i=0..d-j),j=0..d); V:=d->{seq(seq(a[i,j],i=0..d-j),j=0..d)}; E:=d->{seq(P(d,fibonacci(n),fibonacci(n+1)),n=1..nops(V(d))+5) }; Q:=(d,x,y)->subs(solve(E(d),V(d)),P(d,x,y)); A more direct translation to Sage might be something like this: sage: P=lambda d,x,y: sum([ sum([ var("a"+str(i)+str(j))*x^i*y^j for i in [0..d-j]]) for j in [0..d]]) sage: V=lambda d:sum([[var("a"+str(i)+str(j)) for i in [0..d-j]] for j in [0..d]],[]) sage: E=lambda d: [ P(d,fibonacci(n),fibonacci(n+1)) for n in [1..len(V(d))+5] ] sage: Q=lambda d,x,y:P(d,x,y).subs_expr(solve(E(d),V(d),solution_dict=True)[0]) sage: Q(1,x,y) 0 sage: Q(2,x,y) 0 sage: Q(3,x,y) 0 sage: Q(4,x,y).factor() r21*(-y^2 + x*y + x^2 - 1)*(-y^2 + x*y + x^2 + 1) Regards, Bill Page. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---