Let $G$ be a compact topological group with normalized Haar measure $\mu$.
Is there an effective isometric action of $G$ on some $\mathbb{R}^n$ such that the following map would be a non-irreducible polynomial in $\mathbb{R}[x_1,x_2,\ldots,x_n]$?
$$P(X)=\int_G \langle X, \; g.X\rangle,\qquad X\in \mathbb{R}^n$$
A motivational example is the permutational action of the finite group $G$ generated by cyclic permutation $(1,2,\ldots,n)$ on $\mathbb{R}^n$. For this action the above map $P$ has the formula
$$P(x_1,x_2,\ldots,x_n)=\frac{(x_1+x_2+\ldots+x_n)^2}{n}$$
My initial motivation was the following:
I encountered the inquality $n\sum_{i=1}^n x_i^2 \geq (\sum_{=1}^n x_i)^2$. To prove this I realized that the right hand side of this inequality has the expansion $\sum_{i=0}^n <X, g^i.X>$ where $g$ is the cyclic permutation $g=<2,3,\ldots,n,1>$. Then I applied Cauchy Schwartz inequality. So this leads me to be interested in the term $\int_G <X, gX>$ in present of a group action. According to the comment of Prof. Valette I realized that this integral is $|Q(x)|^2$ where $Q$ is projection on the space of fixed points of $G$.
My reason to emphasis on effectiveness was that: for trivial action we get the irreducible polynomial. Now thanks to the comment of Prof. Valette I realize that the only non irreducible case is when the space of $G$ fixed vectors is a 1 dimensional space.
If the answer to the above question is yes one may associate an invariant to a compact in particular finite group $G$ equal to the minimum of all possible $n$ with the above mentioned effective isometric action of $G$ on $\mathbb{R}^n$.
What is this function $P$ when $G$ is the whole group $O(n)$?
What is the ideal generated by all polynomials $P$ obtained in this way via finit subgroups of $O(n)$?