Trowbridge-Reitz Sample, sample surface normal, cosTheta

Percentage Accurate: 99.4% → 99.9%
Time: 23.4s
Alternatives: 8
Speedup: 2.2×

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} \\ \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} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (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}

\\
\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}
\end{array}

Sampling outcomes in binary32 precision:

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 8 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.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (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}

\\
\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}
\end{array}

Alternative 1: 99.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\\
\sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{\frac{1}{1 + {\left(t\_0 \cdot \frac{alphay}{alphax}\right)}^{2}}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{t\_0 \cdot alphay}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\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. Add Preprocessing
  3. Taylor expanded in u1 around 0

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

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphax}^{2}} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphay}^{2}}\right)}}}} \]
    4. lower--.f32N/A

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

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

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

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

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \left(2 \cdot u1 + \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    2. lift-fma.f32N/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{fma}\left(2, u1, \frac{1}{2}\right)}\right)}{alphax}\right)}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    3. lift-*.f32N/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}}{alphax}\right)}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    4. lift-tan.f32N/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}}{alphax}\right)}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    5. lift-*.f32N/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\cos \tan^{-1} \left(\frac{\color{blue}{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}}{alphax}\right)}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    6. lift-/.f32N/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\cos \tan^{-1} \color{blue}{\left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    7. cos-atanN/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\color{blue}{\left(\frac{1}{\sqrt{1 + \frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax} \cdot \frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}}}\right)}}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    8. inv-powN/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{{\color{blue}{\left({\left(\sqrt{1 + \frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax} \cdot \frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}}\right)}^{-1}\right)}}^{2}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
    9. pow-powN/A

      \[\leadsto \sqrt{\frac{1}{1 + \frac{u0}{\left(\frac{\color{blue}{{\left(\sqrt{1 + \frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax} \cdot \frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}}\right)}^{\left(-1 \cdot 2\right)}}}{alphax \cdot alphax} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(2, u1, \frac{1}{2}\right)\right)}{alphax}\right)}^{2}}{alphay \cdot alphay}\right) \cdot \left(1 - u0\right)}}} \]
  9. Applied rewrites99.9%

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

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

Alternative 2: 99.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\\ e^{\mathsf{log1p}\left(\frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - t\_0}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + t\_0\right)\right)}\right)}\right) \cdot -0.5} \end{array} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (let* ((t_0 (pow (* (tan (* PI (fma 2.0 u1 0.5))) (/ alphay alphax)) 2.0)))
   (exp
    (*
     (log1p
      (/
       u0
       (*
        (- 1.0 u0)
        (+
         (/ (+ 1.0 (/ 1.0 (- -1.0 t_0))) (* alphay alphay))
         (/ 1.0 (* alphax (* alphax (+ 1.0 t_0))))))))
     -0.5))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = powf((tanf((((float) M_PI) * fmaf(2.0f, u1, 0.5f))) * (alphay / alphax)), 2.0f);
	return expf((log1pf((u0 / ((1.0f - u0) * (((1.0f + (1.0f / (-1.0f - t_0))) / (alphay * alphay)) + (1.0f / (alphax * (alphax * (1.0f + t_0)))))))) * -0.5f));
}
function code(u0, u1, alphax, alphay)
	t_0 = Float32(tan(Float32(Float32(pi) * fma(Float32(2.0), u1, Float32(0.5)))) * Float32(alphay / alphax)) ^ Float32(2.0)
	return exp(Float32(log1p(Float32(u0 / Float32(Float32(Float32(1.0) - u0) * Float32(Float32(Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(-1.0) - t_0))) / Float32(alphay * alphay)) + Float32(Float32(1.0) / Float32(alphax * Float32(alphax * Float32(Float32(1.0) + t_0)))))))) * Float32(-0.5)))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\\
e^{\mathsf{log1p}\left(\frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - t\_0}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + t\_0\right)\right)}\right)}\right) \cdot -0.5}
\end{array}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\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. Add Preprocessing
  3. Taylor expanded in u1 around 0

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

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphax}^{2}} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphay}^{2}}\right)}}}} \]
    4. lower--.f32N/A

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

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 - \frac{1}{1 + {\left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}^{2}}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + {\left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right)\right)}^{2}\right)\right)}\right)}\right) \cdot -0.5}} \]
  7. Final simplification99.7%

    \[\leadsto e^{\mathsf{log1p}\left(\frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\right)\right)}\right)}\right) \cdot -0.5} \]
  8. Add Preprocessing

