\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\begin{array}{l}
\mathbf{if}\;1 - u0 \leq 0.9502819776535034:\\
\;\;\;\;\begin{array}{l}
t_0 := \log \left(1 - u0\right)\\
\sqrt[3]{\left(\left(\alpha \cdot \left(-\alpha\right)\right) \cdot \left(\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)\right)\right) \cdot \left(t_0 \cdot \left(t_0 \cdot t_0\right)\right)}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;u0 \cdot \left(\alpha \cdot \alpha\right) + \alpha \cdot \left(\alpha \cdot \left(0.25 \cdot {u0}^{4} + \left(u0 \cdot u0\right) \cdot \left(0.5 + u0 \cdot 0.3333333333333333\right)\right)\right)\\
\end{array}
(FPCore (alpha u0) :precision binary32 (* (* (- alpha) alpha) (log (- 1.0 u0))))
(FPCore (alpha u0)
:precision binary32
(if (<= (- 1.0 u0) 0.9502819776535034)
(let* ((t_0 (log (- 1.0 u0))))
(cbrt
(*
(* (* alpha (- alpha)) (* (* alpha alpha) (* alpha alpha)))
(* t_0 (* t_0 t_0)))))
(+
(* u0 (* alpha alpha))
(*
alpha
(*
alpha
(+
(* 0.25 (pow u0 4.0))
(* (* u0 u0) (+ 0.5 (* u0 0.3333333333333333)))))))))float code(float alpha, float u0) {
return (-alpha * alpha) * logf(1.0f - u0);
}
float code(float alpha, float u0) {
float tmp;
if ((1.0f - u0) <= 0.9502819776535034f) {
float t_0_1 = logf(1.0f - u0);
tmp = cbrtf(((alpha * -alpha) * ((alpha * alpha) * (alpha * alpha))) * (t_0_1 * (t_0_1 * t_0_1)));
} else {
tmp = (u0 * (alpha * alpha)) + (alpha * (alpha * ((0.25f * powf(u0, 4.0f)) + ((u0 * u0) * (0.5f + (u0 * 0.3333333333333333f))))));
}
return tmp;
}



Bits error versus alpha



Bits error versus u0
Results
if (-.f32 1 u0) < 0.950281978Initial program 1.0
rmApplied add-cbrt-cube_binary321.0
Applied add-cbrt-cube_binary321.0
Applied cbrt-unprod_binary321.0
if 0.950281978 < (-.f32 1 u0) Initial program 16.3
Taylor expanded in u0 around 0 0.4
Simplified0.4
Taylor expanded in u0 around 0 0.4
Simplified0.4
rmApplied distribute-rgt-in_binary320.4
Applied distribute-rgt-in_binary320.4
Simplified0.4
Simplified0.4
Final simplification0.5
herbie shell --seed 2021206
(FPCore (alpha u0)
:name "Beckmann Distribution sample, tan2theta, alphax == alphay"
:precision binary32
:pre (and (<= 0.0001 alpha 1.0) (<= 2.328306437e-10 u0 1.0))
(* (* (- alpha) alpha) (log (- 1.0 u0))))