lu := - ( 3 x[1, 1] x[1, 2] x[1, 3] x[2, 1] x[2, 2] x[2, 3] x[3, 1] x[3, 2] x[3, 3] z - 1)/((x[2, 2] x[1, 3] z x[3, 1] - 1) (x[2, 3] x[1, 2] z x[3, 1] - 1) (x[2, 1] x[1, 2] z x[3, 3] - 1) (x[2, 2] x[1, 1] z x[3, 3] - 1) (x[2, 3] x[1, 1] z x[3, 2] - 1) (x[2, 1] x[1, 3] z x[3, 2] - 1)) The weighted generating function for magic squares of size, 3, is: 3 - (x[1, 1] x[1, 2] x[1, 3] x[2, 1] x[2, 2] x[2, 3] x[3, 1] x[3, 2] x[3, 3] z - 1)/((x[2, 2] x[1, 3] z x[3, 1] - 1) (x[2, 3] x[1, 2] z x[3, 1] - 1) (x[2, 1] x[1, 2] z x[3, 3] - 1) (x[2, 2] x[1, 1] z x[3, 3] - 1) (x[2, 3] x[1, 1] z x[3, 2] - 1) (x[2, 1] x[1, 3] z x[3, 2] - 1)) and in Maple input notation: -(x[1,1]*x[1,2]*x[1,3]*x[2,1]*x[2,2]*x[2,3]*x[3,1]*x[3,2]*x[3,3]*z^3-1)/(x[2,2] *x[1,3]*z*x[3,1]-1)/(x[2,3]*x[1,2]*z*x[3,1]-1)/(x[2,1]*x[1,2]*z*x[3,3]-1)/(x[2, 2]*x[1,1]*z*x[3,3]-1)/(x[2,3]*x[1,1]*z*x[3,2]-1)/(x[2,1]*x[1,3]*z*x[3,2]-1) 2 z + z + 1 lu := - ---------- 5 (z - 1) The generating function for magic squares of size, 3, is: 2 z + z + 1 - ---------- 5 (z - 1) and in Maple input notation: -(z^2+z+1)/(z-1)^5 And the squence itself is: 4 3 2 [[1/8 n + 3/4 n + 15/8 n + 9/4 n + 1]] and in Maple input notation: [[1/8*n^4+3/4*n^3+15/8*n^2+9/4*n+1]] This took, 6540.671, seconds.