Trowbridge-Reitz Sample, sample surface normal, cosTheta

Percentage Accurate: 99.3% → 99.9%
Time: 56.3s
Alternatives: 9
Speedup: 2.1×

Specification

?
\[\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)\]
\[\begin{array}{l} t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)\\ t_1 := \sin t\_0\\ t_2 := \cos t\_0\\ \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{t\_2 \cdot t\_2}{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
  :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)))
  (let* ((t_0
        (atan
         (*
          (/ alphay alphax)
          (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI))))))
       (t_1 (sin t_0))
       (t_2 (cos t_0)))
  (/
   1.0
   (sqrt
    (+
     1.0
     (/
      (*
       (/
        1.0
        (+
         (/ (* t_2 t_2) (* alphax alphax))
         (/ (* t_1 t_1) (* alphay alphay))))
       u0)
      (- 1.0 u0)))))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = atanf(((alphay / alphax) * tanf((((2.0f * ((float) M_PI)) * u1) + (0.5f * ((float) M_PI))))));
	float t_1 = sinf(t_0);
	float t_2 = cosf(t_0);
	return 1.0f / sqrtf((1.0f + (((1.0f / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (1.0f - u0))));
}
function code(u0, u1, alphax, alphay)
	t_0 = atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * u1) + Float32(Float32(0.5) * Float32(pi))))))
	t_1 = sin(t_0)
	t_2 = cos(t_0)
	return Float32(Float32(1.0) / sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) / Float32(Float32(Float32(t_2 * t_2) / Float32(alphax * alphax)) + Float32(Float32(t_1 * t_1) / Float32(alphay * alphay)))) * u0) / Float32(Float32(1.0) - u0)))))
end
function tmp = code(u0, u1, alphax, alphay)
	t_0 = atan(((alphay / alphax) * tan((((single(2.0) * single(pi)) * u1) + (single(0.5) * single(pi))))));
	t_1 = sin(t_0);
	t_2 = cos(t_0);
	tmp = single(1.0) / sqrt((single(1.0) + (((single(1.0) / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (single(1.0) - u0))));
end
\begin{array}{l}
t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
\frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{t\_2 \cdot t\_2}{alphax \cdot alphax} + \frac{t\_1 \cdot t\_1}{alphay \cdot alphay}} \cdot u0}{1 - u0}}}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.3% accurate, 1.0× speedup?

\[\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)\]
\[\begin{array}{l} t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)\\ t_1 := \sin t\_0\\ t_2 := \cos t\_0\\ \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{t\_2 \cdot t\_2}{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
  :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)))
  (let* ((t_0
        (atan
         (*
          (/ alphay alphax)
          (tan (+ (* (* 2.0 PI) u1) (* 0.5 PI))))))
       (t_1 (sin t_0))
       (t_2 (cos t_0)))
  (/
   1.0
   (sqrt
    (+
     1.0
     (/
      (*
       (/
        1.0
        (+
         (/ (* t_2 t_2) (* alphax alphax))
         (/ (* t_1 t_1) (* alphay alphay))))
       u0)
      (- 1.0 u0)))))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = atanf(((alphay / alphax) * tanf((((2.0f * ((float) M_PI)) * u1) + (0.5f * ((float) M_PI))))));
	float t_1 = sinf(t_0);
	float t_2 = cosf(t_0);
	return 1.0f / sqrtf((1.0f + (((1.0f / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (1.0f - u0))));
}
function code(u0, u1, alphax, alphay)
	t_0 = atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * u1) + Float32(Float32(0.5) * Float32(pi))))))
	t_1 = sin(t_0)
	t_2 = cos(t_0)
	return Float32(Float32(1.0) / sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) / Float32(Float32(Float32(t_2 * t_2) / Float32(alphax * alphax)) + Float32(Float32(t_1 * t_1) / Float32(alphay * alphay)))) * u0) / Float32(Float32(1.0) - u0)))))
