Enumeration of field generators of a finite field over $\mathbb{F}_{q}$, which are $m^{th}$ powers in the same field Consider the finite field extension $\mathbb{F}_{{q}^{d}}$ over $\mathbb{F}_{q}$, where $q=p^a$ for some prime $p$. We assume $d\geq 2$. Let,
$$ S=\{ \alpha \in \mathbb{F}_{q^d}\hspace{0.1 cm} | \hspace{0.1 cm} \mathbb{F}_{q}(\alpha)=\mathbb{F}_{q^d} \}$$
In other words, $S$ consists of all those elements in $\mathbb{F}_{q^d}$, whose minimal polynomial over $\mathbb{F}_{q}$ has degree $d$, or to say another way $S$ consists of all field generators of $\mathbb{F}_{q^d}$ Over  $\mathbb{F}_{q}$. Let, $S^m= \{ s^m | s\in S\} $, where $m$ is a positive integer $\geq 2$. Then, 
$$ |S\cap S^m|=?$$
More, precisely, $S\cap S^m$ is the set of all field generators in $\mathbb{F}_{q^d}$ (over $\mathbb{F}_q$), which are $m^{th}$ powers in $\mathbb{F}_{q^d}$.
I calculated, this for $m=2$. The answer depends on whether $d$ is odd or even. We have,
$$
  |S\cap S^2|= 
 \begin{cases}
  \frac{|S|}{2} & if \hspace{0.2 cm}  d \text{ is odd}\\
  \frac{1}{2}[|S|-\frac{(q^{d/2}-1)}{d}] & if \hspace{0.2 cm} d \text{ is even}
 \end{cases}
$$
And, $|S|=dM(d,q)$, where $M(d,q)$ denote the number of irreducible polyomials of degree $d$ over $\mathbb{F}_{q}$. 
I couldn't generalize my method to $m>2$. My, idea is that this problem seems to have been well studied in the literature of finite fields. So, I am hoping for some kind of help or suitable references in this case.
Thank you!
 A: $$| S \cap S^m | = \sum_{n|d} \mu(n)
\frac{  \gcd ( m  (q^{d/n}-1), q^{d}-1 )}{ \gcd (q^{d} - 1, m) } $$
First note that $|S \cap S^m | = |S \cap \mathbb F_{q^d}^m |$ because every $m$th power that generates is an $m$th power of a generator.
We can count elements of $S$ by an inclusion-exclusion argument, subtracting and adding the number of elements in subfields. This gives the term $ \mu(n) q^{d/n}$, or $ \mu(n)( q^{d/n}-1)$ if we only count nonzero elements.   To count elements of $S$ that are $m$th powers, we use inclusion-exclusion to count the number of $m$th powers in subfields.
To count the number of elements of $\mathbb F_{q^{d/n}}^\times$ that are $m$th powers in $\mathbb F_{q^d}^\times$, we observe that their $m$th roots are both $ m (q^{d/n}-1)$st roots of unity and $(q^d-1)$st roots of unity, hence are $\gcd (  m (q^{d/n}-1),(q^d-1))$th roots of unity, and each of them has $\gcd(q^d-1, m)$ $m$th roots in $\mathbb F_{q^d}^\times$, so the total number of them is $\frac{  \gcd ( m  (q^{d/n}-1), q^{d}-1 )}{ \gcd (q^{d} - 1, m) } $. 
Inclusion-exclusion gives our formula.
