Average Error: 0.2 → 0.2
Time: 15.9s
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 := \pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\\ t_1 := alphay \cdot \frac{\tan t_0}{alphax}\\ t_2 := \sin \tan^{-1} t_1\\ \frac{1}{\sqrt{1 + \frac{u0}{\mathsf{fma}\left({\left(\mathsf{hypot}\left(1, t_1\right)\right)}^{-1}, \frac{\frac{1}{\mathsf{hypot}\left(1, alphay \cdot \frac{\tan \left({\left(\sqrt{t_0}\right)}^{2}\right)}{alphax}\right)}}{alphax \cdot alphax}, t_2 \cdot \frac{t_2}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \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 (fma 2.0 u1 0.5)))
        (t_1 (* alphay (/ (tan t_0) alphax)))
        (t_2 (sin (atan t_1))))
   (/
    1.0
    (sqrt
     (+
      1.0
      (/
       u0
       (*
        (fma
         (pow (hypot 1.0 t_1) -1.0)
         (/
          (/ 1.0 (hypot 1.0 (* alphay (/ (tan (pow (sqrt t_0) 2.0)) alphax))))
          (* alphax alphax))
         (* t_2 (/ t_2 (* 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 = ((float) M_PI) * fmaf(2.0f, u1, 0.5f);
	float t_1 = alphay * (tanf(t_0) / alphax);
	float t_2 = sinf(atanf(t_1));
	return 1.0f / sqrtf((1.0f + (u0 / (fmaf(powf(hypotf(1.0f, t_1), -1.0f), ((1.0f / hypotf(1.0f, (alphay * (tanf(powf(sqrtf(t_0), 2.0f)) / alphax)))) / (alphax * alphax)), (t_2 * (t_2 / (alphay * alphay)))) * (1.0f - u0)))));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) / sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) / Float32(Float32(Float32(cos(atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * u1) + Float32(Float32(0.5) * Float32(pi))))))) * cos(atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * u1) + Float32(Float32(0.5) * Float32(pi)))))))) / Float32(alphax * alphax)) + Float32(Float32(sin(atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * u1) + Float32(Float32(0.5) * Float32(pi))))))) * sin(atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * u1) + Float32(Float32(0.5) * Float32(pi)))))))) / Float32(alphay * alphay)))) * u0) / Float32(Float32(1.0) - u0)))))
end
function code(u0, u1, alphax, alphay)
	t_0 = Float32(Float32(pi) * fma(Float32(2.0), u1, Float32(0.5)))
	t_1 = Float32(alphay * Float32(tan(t_0) / alphax))
	t_2 = sin(atan(t_1))
	return Float32(Float32(1.0) / sqrt(Float32(Float32(1.0) + Float32(u0 / Float32(fma((hypot(Float32(1.0), t_1) ^ Float32(-1.0)), Float32(Float32(Float32(1.0) / hypot(Float32(1.0), Float32(alphay * Float32(tan((sqrt(t_0) ^ Float32(2.0))) / alphax)))) / Float32(alphax * alphax)), Float32(t_2 * Float32(t_2 / Float32(alphay * alphay)))) * Float32(Float32(1.0) - u0))))))
end
\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 := \pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\\
t_1 := alphay \cdot \frac{\tan t_0}{alphax}\\
t_2 := \sin \tan^{-1} t_1\\
\frac{1}{\sqrt{1 + \frac{u0}{\mathsf{fma}\left({\left(\mathsf{hypot}\left(1, t_1\right)\right)}^{-1}, \frac{\frac{1}{\mathsf{hypot}\left(1, alphay \cdot \frac{\tan \left({\left(\sqrt{t_0}\right)}^{2}\right)}{alphax}\right)}}{alphax \cdot alphax}, t_2 \cdot \frac{t_2}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}}
\end{array}

Error

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{u0}{\mathsf{fma}\left(\cos \tan^{-1} \left(alphay \cdot \frac{\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)}{alphax}\right), \frac{\cos \tan^{-1} \left(alphay \cdot \frac{\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)}{alphax}\right)}{alphax \cdot alphax}, \sin \tan^{-1} \left(alphay \cdot \frac{\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)}{alphax}\right) \cdot \frac{\sin \tan^{-1} \left(alphay \cdot \frac{\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)}{alphax}\right)}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}}} \]
  3. Applied egg-rr0.2

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

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

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

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

Reproduce

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