When configurations after rotations and flips are considered the same, how many ways are there to color a $3 × 3$ grid in the same way if five squares have to be red and four squares have to be blue? We can color a $3 × 3$ grid in $$\frac{n^9 + 4n^6 + n^5 + 2n^3}{8}$$ ways using $n$ colors if configurations after rotations and flips are considered the same.
But I couldn't find how many ways are there when the grid has five squares have to be red and four squares have to be blue. How can I calculate this?
Enumerating the symmetries of the grid for the cycle index so that we may apply PET we obtain
We get for the cycle index
$$Z(Q) = \frac{1}{8} (a_1^9 + 2 a_1 a_4^2 + a_1 a_2^4 + 4 a_1^3 a_2^3).$$
Just to check we get for colorings using at most $N$ colors
$$\frac{1}{8} (N^9 + 4 N^6 + N^5 + 2 N^3)$$
which gives the sequence
$$1, 102, 2862, 34960, 252375, 1284066, 5105212, \ldots$$
which points to OEIS A217331 where these data are confirmed.
Now we use PET to compute the number of colorings with five red squares and four blue ones, essentially performing
$$[R^5 B^4] Z(Q; R+B),$$
which yields (substitution is $a_d = R^d B^d$)
We thus get for our answer $\frac{1}{8} (126 + 4 + 6 + 48) = 23.$