I'm doing an exercise on the Möbius function $\mu$. I've seen this equation but I don't understand it.
\begin{align*} \mathrm{X}^{n}-1&= \prod_{d \mid n} \phi_d(X) \\ &=\prod_{d \mid n} \left(\mathrm{X}^{\varphi(d)}-\mu(d) \mathrm{X}^{\varphi(d)-1}+\cdots \right) \\ &=\mathrm{X}^{n}-\sum_{d \mid n} \mu(d) \mathrm{X}^{\varphi(d)-1} \prod_{q \mid n, q \neq d} \mathrm{X}^{\varphi(q)}+\cdots \\ &=\mathrm{X}^{n}-\sum_{d \mid n} \mu(d) \mathrm{X}^{n-1}+\cdots \end{align*}
I know that $X^{\sum_{d | n } \varphi(d)} = X^n$ but I don't see why we get the term $\sum_{d \mid n} \mu(d) \mathrm{X}^{\varphi(d)-1} \prod_{q \mid n, q \neq d} \mathrm{X}^{\varphi(q)}$.