end
function tmp = code(u0, u1, alphax, alphay)
	t_0 = atan(((alphay / alphax) * tan((((single(2.0) * single(pi)) * u1) + (single(0.5) * single(pi))))));
	t_1 = sin(t_0);
	t_2 = cos(t_0);
	tmp = single(1.0) / sqrt((single(1.0) + (((single(1.0) / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (single(1.0) - u0))));
end
\begin{array}{l}
t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
\frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{t\_2 \cdot t\_2}{alphax \cdot alphax} + \frac{t\_1 \cdot t\_1}{alphay \cdot alphay}} \cdot u0}{1 - u0}}}
\end{array}

Alternative 1: 99.9% accurate, 2.0× speedup?

\[\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)\]
\[\begin{array}{l} t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\ {\left(\frac{u0}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh t\_0}{alphay}\right)}^{2} + \frac{{\cosh t\_0}^{-2}}{alphax \cdot alphax}\right)} - -1\right)}^{-0.5} \end{array} \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (let* ((t_0
        (asinh (* (tan (* PI (fma u1 2.0 0.5))) (/ alphay alphax)))))
  (pow
   (-
    (/
     u0
     (*
      (- 1.0 u0)
      (+
       (pow (/ (tanh t_0) alphay) 2.0)
       (/ (pow (cosh t_0) -2.0) (* alphax alphax)))))
    -1.0)
   -0.5)))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = asinhf((tanf((((float) M_PI) * fmaf(u1, 2.0f, 0.5f))) * (alphay / alphax)));
	return powf(((u0 / ((1.0f - u0) * (powf((tanhf(t_0) / alphay), 2.0f) + (powf(coshf(t_0), -2.0f) / (alphax * alphax))))) - -1.0f), -0.5f);
}
function code(u0, u1, alphax, alphay)
	t_0 = asinh(Float32(tan(Float32(Float32(pi) * fma(u1, Float32(2.0), Float32(0.5)))) * Float32(alphay / alphax)))
	return Float32(Float32(u0 / Float32(Float32(Float32(1.0) - u0) * Float32((Float32(tanh(t_0) / alphay) ^ Float32(2.0)) + Float32((cosh(t_0) ^ Float32(-2.0)) / Float32(alphax * alphax))))) - Float32(-1.0)) ^ Float32(-0.5)
end
\begin{array}{l}
t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\
{\left(\frac{u0}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh t\_0}{alphay}\right)}^{2} + \frac{{\cosh t\_0}^{-2}}{alphax \cdot alphax}\right)} - -1\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\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. Applied rewrites99.9%

    \[\leadsto \color{blue}{{\left(\frac{u0}{\left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right) \cdot \left(1 - u0\right)} - -1\right)}^{-0.5}} \]
  3. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto {\left(\frac{u0}{\color{blue}{\left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right) \cdot \left(1 - u0\right)}} - -1\right)}^{\frac{-1}{2}} \]
    2. *-commutativeN/A

      \[\leadsto {\left(\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1\right)}^{\frac{-1}{2}} \]
    3. lower-*.f3299.9%

      \[\leadsto {\left(\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1\right)}^{-0.5} \]
  4. Applied rewrites99.9%

    \[\leadsto {\left(\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1\right)}^{-0.5} \]
  5. Add Preprocessing

Alternative 2: 99.4% accurate, 2.1× speedup?

