\frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}}
\begin{array}{l}
t_0 := \left(\pi \cdot 2\right) \cdot u1\\
t_1 := \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(t_0 + \pi \cdot 0.5\right)\right)\\
\frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\mathsf{expm1}\left(\mathsf{log1p}\left({\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\mathsf{fma}\left(\pi, 0.5, t_0\right)\right)\right)}^{2}\right)\right)}{alphax \cdot alphax} + \frac{t_1 \cdot t_1}{alphay \cdot alphay}} \cdot u0}{1 - u0}}}
\end{array}
(FPCore (u0 u1 alphax alphay)
:precision binary32
(/
1.0
(sqrt
(+
1.0
(/
(*
(/
1.0
(+
(/
(*
(cos
(atan (* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI))))))
(cos
(atan
(* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI)))))))
(* alphax alphax))
(/
(*
(sin
(atan (* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI))))))
(sin
(atan
(* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI)))))))
(* alphay alphay))))
u0)
(- 1.0 u0))))))(FPCore (u0 u1 alphax alphay)
:precision binary32
(let* ((t_0 (* (* PI 2.0) u1))
(t_1 (sin (atan (* (/ alphay alphax) (tan (+ t_0 (* PI 0.5))))))))
(/
1.0
(sqrt
(+
1.0
(/
(*
(/
1.0
(+
(/
(expm1
(log1p
(pow
(cos (atan (* (/ alphay alphax) (tan (fma PI 0.5 t_0)))))
2.0)))
(* alphax alphax))
(/ (* t_1 t_1) (* alphay alphay))))
u0)
(- 1.0 u0)))))))float code(float u0, float u1, float alphax, float alphay) {
return 1.0f / sqrtf((1.0f + (((1.0f / (((cosf(atanf(((alphay / alphax) * tanf((((2.0f * ((float) M_PI)) * u1) + (0.5f * ((float) M_PI))))))) * cosf(atanf(((alphay / alphax) * tanf((((2.0f * ((float) M_PI)) * u1) + (0.5f * ((float) M_PI)))))))) / (alphax * alphax)) + ((sinf(atanf(((alphay / alphax) * tanf((((2.0f * ((float) M_PI)) * u1) + (0.5f * ((float) M_PI))))))) * sinf(atanf(((alphay / alphax) * tanf((((2.0f * ((float) M_PI)) * u1) + (0.5f * ((float) M_PI)))))))) / (alphay * alphay)))) * u0) / (1.0f - u0))));
}
float code(float u0, float u1, float alphax, float alphay) {
float t_0 = (((float) M_PI) * 2.0f) * u1;
float t_1 = sinf(atanf(((alphay / alphax) * tanf((t_0 + (((float) M_PI) * 0.5f))))));
return 1.0f / sqrtf((1.0f + (((1.0f / ((expm1f(log1pf(powf(cosf(atanf(((alphay / alphax) * tanf(fmaf(((float) M_PI), 0.5f, t_0))))), 2.0f))) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (1.0f - u0))));
}



Bits error versus u0



Bits error versus u1



Bits error versus alphax



Bits error versus alphay
Initial program 0.2
Applied egg-rr0.2
Final simplification0.2
herbie shell --seed 2022129
(FPCore (u0 u1 alphax alphay)
:name "Trowbridge-Reitz Sample, sample surface normal, cosTheta"
:precision binary32
:pre (and (and (and (and (<= 2.328306437e-10 u0) (<= u0 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 0.5))) (and (<= 0.0001 alphax) (<= alphax 1.0))) (and (<= 0.0001 alphay) (<= alphay 1.0)))
(/ 1.0 (sqrt (+ 1.0 (/ (* (/ 1.0 (+ (/ (* (cos (atan (* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI)))))) (cos (atan (* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI))))))) (* alphax alphax)) (/ (* (sin (atan (* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI)))))) (sin (atan (* (/ alphay alphax) (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI))))))) (* alphay alphay)))) u0) (- 1.0 u0))))))