A system for controlling an electric machine comprising: a memory storing computer-readable instructions; and at least one processing device configured to execute the computer-readable instructions to, obtain an estimated position waveform, the estimated position waveform being based on a position of a rotor of the electric machine, the estimated position waveform having an error signal and an actual position waveform, determine a corrected position waveform of the rotor based on the estimated position waveform by, determining an estimated first coefficient and an estimated second coefficient, and reducing at least one frequency component of the error signal using the estimated first coefficient and the estimated second coefficient to determine the corrected position waveform, control the electric machine based on the corrected position waveform, and reduce a ripple in a direct current link voltage based on the controlling, and by increasing a virtual resistance of the electric machine, the virtual resistance based on a gain of a proportional-integral, PI, controller of the electric machine, a bandwidth of a current regulator of the electric machine and a stator resistance of the electric machine. a memory storing computer-readable instructions; and at least one processing device configured to execute the computer-readable instructions to, obtain an estimated position waveform, the estimated position waveform being based on a position of a rotor of the electric machine, the estimated position waveform having an error signal and an actual position waveform, determine a corrected position waveform of the rotor based on the estimated position waveform by, determining an estimated first coefficient and an estimated second coefficient, and reducing at least one frequency component of the error signal using the estimated first coefficient and the estimated second coefficient to determine the corrected position waveform, control the electric machine based on the corrected position waveform, and reduce a ripple in a direct current link voltage based on the controlling, and by increasing a virtual resistance of the electric machine, the virtual resistance based on a gain of a proportional-integral, PI, controller of the electric machine, a bandwidth of a current regulator of the electric machine and a stator resistance of the electric machine. obtain an estimated position waveform, the estimated position waveform being based on a position of a rotor of the electric machine, the estimated position waveform having an error signal and an actual position waveform, determine a corrected position waveform of the rotor based on the estimated position waveform by, determining an estimated first coefficient and an estimated second coefficient, and reducing at least one frequency component of the error signal using the estimated first coefficient and the estimated second coefficient to determine the corrected position waveform, determining an estimated first coefficient and an estimated second coefficient, and reducing at least one frequency component of the error signal using the estimated first coefficient and the estimated second coefficient to determine the corrected position waveform, control the electric machine based on the corrected position waveform, and reduce a ripple in a direct current link voltage based on the controlling, and by increasing a virtual resistance of the electric machine, the virtual resistance based on a gain of a proportional-integral, PI, controller of the electric machine, a bandwidth of a current regulator of the electric machine and a stator resistance of the electric machine.