\[\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)\]
\[\begin{array}{l} t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\ \frac{1}{\sqrt{\frac{\frac{u0}{{\left(\frac{\tanh t\_0}{alphay}\right)}^{2} + {\left(\frac{1}{\cosh t\_0 \cdot alphax}\right)}^{2}} + \left(1 - u0\right)}{1 - u0}}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (let* ((t_0
        (asinh (* (tan (* PI (fma u1 2.0 0.5))) (/ alphay alphax)))))
  (/
   1.0
   (sqrt
    (/
     (+
      (/
       u0
       (+
        (pow (/ (tanh t_0) alphay) 2.0)
        (pow (/ 1.0 (* (cosh t_0) alphax)) 2.0)))
      (- 1.0 u0))
     (- 1.0 u0))))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = asinhf((tanf((((float) M_PI) * fmaf(u1, 2.0f, 0.5f))) * (alphay / alphax)));
	return 1.0f / sqrtf((((u0 / (powf((tanhf(t_0) / alphay), 2.0f) + powf((1.0f / (coshf(t_0) * alphax)), 2.0f))) + (1.0f - u0)) / (1.0f - u0)));
}
function code(u0, u1, alphax, alphay)
	t_0 = asinh(Float32(tan(Float32(Float32(pi) * fma(u1, Float32(2.0), Float32(0.5)))) * Float32(alphay / alphax)))
	return Float32(Float32(1.0) / sqrt(Float32(Float32(Float32(u0 / Float32((Float32(tanh(t_0) / alphay) ^ Float32(2.0)) + (Float32(Float32(1.0) / Float32(cosh(t_0) * alphax)) ^ Float32(2.0)))) + Float32(Float32(1.0) - u0)) / Float32(Float32(1.0) - u0))))
end
\begin{array}{l}
t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\
\frac{1}{\sqrt{\frac{\frac{u0}{{\left(\frac{\tanh t\_0}{alphay}\right)}^{2} + {\left(\frac{1}{\cosh t\_0 \cdot alphax}\right)}^{2}} + \left(1 - u0\right)}{1 - u0}}}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\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. Applied rewrites99.4%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\frac{alphay \cdot alphay}{{\left(alphay \cdot \frac{1}{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right) \cdot alphax}\right)}^{2} + {\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}}} \cdot u0}{1 - u0}}} \]
  3. Applied rewrites99.3%

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\frac{\frac{u0}{{\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + {\left(\frac{1}{\cosh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right) \cdot alphax}\right)}^{2}} + \left(1 - u0\right)}{1 - u0}}}} \]
  4. Add Preprocessing

Alternative 3: 99.4% accurate, 2.1× speedup?

\[\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)\]
\[\begin{array}{l} t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\ \frac{1}{\sqrt{\mathsf{fma}\left(\frac{alphay \cdot alphay}{{\left(\frac{alphay}{\cosh t\_0 \cdot alphax}\right)}^{2} + {\tanh t\_0}^{2}}, \frac{u0}{1 - u0}, 1\right)}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (let* ((t_0
        (asinh (* (tan (* PI (fma u1 2.0 0.5))) (/ alphay alphax)))))
  (/
   1.0
   (sqrt
    (fma
     (/
      (* alphay alphay)
      (+
       (pow (/ alphay (* (cosh t_0) alphax)) 2.0)
       (pow (tanh t_0) 2.0)))
     (/ u0 (- 1.0 u0))
     1.0)))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = asinhf((tanf((((float) M_PI) * fmaf(u1, 2.0f, 0.5f))) * (alphay / alphax)));
	return 1.0f / sqrtf(fmaf(((alphay * alphay) / (powf((alphay / (coshf(t_0) * alphax)), 2.0f) + powf(tanhf(t_0), 2.0f))), (u0 / (1.0f - u0)), 1.0f));
}
function code(u0, u1, alphax, alphay)
	t_0 = asinh(Float32(tan(Float32(Float32(pi) * fma(u1, Float32(2.0), Float32(0.5)))) * Float32(alphay / alphax)))
	return Float32(Float32(1.0) / sqrt(fma(Float32(Float32(alphay * alphay) / Float32((Float32(alphay / Float32(cosh(t_0) * alphax)) ^ Float32(2.0)) + (tanh(t_0) ^ Float32(2.0)))), Float32(u0 / Float32(Float32(1.0) - u0)), Float32(1.0))))
end
\begin{array}{l}
t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\
\frac{1}{\sqrt{\mathsf{fma}\left(\frac{alphay \cdot alphay}{{\left(\frac{alphay}{\cosh t\_0 \cdot alphax}\right)}^{2} + {\tanh t\_0}^{2}}, \frac{u0}{1 - u0}, 1\right)}}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\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. Applied rewrites99.4%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\frac{alphay \cdot alphay}{{\left(alphay \cdot \frac{1}{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right) \cdot alphax}\right)}^{2} + {\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}}} \cdot u0}{1 - u0}}} \]
  3. Applied rewrites99.4%

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{alphay \cdot alphay}{{\left(\frac{alphay}{\cosh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right) \cdot alphax}\right)}^{2} + {\tanh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}}, \frac{u0}{1 - u0}, 1\right)}}} \]
  4. Add Preprocessing

