\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}}
\frac{1}{\left(1 + c\right) + \sqrt{\mathsf{fma}\left(cosTheta, -2, 1\right)} \cdot \frac{1}{\sqrt{\sqrt[3]{\pi}} \cdot \mathsf{fma}\left({cosTheta}^{3}, \sqrt[3]{\pi}, \mathsf{fma}\left(0.5, \sqrt[3]{\pi} \cdot {cosTheta}^{5}, \mathsf{fma}\left(cosTheta, \sqrt[3]{\pi}, 0.16666666666666666 \cdot \left(\sqrt[3]{\pi} \cdot {cosTheta}^{7}\right)\right)\right)\right)}}
(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
(/
1.0
(+
(+ 1.0 c)
(*
(sqrt (fma cosTheta -2.0 1.0))
(/
1.0
(*
(sqrt (cbrt PI))
(fma
(pow cosTheta 3.0)
(cbrt PI)
(fma
0.5
(* (cbrt PI) (pow cosTheta 5.0))
(fma
cosTheta
(cbrt PI)
(* 0.16666666666666666 (* (cbrt PI) (pow cosTheta 7.0))))))))))))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) {
return 1.0f / ((1.0f + c) + (sqrtf(fmaf(cosTheta, -2.0f, 1.0f)) * (1.0f / (sqrtf(cbrtf((float) M_PI)) * fmaf(powf(cosTheta, 3.0f), cbrtf((float) M_PI), fmaf(0.5f, (cbrtf((float) M_PI) * powf(cosTheta, 5.0f)), fmaf(cosTheta, cbrtf((float) M_PI), (0.16666666666666666f * (cbrtf((float) M_PI) * powf(cosTheta, 7.0f))))))))));
}



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.4
Applied div-inv_binary320.5
Applied sqrt-prod_binary321.1
Applied associate-*l*_binary321.2
Simplified0.5
Taylor expanded in cosTheta around 0 0.5
Simplified0.5
Final simplification0.5
herbie shell --seed 2022068
(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))))))