Alternative 3: 99.8% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\\ {\left(1 + \frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - t\_0}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + t\_0\right)\right)}\right)}\right)}^{-0.5} \end{array} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (let* ((t_0 (pow (* (tan (* PI (fma 2.0 u1 0.5))) (/ alphay alphax)) 2.0)))
   (pow
    (+
     1.0
     (/
      u0
      (*
       (- 1.0 u0)
       (+
        (/ (+ 1.0 (/ 1.0 (- -1.0 t_0))) (* alphay alphay))
        (/ 1.0 (* alphax (* alphax (+ 1.0 t_0))))))))
    -0.5)))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = powf((tanf((((float) M_PI) * fmaf(2.0f, u1, 0.5f))) * (alphay / alphax)), 2.0f);
	return powf((1.0f + (u0 / ((1.0f - u0) * (((1.0f + (1.0f / (-1.0f - t_0))) / (alphay * alphay)) + (1.0f / (alphax * (alphax * (1.0f + t_0)))))))), -0.5f);
}
function code(u0, u1, alphax, alphay)
	t_0 = Float32(tan(Float32(Float32(pi) * fma(Float32(2.0), u1, Float32(0.5)))) * Float32(alphay / alphax)) ^ Float32(2.0)
	return Float32(Float32(1.0) + Float32(u0 / Float32(Float32(Float32(1.0) - u0) * Float32(Float32(Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(-1.0) - t_0))) / Float32(alphay * alphay)) + Float32(Float32(1.0) / Float32(alphax * Float32(alphax * Float32(Float32(1.0) + t_0)))))))) ^ Float32(-0.5)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\\
{\left(1 + \frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - t\_0}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + t\_0\right)\right)}\right)}\right)}^{-0.5}
\end{array}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\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. Add Preprocessing
  3. Taylor expanded in u1 around 0

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

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphax}^{2}} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphay}^{2}}\right)}}}} \]
    4. lower--.f32N/A

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

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

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

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

Alternative 4: 99.3% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\\ \frac{1}{\sqrt{1 + \frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - t\_0}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + t\_0\right)\right)}\right)}}} \end{array} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (let* ((t_0 (pow (* (tan (* PI (fma 2.0 u1 0.5))) (/ alphay alphax)) 2.0)))
   (/
    1.0
    (sqrt
     (+
      1.0
      (/
       u0
       (*
        (- 1.0 u0)
        (+
         (/ (+ 1.0 (/ 1.0 (- -1.0 t_0))) (* alphay alphay))
         (/ 1.0 (* alphax (* alphax (+ 1.0 t_0))))))))))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = powf((tanf((((float) M_PI) * fmaf(2.0f, u1, 0.5f))) * (alphay / alphax)), 2.0f);
	return 1.0f / sqrtf((1.0f + (u0 / ((1.0f - u0) * (((1.0f + (1.0f / (-1.0f - t_0))) / (alphay * alphay)) + (1.0f / (alphax * (alphax * (1.0f + t_0)))))))));
}
function code(u0, u1, alphax, alphay)
	t_0 = Float32(tan(Float32(Float32(pi) * fma(Float32(2.0), u1, Float32(0.5)))) * Float32(alphay / alphax)) ^ Float32(2.0)
	return Float32(Float32(1.0) / sqrt(Float32(Float32(1.0) + Float32(u0 / Float32(Float32(Float32(1.0) - u0) * Float32(Float32(Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(-1.0) - t_0))) / Float32(alphay * alphay)) + Float32(Float32(1.0) / Float32(alphax * Float32(alphax * Float32(Float32(1.0) + t_0))))))))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\tan \left(\pi \cdot \mathsf{fma}\left(2, u1, 0.5\right)\right) \cdot \frac{alphay}{alphax}\right)}^{2}\\
\frac{1}{\sqrt{1 + \frac{u0}{\left(1 - u0\right) \cdot \left(\frac{1 + \frac{1}{-1 - t\_0}}{alphay \cdot alphay} + \frac{1}{alphax \cdot \left(alphax \cdot \left(1 + t\_0\right)\right)}\right)}}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\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. Add Preprocessing
  3. Taylor expanded in u1 around 0

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

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphax}^{2}} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphay}^{2}}\right)}}}} \]
    4. lower--.f32N/A

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

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

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

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

Alternative 5: 98.2% accurate, 30.6× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{1 - u0}, 1\right)}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (sqrt (/ 1.0 (fma (* alphay alphay) (/ u0 (- 1.0 u0)) 1.0))))
float code(float u0, float u1, float alphax, float alphay) {
	return sqrtf((1.0f / fmaf((alphay * alphay), (u0 / (1.0f - u0)), 1.0f)));
}
function code(u0, u1, alphax, alphay)
	return sqrt(Float32(Float32(1.0) / fma(Float32(alphay * alphay), Float32(u0 / Float32(Float32(1.0) - u0)), Float32(1.0))))