Alternative 4: 99.3% accurate, 2.1× speedup?

\[\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)\]
\[\begin{array}{l} t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\ \frac{1}{\sqrt{\frac{u0}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh t\_0}{alphay}\right)}^{2} + \frac{{\cosh t\_0}^{-2}}{alphax \cdot alphax}\right)} - -1}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (let* ((t_0
        (asinh (* (tan (* PI (fma u1 2.0 0.5))) (/ alphay alphax)))))
  (/
   1.0
   (sqrt
    (-
     (/
      u0
      (*
       (- 1.0 u0)
       (+
        (pow (/ (tanh t_0) alphay) 2.0)
        (/ (pow (cosh t_0) -2.0) (* alphax alphax)))))
     -1.0)))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = asinhf((tanf((((float) M_PI) * fmaf(u1, 2.0f, 0.5f))) * (alphay / alphax)));
	return 1.0f / sqrtf(((u0 / ((1.0f - u0) * (powf((tanhf(t_0) / alphay), 2.0f) + (powf(coshf(t_0), -2.0f) / (alphax * alphax))))) - -1.0f));
}
function code(u0, u1, alphax, alphay)
	t_0 = asinh(Float32(tan(Float32(Float32(pi) * fma(u1, Float32(2.0), Float32(0.5)))) * Float32(alphay / alphax)))
	return Float32(Float32(1.0) / sqrt(Float32(Float32(u0 / Float32(Float32(Float32(1.0) - u0) * Float32((Float32(tanh(t_0) / alphay) ^ Float32(2.0)) + Float32((cosh(t_0) ^ Float32(-2.0)) / Float32(alphax * alphax))))) - Float32(-1.0))))
end
\begin{array}{l}
t_0 := \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)\\
\frac{1}{\sqrt{\frac{u0}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh t\_0}{alphay}\right)}^{2} + \frac{{\cosh t\_0}^{-2}}{alphax \cdot alphax}\right)} - -1}}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\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. Applied rewrites99.4%

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\frac{u0}{\left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right) \cdot \left(1 - u0\right)} - -1}}} \]
  3. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{\frac{u0}{\color{blue}{\left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right) \cdot \left(1 - u0\right)}} - -1}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{1}{\sqrt{\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1}} \]
    3. lower-*.f3299.4%

      \[\leadsto \frac{1}{\sqrt{\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1}} \]
  4. Applied rewrites99.4%

    \[\leadsto \frac{1}{\sqrt{\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1}} \]
  5. Add Preprocessing

Alternative 5: 97.7% accurate, 2.2× speedup?

\[\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)\]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\\ \frac{1}{\sqrt{1 + \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin t\_0}{alphax \cdot \cos t\_0}\right)}^{2} \cdot \left(1 - u0\right)}}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (let* ((t_0 (fma 0.5 PI (* 2.0 (* u1 PI)))))
  (/
   1.0
   (sqrt
    (+
     1.0
     (/
      (* (pow alphay 2.0) u0)
      (*
       (pow
        (sin (atan (/ (* alphay (sin t_0)) (* alphax (cos t_0)))))
        2.0)
       (- 1.0 u0))))))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = fmaf(0.5f, ((float) M_PI), (2.0f * (u1 * ((float) M_PI))));
	return 1.0f / sqrtf((1.0f + ((powf(alphay, 2.0f) * u0) / (powf(sinf(atanf(((alphay * sinf(t_0)) / (alphax * cosf(t_0))))), 2.0f) * (1.0f - u0)))));
}
function code(u0, u1, alphax, alphay)
	t_0 = fma(Float32(0.5), Float32(pi), Float32(Float32(2.0) * Float32(u1 * Float32(pi))))
	return Float32(Float32(1.0) / sqrt(Float32(Float32(1.0) + Float32(Float32((alphay ^ Float32(2.0)) * u0) / Float32((sin(atan(Float32(Float32(alphay * sin(t_0)) / Float32(alphax * cos(t_0))))) ^ Float32(2.0)) * Float32(Float32(1.0) - u0))))))
