function [G,Q]=geom(r,N) k=0:N; z=r.^k; G=sum(z); Q=(1-r^(N+1))/(1-r); G Q G-Q z k sort(z)