# Fast Low-Precision Computer-Generated Holography on GPU
## 2 Methodology
### LUT-Free Low-Precision Approximations to the Complex Exponential  
We would like find a way to compute cosine (and sine) functions efficiently, using fixed-point integers without the use of look-up tables (LUT). Accurately computing (co)sines takes significant resources, and has less utility in a low-precision computation environment. We are thus seeking approximations requiring minimal amount calculations. Since the appearance of holograms remains invariant under scaling, we should try to minimize the deviation from the true cosine only up to a constant scaling factor.  
For the first approximation, we take a triangular signal with matching frequency and phase to a pure cosine. This is also known in the CGH literature as \"Nishitsuji's approximation\" [19]. This approximation consists of linear segments, described by an absolute difference operator. This can thus be computed easily, using only a difference and a conditional sign change. Within the interval of interest \([0,2\pi[\), we obtain the following:  
\[\cos(\phi)\approx TA(\phi)\propto|\phi-\pi| \tag{6}\]  
We call this function \(TA\) the \"triangular approximation\". The error is small when the (co)sine is close to 0, given their Taylor expansion, but the deviation is quite significant near the peaks of the triangular wave. We aim to significantly reduce that error by making a modification. We first define the clipping function as follows:  
\[\text{clip}(x,d)=\begin{cases}-d,&\text{if }x<d\\ x,&\text{if }|x|\leq d\\ d,&\text{if }x>d\end{cases} \tag{7}\]  
which saturates a signal between \(-d\) and \(+d\). This can be used to reduce the relative slope of the approximate function near the extremes of the cosine. We use the following:  
\[\cos(\phi)\approx PA(\phi)\propto TA(\phi)+\text{clip}(TA(\phi),d) \tag{8}\]  
which we call the \"piecewise approximation\". It either doubles the computed \(TA\) value, or adds a saturated version of the signal to itself when \(|x|>d\). The relative slope is thus halved near the peaks and valleys of the cosine. We still need to determine the best value for \(d\), so that the squared error \(\|\cos(\phi)-PA(\phi)\|\) is minimal (using the Euclidean norm \(\|\cdot\|\)). This optimum can be found easily since the error function is convex, cf. Figure 2. The minimum is reached at \(d=0.7515\), where the error becomes \(1.557\times 10^{-3}\). This can be contrasted with the error of the triangular approximation, which equals to \(2.272\times 10^{-2}\) at optimal scaling, differing by an order of magnitude.  
The resulting functions can be viewed in Figure 3. One can see that changes in the slopes of the smoothing of the piecewise approximation match the reference cosine much  
Figure 2: Euclidean norm of the error \(\|\cos(\phi)-PA(\phi)\|\) as a function of \(d\). The function is convex, reaching a minimum error of \(1.557\times 10^{-3}\) at \(d=0.7515\).  
better, reducing the error by a factor of \(\approx\)7. This allows for the calculation of hologram wave fields with increased accuracy without sacrificing much extra calculation time. The sine function can be computed analogously by using a \(\frac{\pi}{2}\) phase delay.