1. Introduction
The approximation of trigonometric functions is an important topic in electronics engineering, including digital communications, arithmetic computing, and signal processing [1–4]. Field programmable gate arrays (FPGAs) and micro controllers are used to implement digital circuits suffers from limited resources such as floating-point multipliers, dividers, adders, LUT, and digital signal processors. Therefore, simplification techniques are required to reduce the large number of calculations in embedded systems [5] for example, two arithmetic operations; division and square root are slower than multiplication and addition [6,7].
Small, low-power programmable logic circuits are utilized in many goods and applications, including smartphones, calculators, audio accessories, medical equipment, Internet of Things devices, and remote-control drones [8-19]. Fast approximate computation is also crucial in machine learning for addressing issues like accelerated learning and immediate inference processing [20-23].
Improving performance and reducing model size in machine learning is feasible by performing approximation calculations using multiply-add operations, which can be processed in parallel by graphics processing units.
When the performance of processor is low, reducing the operation are required to be suitable with the speed of the processor such as replacing the division process with another mathematical operations [24-25]. Also, different techniques are used to implement exponential and logarithmic functions [21-26], and reciprocal sqrt.
Taylor expansions is the first approximations of trigonometric functions; however, it suffers from slow conversions or long computation time. While inverse trigonometric functions replaced by many methods such as LUT, CORDIC algorithm, rational, polynomial approximations. Unfortunately, all the mentioned methods require large amount of memory.
This paper presents a proposed method to approximate sine, cos, and inverse tan functions depending on adder and multiplier without the use of a memory. The optimization method minimizes the error over the entire domain.
2. Proposed Mathematical Method
A- First Method
To do rapid calculations for embedded systems, the suggested method implements the idea of encoding sine and cosine functions using a mathematical formula based on multiplication and addition without memory, division operations, and iterative convergence procedures. The approximate formula was developed using the steps below.
For sine and cosine functions, it was demonstrated that an effective approximation formula might be obtained using parabolic functions, considering both processing cost and approximation error. Some tasks, however, necessitate a more precise result. The second approach involves extending the approximation formula with the residual correction to lower the approximated error while keeping the processing cost constant. Residual correction approximations for trigonometric functions are as follows:
These are of the same form as the famous quadratic approximation for a sine function in , but the error is larger around , as shown in Figure 2.
To carry out the procedure while being limited to the multiply-add method of computation. For this purpose, we consider the sin function and assess the initial approximation's residuals. For this residual, we can consider the modified RCF that is obtained by multiplying and adding:
B. Second Method
Using ( ) for RCF, the second method of the sine function is
A similar argument can be made for the second method of the cos function: ( ) ( )[( ) ( ) ] (4)
The approximate shape of the final second approximation function is shown in Figure 4.
3. Results
To investigate the performance of the 1st, 2nd approximation methods by showing the residual error, and execution time of both methods. Figure 5 shows the residual error of the first of 1st approximation method it approximately equals 0.056. figure 6. Shows the residual error of the 2nd method which is reduced to be 0.000092.
The processing time was measured on a 2.5 GHz Intel Xeon E3 processor. The result was an approximation for sine that took 1.4 ns to calculate and an approximation for cosine that took 2.04 ns to figure; both were roughly twice as fast as the initial approximation but still over 30 times faster than the standard mathematical built-in functions. h. The computational cost and maximum error for the first and second approximation approaches are shown in Table 2.
between Taylor series and proposed two methods
As shown in figure 7 Taylor series required several iterations to achieve accurate results. The 9th iteration of Taylor series has error more than the 2nd approximation method.
As shown in Table 3. The 1st method have a smaller error compred to taylor series with 9th iterations while the 2nd method achives a less error compared to 1st method. Also the number of multiplications increases with the number of iterations in taylor series method but with the propsed 1st method achives two multiplication only and four in the 2nd proposed method.
Conclusions
In this paper, we proposed two approximation methods to sine, and cosine with a high accuracy using a small number of calculations to allow simple implementation for embedded systems. Simulations indicate a reduction of absolute error in the 2nd method to be 0.000092 which is negligible. Also, the proposed method reduces the number of multiplications to be 2 in the 1st method and 4 in the 2nd method which reduced the power consumption and increase4 the operating frequency. A comparison with Taylor series indicates that the proposed system achieves less error compared to the 9th iteration of Taylor series. The proposed method suitable for embedded systems in drones and robots.