end
\begin{array}{l}

\\
\sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{1 - u0}, 1\right)}}
\end{array}
Derivation
  1. Initial program 99.4%

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \color{blue}{\frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}}} \]
    2. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{{alphay}^{2} \cdot u0}}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    3. unpow2N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    4. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    5. lower-*.f32N/A

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
  8. Step-by-step derivation
    1. lower-sqrt.f32N/A

      \[\leadsto \color{blue}{\sqrt{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
    2. lower-/.f32N/A

      \[\leadsto \sqrt{\color{blue}{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
    3. +-commutativeN/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{\frac{{alphay}^{2} \cdot u0}{1 - u0} + 1}}} \]
    4. associate-/l*N/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{{alphay}^{2} \cdot \frac{u0}{1 - u0}} + 1}} \]
    5. lower-fma.f32N/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left({alphay}^{2}, \frac{u0}{1 - u0}, 1\right)}}} \]
    6. unpow2N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(\color{blue}{alphay \cdot alphay}, \frac{u0}{1 - u0}, 1\right)}} \]
    7. lower-*.f32N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(\color{blue}{alphay \cdot alphay}, \frac{u0}{1 - u0}, 1\right)}} \]
    8. lower-/.f32N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \color{blue}{\frac{u0}{1 - u0}}, 1\right)}} \]
    9. lower--.f3297.6

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{\color{blue}{1 - u0}}, 1\right)}} \]
  9. Applied rewrites97.6%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{1 - u0}, 1\right)}}} \]
  10. Add Preprocessing

Alternative 6: 96.6% accurate, 46.3× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(-0.5, \frac{u0 \cdot \left(alphay \cdot alphay\right)}{1 - u0}, 1\right) \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (fma -0.5 (/ (* u0 (* alphay alphay)) (- 1.0 u0)) 1.0))
float code(float u0, float u1, float alphax, float alphay) {
	return fmaf(-0.5f, ((u0 * (alphay * alphay)) / (1.0f - u0)), 1.0f);
}
function code(u0, u1, alphax, alphay)
	return fma(Float32(-0.5), Float32(Float32(u0 * Float32(alphay * alphay)) / Float32(Float32(1.0) - u0)), Float32(1.0))
end
\begin{array}{l}

\\
\mathsf{fma}\left(-0.5, \frac{u0 \cdot \left(alphay \cdot alphay\right)}{1 - u0}, 1\right)
\end{array}
Derivation
  1. Initial program 99.4%

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \color{blue}{\frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}}} \]
    2. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{{alphay}^{2} \cdot u0}}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    3. unpow2N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    4. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    5. lower-*.f32N/A

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
  8. Step-by-step derivation
    1. lower-sqrt.f32N/A

      \[\leadsto \color{blue}{\sqrt{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
    2. lower-/.f32N/A

      \[\leadsto \sqrt{\color{blue}{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
    3. +-commutativeN/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{\frac{{alphay}^{2} \cdot u0}{1 - u0} + 1}}} \]
    4. associate-/l*N/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{{alphay}^{2} \cdot \frac{u0}{1 - u0}} + 1}} \]
    5. lower-fma.f32N/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left({alphay}^{2}, \frac{u0}{1 - u0}, 1\right)}}} \]
    6. unpow2N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(\color{blue}{alphay \cdot alphay}, \frac{u0}{1 - u0}, 1\right)}} \]
    7. lower-*.f32N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(\color{blue}{alphay \cdot alphay}, \frac{u0}{1 - u0}, 1\right)}} \]
    8. lower-/.f32N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \color{blue}{\frac{u0}{1 - u0}}, 1\right)}} \]
    9. lower--.f3297.6

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{\color{blue}{1 - u0}}, 1\right)}} \]
  9. Applied rewrites97.6%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{1 - u0}, 1\right)}}} \]
  10. Taylor expanded in alphay around 0

    \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{1 - u0}} \]
  11. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{1 - u0} + 1} \]
    2. lower-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{alphay}^{2} \cdot u0}{1 - u0}, 1\right)} \]
    3. lower-/.f32N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\frac{{alphay}^{2} \cdot u0}{1 - u0}}, 1\right) \]
    4. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \frac{\color{blue}{{alphay}^{2} \cdot u0}}{1 - u0}, 1\right) \]
    5. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{1 - u0}, 1\right) \]
    6. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{1 - u0}, 1\right) \]
    7. lower--.f3296.2

      \[\leadsto \mathsf{fma}\left(-0.5, \frac{\left(alphay \cdot alphay\right) \cdot u0}{\color{blue}{1 - u0}}, 1\right) \]
  12. Applied rewrites96.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \frac{\left(alphay \cdot alphay\right) \cdot u0}{1 - u0}, 1\right)} \]
  13. Final simplification96.2%

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

