## 1 Introduction  
Currently, there has been substantial growth in electricity generation through solar energy, which has led to the development of inverters that convert photovoltaic energy generated in direct current (DC) to alternating current (AC) that can be injected into the main power grid [1]. On the other hand, there has also been an increase in works on inverters that power the motors of electric vehicles [2]. In both cases, the management of the inverter is very relevant, but above all, its modulation techniques have been known since 1973 [3]. There are several algorithms to implement in the inverter modulation techniques such as space vector pulse width modulation (SVPWM), selective harmonic elimination pulse width modulation (SHEPWM), sinusoidal pulse width modulation (SPWM), and wavelet modulation [4; 5; 6; 7; 8; 9; 10; 11]. However, one of the most widely used is SPWM due to the ease of implementation [8; 10; 11; 12; 13; 14; 15; 16; 17; 18]. The SPWM technique can be implemented using analog or digital sampling. Analog implementation is called natural sampling, and digital techniques are called regular sampling [5; 6; 8; 10; 15]. The analog implementation is very easy, as it only requires comparing a sinusoidal signal with a triangular signal using an op-amplifier, and the resulting signal can be applied to the inverter switches. It is important to clarify that this work is limited to single-phase inverters, which are widely used as microinverters in single-phase systems. But the algorithm shown can be easily scaled to three-phase systems. There are two cases for the comparison: unipolar and bipolar modulation [3; 19]. Only the unipolar modulation will be analyzed, since this modulation presents lower THD. The unipolar modulation is shown in Figure 1.  
Figure 1 shows the unipolar SPWM technique. A comparison is made between a sinusoidal signal and a triangular signal; the amplitude of the sine signal is \(A_{s}\) with a frequency \(f_{c}=1/t_{p}\), where \(t_{p}\) is its period, and the amplitude of the triangular signal is \(A_{t}\). with a frequency \(f_{0}=1/t_{0}\) where \(t_{0}\) is its period. For convenience, switching times are expressed in angles rather than in time; both are related by angular frequency \(\omega=2\pi f_{0}=\frac{2\pi}{t_{0}}\). The period of the sinusoidal signal \(t_{0}\) represents an angle of \(2\pi\). When the sine signal is greater than the triangular signal (angle \(\beta_{1}\)), the output of the inverter changes to a \"high\" state equal to the voltage that feeds the inverter (\(V_{DC}\)), and when the sine signal becomes less than the triangular signal, the output signal of the inverter changes to a \"low\" state where the output voltage is 0 V (angle \(\beta_{1t}\)). The duration of the pulse will be given by subtracting the rising and falling angles (\(\alpha_{1}=\beta_{1t}-\beta_{1}\)). By symmetry, the angles corresponding to the negative half-cycle are obtained by adding 180 degrees (\(\pi\) radians) to the angles obtained in the positive half-cycle. Among the drawbacks of natural sampling are the generation of sine and triangular signals, noise or interference problems, and the lack of versatility in reconfiguring parameters. Digital implementation solves many of the problems of natural sampling. However, one of the main drawbacks is that evaluating switching angles involves solving transcendental equations that do not have an analytical solution [20]. The main contribution of this work is the proposal of a very simple numerical solution to the transcendental equations. The proposed solution is developed using an algorithm that assess the angles of the SPWM technique. The solution is proposed for unipolar SPWM and single-phase inverters. However, it can be easily extrapolated to three-phase and multi-level inverters. The proposed algorithm can be easily implemented on different platforms such as a microcontroller, a Raspberry Pi or an FPGA.