\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\begin{array}{l}
\mathbf{if}\;1 - u0 \leq 0.9633153676986694:\\
\;\;\;\;\frac{-\log \left(1 - u0\right)}{\left(alphay \cdot alphay\right) \cdot cos2phi + sin2phi \cdot \left(alphax \cdot alphax\right)} \cdot \left(\left(alphay \cdot alphay\right) \cdot \left(alphax \cdot alphax\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}\\
\frac{u0}{\frac{sin2phi}{{alphay}^{2}} + \frac{cos2phi}{{alphax}^{2}}} + \left(0.3333333333333333 \cdot \frac{{u0}^{3}}{t_0} + \left(0.5 \cdot \frac{u0 \cdot u0}{t_0} + 0.25 \cdot \frac{{u0}^{4}}{t_0}\right)\right)
\end{array}\\
\end{array}
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(if (<= (- 1.0 u0) 0.9633153676986694)
(*
(/
(- (log (- 1.0 u0)))
(+ (* (* alphay alphay) cos2phi) (* sin2phi (* alphax alphax))))
(* (* alphay alphay) (* alphax alphax)))
(let* ((t_0
(+ (/ sin2phi (* alphay alphay)) (/ cos2phi (* alphax alphax)))))
(+
(/ u0 (+ (/ sin2phi (pow alphay 2.0)) (/ cos2phi (pow alphax 2.0))))
(+
(* 0.3333333333333333 (/ (pow u0 3.0) t_0))
(+ (* 0.5 (/ (* u0 u0) t_0)) (* 0.25 (/ (pow u0 4.0) t_0))))))))float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return -logf(1.0f - u0) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((1.0f - u0) <= 0.9633153676986694f) {
tmp = (-logf(1.0f - u0) / (((alphay * alphay) * cos2phi) + (sin2phi * (alphax * alphax)))) * ((alphay * alphay) * (alphax * alphax));
} else {
float t_0 = (sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax));
tmp = (u0 / ((sin2phi / powf(alphay, 2.0f)) + (cos2phi / powf(alphax, 2.0f)))) + ((0.3333333333333333f * (powf(u0, 3.0f) / t_0)) + ((0.5f * ((u0 * u0) / t_0)) + (0.25f * (powf(u0, 4.0f) / t_0))));
}
return tmp;
}



Bits error versus alphax



Bits error versus alphay



Bits error versus u0



Bits error versus cos2phi



Bits error versus sin2phi
Results
if (-.f32 1 u0) < 0.963315368Initial program 1.7
rmApplied frac-add_binary321.7
Applied associate-/r/_binary321.1
Simplified1.1
if 0.963315368 < (-.f32 1 u0) Initial program 14.5
Taylor expanded around 0 0.5
Simplified0.5
Taylor expanded around 0 0.5
Final simplification0.6
herbie shell --seed 2021204
(FPCore (alphax alphay u0 cos2phi sin2phi)
:name "Beckmann Distribution sample, tan2theta, alphax != alphay, u1 <= 0.5"
:precision binary32
:pre (and (<= 0.0001 alphax 1.0) (<= 0.0001 alphay 1.0) (<= 2.328306437e-10 u0 1.0) (<= 0.0 cos2phi 1.0) (<= 0.0 sin2phi))
(/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))