About RMS in a non-sinusoidal electrical circuit
Expanding the sum will result in

$$\left( \sum_{n=1}^{\infty} \sqrt{2}I_n\sin(n\omega t + \gamma_n)\right)^2 \\
\begin{align}
&amp;= \sum_{n_1=1}^{\infty}\sum_{n_2=1}^{\infty}\left[2I_{n_1}I_{n_2}\sin(n_1\omega t + \gamma_{n_1})\sin(n_2\omega t + \gamma_{n_2})\right]
\end{align}$$

If \$n_1 = n_2 = n\$, then we simply get

$$\int_0^T 2I_n^2\sin^2(n\omega t + \gamma_n) dt = I_n^2$$

For the mixed terms where \$n_1 \neq n_2\$, we can calculate the integral using the following equality:

$$\sin(\alpha)\sin(\beta) = \frac{1}{2}\left( cos(\alpha-\beta) - cos(\alpha+\beta) \right)$$

$$\begin{align}
&amp; \int_0^T \sin(n_1\omega t + \gamma_{n_1})\sin(n_2\omega t + \gamma_{n_2})dt \\
 &amp;= \int_0^T \frac{1}{2} \left( \cos \left[ (n_1 - n_2)\omega t + (\gamma_{n_1} - \gamma_{n_2}) \right] - \cos \left[ (n_1 + n_2)\omega t + (\gamma_{n_1} + \gamma_{n_2}) \right] \right)dt \\
 &amp;= \frac{1}{2} \int_0^T \cos( (n_1-n_2)\omega t + (\gamma_{n_1} - \gamma_{n_2})) dt \\
 &amp;- \frac{1}{2} \int_0^T \cos( (n_1 + n_2)\omega t + (\gamma_{n_1} + \gamma_{n_2})) dt
\end{align}
$$

Both of these integrals are of the form:

$$\int_0^T cos(m\omega t + \phi)dt$$

with \$m\$ a non-zero integer (else \$n_1 = n_2\$), meaning that \$T\$ is a multiple of the period of this cosine. The latter means that the integral will result to 0.

So your formula can be simplified to

$$I_0^2 + \sum_{n=1}^{\infty} I_n^2$$