Average Error: 0.2 → 0.2
Time: 1.3min
Precision: binary32
\[\left(\left(\left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 0.5\right)\right) \land \left(0.0001 \leq alphax \land alphax \leq 1\right)\right) \land \left(0.0001 \leq alphay \land alphay \leq 1\right)\]
\[\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 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\\ t_1 := \cos t_0\\ t_2 := 1 + t_1\\ t_3 := \sin t_0\\ \frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(t_1, \frac{\frac{\left({t_2}^{9} + -1\right) \cdot \frac{1}{{t_2}^{6} + \left(1 + {t_2}^{3}\right)}}{{t_2}^{2} + \left(1 + t_2\right)}}{alphax \cdot alphax}, \frac{t_3 \cdot t_3}{alphay \cdot alphay}\right)}}{1 - u0}}} \end{array} \]
\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 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\\
t_1 := \cos t_0\\
t_2 := 1 + t_1\\
t_3 := \sin t_0\\
\frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(t_1, \frac{\frac{\left({t_2}^{9} + -1\right) \cdot \frac{1}{{t_2}^{6} + \left(1 + {t_2}^{3}\right)}}{{t_2}^{2} + \left(1 + t_2\right)}}{alphax \cdot alphax}, \frac{t_3 \cdot t_3}{alphay \cdot alphay}\right)}}{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 (atan (* (/ alphay alphax) (tan (* PI (fma 2.0 u1 0.5))))))
        (t_1 (cos t_0))
        (t_2 (+ 1.0 t_1))
        (t_3 (sin t_0)))
   (/
    1.0
    (sqrt
     (+
      1.0
      (/
       (/
        u0
        (fma
         t_1
         (/
          (/
           (*
            (+ (pow t_2 9.0) -1.0)
            (/ 1.0 (+ (pow t_2 6.0) (+ 1.0 (pow t_2 3.0)))))
           (+ (pow t_2 2.0) (+ 1.0 t_2)))
          (* alphax alphax))
         (/ (* t_3 t_3) (* alphay alphay))))
       (- 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 = atanf(((alphay / alphax) * tanf((((float) M_PI) * fmaf(2.0f, u1, 0.5f)))));
	float t_1 = cosf(t_0);
	float t_2 = 1.0f + t_1;
	float t_3 = sinf(t_0);
	return 1.0f / sqrtf((1.0f + ((u0 / fmaf(t_1, ((((powf(t_2, 9.0f) + -1.0f) * (1.0f / (powf(t_2, 6.0f) + (1.0f + powf(t_2, 3.0f))))) / (powf(t_2, 2.0f) + (1.0f + t_2))) / (alphax * alphax)), ((t_3 * t_3) / (alphay * alphay)))) / (1.0f - u0))));
}

Error

Bits error versus u0

Bits error versus u1

Bits error versus alphax

Bits error versus alphay

Derivation

  1. Initial program 0.2

    \[\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}}} \]
  2. Simplified0.2

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right), \frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}{alphax \cdot alphax}, \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}{alphay \cdot alphay}\right)}}{1 - u0}}}} \]
  3. Applied egg-rr0.2

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right), \frac{\color{blue}{e^{\mathsf{log1p}\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\right)} - 1}}{alphax \cdot alphax}, \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}{alphay \cdot alphay}\right)}}{1 - u0}}} \]
  4. Applied egg-rr0.2

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right), \frac{\color{blue}{\frac{{\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right)}^{3} + -1}{{\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right)}^{2} + \left(\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right) + 1\right)}}}{alphax \cdot alphax}, \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}{alphay \cdot alphay}\right)}}{1 - u0}}} \]
  5. Applied egg-rr0.2

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right), \frac{\frac{\color{blue}{\left({\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right)}^{9} + -1\right) \cdot \frac{1}{{\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right)}^{6} + \left(1 - {\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right)}^{3} \cdot -1\right)}}}{{\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right)}^{2} + \left(\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) + 1\right) + 1\right)}}{alphax \cdot alphax}, \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}{alphay \cdot alphay}\right)}}{1 - u0}}} \]
  6. Final simplification0.2

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{u0}{\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right), \frac{\frac{\left({\left(1 + \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\right)}^{9} + -1\right) \cdot \frac{1}{{\left(1 + \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\right)}^{6} + \left(1 + {\left(1 + \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\right)}^{3}\right)}}{{\left(1 + \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\right)}^{2} + \left(1 + \left(1 + \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)\right)\right)}}{alphax \cdot alphax}, \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}{alphay \cdot alphay}\right)}}{1 - u0}}} \]

Reproduce

herbie shell --seed 2022130 
(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))))))