Discrete Total Harmonic Distortion Calculation