Alternative 7: 95.1% accurate, 84.5× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(-0.5, u0 \cdot \left(alphay \cdot alphay\right), 1\right) \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (fma -0.5 (* u0 (* alphay alphay)) 1.0))
float code(float u0, float u1, float alphax, float alphay) {
	return fmaf(-0.5f, (u0 * (alphay * alphay)), 1.0f);
}
function code(u0, u1, alphax, alphay)
	return fma(Float32(-0.5), Float32(u0 * Float32(alphay * alphay)), Float32(1.0))
end
\begin{array}{l}

\\
\mathsf{fma}\left(-0.5, u0 \cdot \left(alphay \cdot alphay\right), 1\right)
\end{array}
Derivation
  1. Initial program 99.4%

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \color{blue}{\frac{{alphay}^{2} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}}} \]
    2. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{{alphay}^{2} \cdot u0}}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    3. unpow2N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    4. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\color{blue}{\left(alphay \cdot alphay\right)} \cdot u0}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
    5. lower-*.f32N/A

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
  8. Step-by-step derivation
    1. lower-sqrt.f32N/A

      \[\leadsto \color{blue}{\sqrt{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
    2. lower-/.f32N/A

      \[\leadsto \sqrt{\color{blue}{\frac{1}{1 + \frac{{alphay}^{2} \cdot u0}{1 - u0}}}} \]
    3. +-commutativeN/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{\frac{{alphay}^{2} \cdot u0}{1 - u0} + 1}}} \]
    4. associate-/l*N/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{{alphay}^{2} \cdot \frac{u0}{1 - u0}} + 1}} \]
    5. lower-fma.f32N/A

      \[\leadsto \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left({alphay}^{2}, \frac{u0}{1 - u0}, 1\right)}}} \]
    6. unpow2N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(\color{blue}{alphay \cdot alphay}, \frac{u0}{1 - u0}, 1\right)}} \]
    7. lower-*.f32N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(\color{blue}{alphay \cdot alphay}, \frac{u0}{1 - u0}, 1\right)}} \]
    8. lower-/.f32N/A

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \color{blue}{\frac{u0}{1 - u0}}, 1\right)}} \]
    9. lower--.f3297.6

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{\color{blue}{1 - u0}}, 1\right)}} \]
  9. Applied rewrites97.6%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\mathsf{fma}\left(alphay \cdot alphay, \frac{u0}{1 - u0}, 1\right)}}} \]
  10. Taylor expanded in u0 around 0

    \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot \left({alphay}^{2} \cdot u0\right)} \]
  11. Step-by-step derivation
    1. associate-*r*N/A

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

      \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot {alphay}^{2}\right) \cdot u0 + 1} \]
    3. associate-*r*N/A

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \left({alphay}^{2} \cdot u0\right)} + 1 \]
    4. lower-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, {alphay}^{2} \cdot u0, 1\right)} \]
    5. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \color{blue}{{alphay}^{2} \cdot u0}, 1\right) \]
    6. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\left(alphay \cdot alphay\right)} \cdot u0, 1\right) \]
    7. lower-*.f3294.6

      \[\leadsto \mathsf{fma}\left(-0.5, \color{blue}{\left(alphay \cdot alphay\right)} \cdot u0, 1\right) \]
  12. Applied rewrites94.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \left(alphay \cdot alphay\right) \cdot u0, 1\right)} \]
  13. Final simplification94.6%

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

Alternative 8: 91.6% accurate, 1436.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (u0 u1 alphax alphay) :precision binary32 1.0)
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f;
}
real(4) function code(u0, u1, alphax, alphay)
    real(4), intent (in) :: u0
    real(4), intent (in) :: u1
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    code = 1.0e0
end function
function code(u0, u1, alphax, alphay)
	return Float32(1.0)
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0);
end
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 99.4%

    \[\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. Add Preprocessing
  3. Taylor expanded in u1 around 0

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

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{u0}{\color{blue}{\left(1 - u0\right) \cdot \left(\frac{{\cos \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphax}^{2}} + \frac{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) + 2 \cdot \left(u1 \cdot \mathsf{PI}\left(\right)\right)\right)}{alphax}\right)}^{2}}{{alphay}^{2}}\right)}}}} \]
    4. lower--.f32N/A

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

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

    \[\leadsto \color{blue}{1} \]
  7. Step-by-step derivation
    1. Applied rewrites91.7%

      \[\leadsto \color{blue}{1} \]
    2. Add Preprocessing

    Reproduce

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