end
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\\
\frac{1}{\sqrt{1 + \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin t\_0}{alphax \cdot \cos t\_0}\right)}^{2} \cdot \left(1 - u0\right)}}}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\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. Taylor expanded in alphax around inf

    \[\leadsto \frac{1}{\sqrt{1 + \color{blue}{\frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}}}} \]
  3. Step-by-step derivation
    1. lower-/.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{{alphay}^{2} \cdot u0}{\color{blue}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}}}} \]
  4. Applied rewrites97.7%

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

Alternative 6: 96.4% accurate, 4.1× speedup?

\[\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)\]
\[\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(u1, 2, 0.5\right) \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{2} \cdot \left(1 - u0\right)} \cdot -0.5, 1\right) \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (fma
 (* alphay alphay)
 (*
  (/
   u0
   (*
    (pow
     (tanh
      (asinh (* (tan (* (fma u1 2.0 0.5) PI)) (/ alphay alphax))))
     2.0)
    (- 1.0 u0)))
  -0.5)
 1.0))
float code(float u0, float u1, float alphax, float alphay) {
	return fmaf((alphay * alphay), ((u0 / (powf(tanhf(asinhf((tanf((fmaf(u1, 2.0f, 0.5f) * ((float) M_PI))) * (alphay / alphax)))), 2.0f) * (1.0f - u0))) * -0.5f), 1.0f);
}
function code(u0, u1, alphax, alphay)
	return fma(Float32(alphay * alphay), Float32(Float32(u0 / Float32((tanh(asinh(Float32(tan(Float32(fma(u1, Float32(2.0), Float32(0.5)) * Float32(pi))) * Float32(alphay / alphax)))) ^ Float32(2.0)) * Float32(Float32(1.0) - u0))) * Float32(-0.5)), Float32(1.0))
