The (ordinary) generating function whose coeff. of z^n tells you the number of permutations of length n avoiding the set of patterns, {[1, 2, 3], [1, 3, 2]} equals 2 ----- \ ) g[i](1, 1, z) / ----- i = 1 where the vector of formal power series of length, 2 in the variables, x[1], x[2], z is the unique vector that satisfies the following system of functional equations g[1](x[1], x[2], z) = 2 2 2 x[2] g[2](x[1], 1, x[2]) x[2] g[2](x[1] x[2], 1, 1) z x[1] x[2] + ------------------------- - -------------------------- x[2] - 1 x[2] - 1 2 2 x[2] x[1] g[1](x[1], x[2], 1) g[2](x[1], x[2], z) = z x[1] x[2] + ----------------------------- x[1] - 1 x[2] x[1] g[1](1, x[2], 1) x[2] x[1] g[2](x[1] x[2], 1, 1) - -------------------------- + ------------------------------- x[1] - 1 x[1] - 1 x[2] x[1] g[2](x[2], 1, 1) - -------------------------- x[1] - 1 This took, 0.245, seconds