\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}}
\begin{array}{l}
t_0 := \sqrt{\sqrt[3]{\pi}}\\
\frac{1}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(cosTheta, -2, 1\right)}, \mathsf{fma}\left(c, c + -1, 1\right), \left(\left(cosTheta \cdot e^{cosTheta \cdot cosTheta}\right) \cdot {t_0}^{3}\right) \cdot \left(1 + {c}^{3}\right)\right)} \cdot \left(\left(1 + \left(c \cdot c - c\right)\right) \cdot \left(\sqrt{\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}} \cdot \left(t_0 \cdot \left(cosTheta \cdot {\left(e^{cosTheta}\right)}^{cosTheta}\right)\right)\right)\right)
\end{array}
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ 1.0 c)
(*
(* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))
(exp (* (- cosTheta) cosTheta))))))(FPCore (cosTheta c)
:precision binary32
(let* ((t_0 (sqrt (cbrt PI))))
(*
(/
1.0
(fma
(sqrt (fma cosTheta -2.0 1.0))
(fma c (+ c -1.0) 1.0)
(*
(* (* cosTheta (exp (* cosTheta cosTheta))) (pow t_0 3.0))
(+ 1.0 (pow c 3.0)))))
(*
(+ 1.0 (- (* c c) c))
(*
(sqrt (* (cbrt PI) (cbrt PI)))
(* t_0 (* cosTheta (pow (exp cosTheta) cosTheta))))))))float code(float cosTheta, float c) {
return 1.0f / ((1.0f + c) + (((1.0f / sqrtf((float) M_PI)) * (sqrtf((1.0f - cosTheta) - cosTheta) / cosTheta)) * expf(-cosTheta * cosTheta)));
}
float code(float cosTheta, float c) {
float t_0 = sqrtf(cbrtf((float) M_PI));
return (1.0f / fmaf(sqrtf(fmaf(cosTheta, -2.0f, 1.0f)), fmaf(c, (c + -1.0f), 1.0f), (((cosTheta * expf(cosTheta * cosTheta)) * powf(t_0, 3.0f)) * (1.0f + powf(c, 3.0f))))) * ((1.0f + ((c * c) - c)) * (sqrtf(cbrtf((float) M_PI) * cbrtf((float) M_PI)) * (t_0 * (cosTheta * powf(expf(cosTheta), cosTheta)))));
}



Bits error versus cosTheta



Bits error versus c
Initial program 0.7
Simplified0.5
Applied add-cube-cbrt_binary320.5
Applied sqrt-prod_binary320.5
Applied associate-*l*_binary320.5
Applied flip3-+_binary320.5
Applied frac-add_binary320.5
Applied associate-/r/_binary320.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2021275
(FPCore (cosTheta c)
:name "Beckmann Sample, normalization factor"
:precision binary32
:pre (and (and (< 0.0 cosTheta) (< cosTheta 0.9999)) (and (< -1.0 c) (< c 1.0)))
(/ 1.0 (+ (+ 1.0 c) (* (* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta)) (exp (* (- cosTheta) cosTheta))))))