end
\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(u1, 2, 0.5\right) \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{2} \cdot \left(1 - u0\right)} \cdot -0.5, 1\right)
Derivation
  1. Initial program 99.3%

    \[\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. Taylor expanded in alphay around 0

    \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  3. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto 1 + \color{blue}{\frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  4. Applied rewrites96.4%

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

    \[\leadsto \mathsf{fma}\left(alphay \cdot alphay, \color{blue}{\frac{u0}{{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(u1, 2, 0.5\right) \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{2} \cdot \left(1 - u0\right)} \cdot -0.5}, 1\right) \]
  6. Add Preprocessing

Alternative 7: 96.4% accurate, 4.3× speedup?

\[\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)\]
\[\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{{\tanh \sinh^{-1} \left(\tan \left(0.5 \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{2} \cdot \left(1 - u0\right)} \cdot -0.5, 1\right) \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (fma
 (* alphay alphay)
 (*
  (/
   u0
   (*
    (pow (tanh (asinh (* (tan (* 0.5 PI)) (/ alphay alphax)))) 2.0)
    (- 1.0 u0)))
  -0.5)
 1.0))
float code(float u0, float u1, float alphax, float alphay) {
	return fmaf((alphay * alphay), ((u0 / (powf(tanhf(asinhf((tanf((0.5f * ((float) M_PI))) * (alphay / alphax)))), 2.0f) * (1.0f - u0))) * -0.5f), 1.0f);
}
function code(u0, u1, alphax, alphay)
	return fma(Float32(alphay * alphay), Float32(Float32(u0 / Float32((tanh(asinh(Float32(tan(Float32(Float32(0.5) * Float32(pi))) * Float32(alphay / alphax)))) ^ Float32(2.0)) * Float32(Float32(1.0) - u0))) * Float32(-0.5)), Float32(1.0))
end
\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{{\tanh \sinh^{-1} \left(\tan \left(0.5 \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{2} \cdot \left(1 - u0\right)} \cdot -0.5, 1\right)
Derivation
  1. Initial program 99.3%

    \[\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. Taylor expanded in alphay around 0

    \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  3. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto 1 + \color{blue}{\frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  4. Applied rewrites96.4%

    \[\leadsto \color{blue}{1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\right)}{alphax \cdot \cos \left(\mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  5. Taylor expanded in u1 around 0

    \[\leadsto 1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi\right)}{alphax \cdot \cos \left(\mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
  6. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto 1 + \frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)}{alphax \cdot \cos \left(\mathsf{fma}\left(\frac{1}{2}, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
    2. lower-PI.f3297.0%

      \[\leadsto 1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(0.5 \cdot \pi\right)}{alphax \cdot \cos \left(\mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
  7. Applied rewrites97.0%

    \[\leadsto 1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(0.5 \cdot \pi\right)}{alphax \cdot \cos \left(\mathsf{fma}\left(0.5, \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
  8. Taylor expanded in u1 around 0

    \[\leadsto 1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(0.5 \cdot \pi\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
  9. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto 1 + \frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
    2. lower-PI.f3296.4%

      \[\leadsto 1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(0.5 \cdot \pi\right)}{alphax \cdot \cos \left(0.5 \cdot \pi\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
  10. Applied rewrites96.4%

    \[\leadsto 1 + -0.5 \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(0.5 \cdot \pi\right)}{alphax \cdot \cos \left(0.5 \cdot \pi\right)}\right)}^{2} \cdot \left(1 - u0\right)} \]
  11. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto 1 + \color{blue}{\frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
    2. +-commutativeN/A

      \[\leadsto \frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi\right)}\right)}^{2} \cdot \left(1 - u0\right)} + \color{blue}{1} \]
  12. Applied rewrites96.4%

    \[\leadsto \mathsf{fma}\left(alphay \cdot alphay, \color{blue}{\frac{u0}{{\tanh \sinh^{-1} \left(\tan \left(0.5 \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{2} \cdot \left(1 - u0\right)} \cdot -0.5}, 1\right) \]
  13. Add Preprocessing

Alternative 8: 91.3% accurate, 14.7× speedup?

\[\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)\]
\[{\left(\left(1 - u0\right) \cdot \frac{-1}{u0 - 1}\right)}^{-0.5} \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (pow (* (- 1.0 u0) (/ -1.0 (- u0 1.0))) -0.5))
float code(float u0, float u1, float alphax, float alphay) {
	return powf(((1.0f - u0) * (-1.0f / (u0 - 1.0f))), -0.5f);
}
real(4) function code(u0, u1, alphax, alphay)
use fmin_fmax_functions
    real(4), intent (in) :: u0
    real(4), intent (in) :: u1
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    code = ((1.0e0 - u0) * ((-1.0e0) / (u0 - 1.0e0))) ** (-0.5e0)
end function
function code(u0, u1, alphax, alphay)
	return Float32(Float32(Float32(1.0) - u0) * Float32(Float32(-1.0) / Float32(u0 - Float32(1.0)))) ^ Float32(-0.5)
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = ((single(1.0) - u0) * (single(-1.0) / (u0 - single(1.0)))) ^ single(-0.5);
end
{\left(\left(1 - u0\right) \cdot \frac{-1}{u0 - 1}\right)}^{-0.5}
Derivation
  1. Initial program 99.3%

    \[\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. Applied rewrites99.9%

    \[\leadsto \color{blue}{{\left(\frac{u0}{\left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right) \cdot \left(1 - u0\right)} - -1\right)}^{-0.5}} \]
  3. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto {\left(\frac{u0}{\color{blue}{\left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right) \cdot \left(1 - u0\right)}} - -1\right)}^{\frac{-1}{2}} \]
    2. *-commutativeN/A

      \[\leadsto {\left(\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(\frac{1}{2}, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1\right)}^{\frac{-1}{2}} \]
    3. lower-*.f3299.9%

      \[\leadsto {\left(\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(0.5, \pi, u1 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1\right)}^{-0.5} \]
  4. Applied rewrites99.9%

    \[\leadsto {\left(\frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left({\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}\right)}} - -1\right)}^{-0.5} \]
  5. Applied rewrites99.6%

    \[\leadsto {\color{blue}{\left(\left(\frac{u0}{{\left(\frac{\tanh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(u1, 2, 0.5\right) \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}{alphay}\right)}^{2} + \frac{{\cosh \sinh^{-1} \left(\tan \left(\mathsf{fma}\left(u1, 2, 0.5\right) \cdot \pi\right) \cdot \frac{alphay}{alphax}\right)}^{-2}}{alphax \cdot alphax}} + \left(1 - u0\right)\right) \cdot \frac{-1}{u0 - 1}\right)}}^{-0.5} \]
  6. Taylor expanded in alphax around 0

    \[\leadsto {\left(\color{blue}{\left(1 - u0\right)} \cdot \frac{-1}{u0 - 1}\right)}^{-0.5} \]
  7. Step-by-step derivation
    1. lower--.f3291.3%

      \[\leadsto {\left(\left(1 - \color{blue}{u0}\right) \cdot \frac{-1}{u0 - 1}\right)}^{-0.5} \]
  8. Applied rewrites91.3%

    \[\leadsto {\left(\color{blue}{\left(1 - u0\right)} \cdot \frac{-1}{u0 - 1}\right)}^{-0.5} \]
  9. Add Preprocessing

Alternative 9: 88.1% accurate, 27.9× speedup?

\[\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)\]
\[\mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1} \cdot -0.5, 1\right) \]
(FPCore (u0 u1 alphax alphay)
  :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)))
  (fma (* alphax alphax) (* (/ u0 1.0) -0.5) 1.0))
float code(float u0, float u1, float alphax, float alphay) {
	return fmaf((alphax * alphax), ((u0 / 1.0f) * -0.5f), 1.0f);
}
function code(u0, u1, alphax, alphay)
	return fma(Float32(alphax * alphax), Float32(Float32(u0 / Float32(1.0)) * Float32(-0.5)), Float32(1.0))
end
\mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1} \cdot -0.5, 1\right)
Derivation
  1. Initial program 99.3%

    \[\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. Taylor expanded in alphax around 0

    \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot \frac{{alphax}^{2} \cdot u0}{{\cos \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \pi + 2 \cdot \left(u1 \cdot \pi\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  3. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto 1 + \color{blue}{\frac{-1}{2} \cdot \frac{{alphax}^{2} \cdot u0}{{\cos \tan^{-1} \left(\frac{alphay \cdot \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax \cdot \cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  4. Applied rewrites41.1%

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

    \[\leadsto \mathsf{fma}\left(alphax \cdot alphax, \color{blue}{\frac{u0}{\left(1 - {\tanh \sinh^{-1} \left(\tan \left(\pi \cdot \mathsf{fma}\left(u1, 2, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\right) \cdot \left(1 - u0\right)} \cdot -0.5}, 1\right) \]
  6. Taylor expanded in alphax around inf

    \[\leadsto \mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1 - u0} \cdot -0.5, 1\right) \]
  7. Step-by-step derivation
    1. lower--.f3287.9%

      \[\leadsto \mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1 - u0} \cdot -0.5, 1\right) \]
  8. Applied rewrites87.9%

    \[\leadsto \mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1 - u0} \cdot -0.5, 1\right) \]
  9. Taylor expanded in u0 around 0

    \[\leadsto \mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1} \cdot -0.5, 1\right) \]
  10. Step-by-step derivation
    1. Applied rewrites88.1%

      \[\leadsto \mathsf{fma}\left(alphax \cdot alphax, \frac{u0}{1} \cdot -0.5, 1\right) \]
    2. Add Preprocessing

    Reproduce

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