$$ v(t) = V_0 + \sum_{k=1}^{\infty} \sqrt{2} V_k \cos(k\omega t + \phi_k) \newline i(t) = I_0 + \sum_{m=1}^{\infty} \sqrt{2} I_m \cos(m\omega t + \theta_m)
$$
Average power over one period $T$ is given by:
$$ P = \frac{1}{T} \int_0^T v(t) i(t) dt $$
Expanding using the Fourier series
$$ \newline P = \frac{1}{T} \int_0^T \left( V_0 + \sum_{k=1}^{\infty} \sqrt{2} V_k \cos(k\omega t + \phi_k) \right) \left( I_0 + \sum_{m=1}^{\infty} \sqrt{2} I_m \cos(m\omega t + \theta_m) \right) dt
$$
DC * Sinusoid average out to zero
DC*DC terms:
$$ P_{DC} = \frac{1}{T} \int_0^T V_0 I_0 dt = V_0 I_0 $$
Sinusoid * sinusoid terms:
$$ \cos(A) \cos(B) = \frac{1}{2} \left( \cos(A+B) + \cos(A-B) \right) $$
$$ V_{rms} = \sqrt{ \frac{1}{T} \int_0^T v(t)^2 dt } = \sqrt{ V_0^2 + \sum_{k=1}^{\infty} V_k^2 } \newline I_{rms} = \sqrt{ I_0^2 + \sum_{m=1}^{\infty} I_m^2 }
$$
Defined as the ratio of real power to apparent power, combines the displacement and distortion factors
$$ \text{PF} = \frac{P}{V_{rms} I_{rms}} \newline \newline\text{With harmonics: }\text{PF} = \frac{V_1 I_1 \cos(\theta_x - \theta_{i1})}{V_{rms} \sqrt{I_1^2 + \sum I_k^2}} \times \cos(\theta_x - \theta_{i1}) $$