Trowbridge-Reitz Sample, sample surface normal, cosTheta

Percentage Accurate: 99.4% → 100.0%
Time: 31.6s
Alternatives: 10
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} \\ \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 10 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: 100.0% accurate, 1.8× speedup?

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

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

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{u0}{1 - u0}}{\frac{\frac{1}{alphax \cdot alphax}}{1 + {\left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)}^{2}} + \frac{0.5 + \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right) \cdot -0.5}{alphay \cdot alphay}}\right) \cdot -0.5}} \]
  5. Applied egg-rr100.0%

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

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

Alternative 2: 99.9% accurate, 2.1× speedup?

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

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

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. Applied egg-rr100.0%

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

Alternative 3: 98.3% accurate, 2.6× speedup?

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

\\
e^{-0.5 \cdot \mathsf{log1p}\left(\frac{u0 \cdot \left(alphay \cdot alphay\right)}{\left(1 - u0\right) \cdot \left(0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right) \cdot alphay}{alphax}\right)\right)\right)}\right)}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. Applied egg-rr100.0%

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

    \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\color{blue}{\left(\frac{{alphay}^{2} \cdot u0}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)}\right)}\right), \frac{-1}{2}\right)\right) \]
  6. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\left({alphay}^{2} \cdot u0\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\left(u0 \cdot {alphay}^{2}\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \left({alphay}^{2}\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \left(alphay \cdot alphay\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \left(\left(1 - u0\right) \cdot \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\left(1 - u0\right), \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    8. --lowering--.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    9. +-lowering-+.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    11. cos-lowering-cos.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{cos.f32}\left(\left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
  7. Simplified98.3%

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

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

Alternative 4: 98.2% accurate, 3.2× speedup?

\[\begin{array}{l} \\ {\left(1 + \frac{u0}{\left(1 - u0\right) \cdot \left(\frac{-0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right) \cdot alphay}{alphax}\right)\right)}{alphay \cdot alphay} + \frac{0.5}{alphay \cdot alphay}\right)}\right)}^{-0.5} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (pow
  (+
   1.0
   (/
    u0
    (*
     (- 1.0 u0)
     (+
      (/
       (*
        -0.5
        (cos
         (* 2.0 (atan (/ (* (tan (* PI (+ 0.5 (* 2.0 u1)))) alphay) alphax)))))
       (* alphay alphay))
      (/ 0.5 (* alphay alphay))))))
  -0.5))
float code(float u0, float u1, float alphax, float alphay) {
	return powf((1.0f + (u0 / ((1.0f - u0) * (((-0.5f * cosf((2.0f * atanf(((tanf((((float) M_PI) * (0.5f + (2.0f * u1)))) * alphay) / alphax))))) / (alphay * alphay)) + (0.5f / (alphay * alphay)))))), -0.5f);
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) + Float32(u0 / Float32(Float32(Float32(1.0) - u0) * Float32(Float32(Float32(Float32(-0.5) * cos(Float32(Float32(2.0) * atan(Float32(Float32(tan(Float32(Float32(pi) * Float32(Float32(0.5) + Float32(Float32(2.0) * u1)))) * alphay) / alphax))))) / Float32(alphay * alphay)) + Float32(Float32(0.5) / Float32(alphay * alphay)))))) ^ Float32(-0.5)
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = (single(1.0) + (u0 / ((single(1.0) - u0) * (((single(-0.5) * cos((single(2.0) * atan(((tan((single(pi) * (single(0.5) + (single(2.0) * u1)))) * alphay) / alphax))))) / (alphay * alphay)) + (single(0.5) / (alphay * alphay)))))) ^ single(-0.5);
end
\begin{array}{l}

\\
{\left(1 + \frac{u0}{\left(1 - u0\right) \cdot \left(\frac{-0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right) \cdot alphay}{alphax}\right)\right)}{alphay \cdot alphay} + \frac{0.5}{alphay \cdot alphay}\right)}\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. Applied egg-rr100.0%

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

    \[\leadsto \mathsf{pow.f32}\left(\color{blue}{\left(1 + \frac{u0}{\left(\frac{-1}{2} \cdot \frac{\cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)}{{alphay}^{2}} + \frac{1}{2} \cdot \frac{1}{{alphay}^{2}}\right) \cdot \left(1 - u0\right)}\right)}, \frac{-1}{2}\right) \]
  6. Simplified98.2%

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

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

Alternative 5: 98.2% accurate, 3.2× speedup?

\[\begin{array}{l} \\ {\left(1 + \frac{\frac{alphay \cdot alphay}{\frac{1 - u0}{u0}}}{0.5 + \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right) \cdot -0.5}\right)}^{-0.5} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (pow
  (+
   1.0
   (/
    (/ (* alphay alphay) (/ (- 1.0 u0) u0))
    (+
     0.5
     (*
      (cos
       (* 2.0 (atan (/ (tan (* PI (+ 0.5 (* 2.0 u1)))) (/ alphax alphay)))))
      -0.5))))
  -0.5))
float code(float u0, float u1, float alphax, float alphay) {
	return powf((1.0f + (((alphay * alphay) / ((1.0f - u0) / u0)) / (0.5f + (cosf((2.0f * atanf((tanf((((float) M_PI) * (0.5f + (2.0f * u1)))) / (alphax / alphay))))) * -0.5f)))), -0.5f);
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) + Float32(Float32(Float32(alphay * alphay) / Float32(Float32(Float32(1.0) - u0) / u0)) / Float32(Float32(0.5) + Float32(cos(Float32(Float32(2.0) * atan(Float32(tan(Float32(Float32(pi) * Float32(Float32(0.5) + Float32(Float32(2.0) * u1)))) / Float32(alphax / alphay))))) * Float32(-0.5))))) ^ Float32(-0.5)
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = (single(1.0) + (((alphay * alphay) / ((single(1.0) - u0) / u0)) / (single(0.5) + (cos((single(2.0) * atan((tan((single(pi) * (single(0.5) + (single(2.0) * u1)))) / (alphax / alphay))))) * single(-0.5))))) ^ single(-0.5);
end
\begin{array}{l}

\\
{\left(1 + \frac{\frac{alphay \cdot alphay}{\frac{1 - u0}{u0}}}{0.5 + \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right) \cdot -0.5}\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. Applied egg-rr100.0%

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

    \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\color{blue}{\left(\frac{{alphay}^{2} \cdot u0}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)}\right)}\right), \frac{-1}{2}\right)\right) \]
  6. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\left({alphay}^{2} \cdot u0\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\left(u0 \cdot {alphay}^{2}\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \left({alphay}^{2}\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \left(alphay \cdot alphay\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \left(\left(1 - u0\right) \cdot \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\left(1 - u0\right), \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    8. --lowering--.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    9. +-lowering-+.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    11. cos-lowering-cos.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{cos.f32}\left(\left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
  7. Simplified98.3%

    \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{u0 \cdot \left(alphay \cdot alphay\right)}{\left(1 - u0\right) \cdot \left(0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)}}\right) \cdot -0.5} \]
  8. Step-by-step derivation
    1. exp-prodN/A

      \[\leadsto {\left(e^{\log \left(1 + \frac{u0 \cdot \left(alphay \cdot alphay\right)}{\left(1 - u0\right) \cdot \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)}\right)}\right)}^{\color{blue}{\frac{-1}{2}}} \]
    2. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{pow.f32}\left(\left(e^{\log \left(1 + \frac{u0 \cdot \left(alphay \cdot alphay\right)}{\left(1 - u0\right) \cdot \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)}\right)}\right), \color{blue}{\frac{-1}{2}}\right) \]
  9. Applied egg-rr98.2%

    \[\leadsto \color{blue}{{\left(1 + \frac{\frac{alphay \cdot alphay}{\frac{1 - u0}{u0}}}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right)}\right)}^{-0.5}} \]
  10. Final simplification98.2%

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

Alternative 6: 96.5% accurate, 4.1× speedup?

\[\begin{array}{l} \\ \frac{1}{1 + \frac{-0.5 \cdot \frac{alphay \cdot alphay}{\frac{-1}{u0} - -1}}{0.5 + \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right) \cdot -0.5}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (/
  1.0
  (+
   1.0
   (/
    (* -0.5 (/ (* alphay alphay) (- (/ -1.0 u0) -1.0)))
    (+
     0.5
     (*
      (cos
       (* 2.0 (atan (/ (tan (* PI (+ 0.5 (* 2.0 u1)))) (/ alphax alphay)))))
      -0.5))))))
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f / (1.0f + ((-0.5f * ((alphay * alphay) / ((-1.0f / u0) - -1.0f))) / (0.5f + (cosf((2.0f * atanf((tanf((((float) M_PI) * (0.5f + (2.0f * u1)))) / (alphax / alphay))))) * -0.5f))));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(Float32(-0.5) * Float32(Float32(alphay * alphay) / Float32(Float32(Float32(-1.0) / u0) - Float32(-1.0)))) / Float32(Float32(0.5) + Float32(cos(Float32(Float32(2.0) * atan(Float32(tan(Float32(Float32(pi) * Float32(Float32(0.5) + Float32(Float32(2.0) * u1)))) / Float32(alphax / alphay))))) * Float32(-0.5))))))
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0) / (single(1.0) + ((single(-0.5) * ((alphay * alphay) / ((single(-1.0) / u0) - single(-1.0)))) / (single(0.5) + (cos((single(2.0) * atan((tan((single(pi) * (single(0.5) + (single(2.0) * u1)))) / (alphax / alphay))))) * single(-0.5)))));
end
\begin{array}{l}

\\
\frac{1}{1 + \frac{-0.5 \cdot \frac{alphay \cdot alphay}{\frac{-1}{u0} - -1}}{0.5 + \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right) \cdot -0.5}}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

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

    \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(1 + \frac{1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\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} \cdot \left(1 - u0\right)}\right)}\right) \]
  5. Simplified97.3%

    \[\leadsto \frac{1}{\color{blue}{1 + \frac{0.5 \cdot \left(u0 \cdot \left(alphay \cdot alphay\right)\right)}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}}} \]
  6. Applied egg-rr97.3%

    \[\leadsto \frac{1}{\color{blue}{1 - \frac{-0.5 \cdot \frac{alphay \cdot alphay}{\frac{1}{u0} + -1}}{0.5 + \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{\frac{alphax}{alphay}}\right)\right) \cdot -0.5}}} \]
  7. Final simplification97.3%

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

Alternative 7: 96.5% accurate, 4.2× speedup?

\[\begin{array}{l} \\ \frac{1}{1 + -0.5 \cdot \frac{\frac{alphay}{\frac{\frac{-1}{u0} - -1}{alphay}}}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (/
  1.0
  (+
   1.0
   (*
    -0.5
    (/
     (/ alphay (/ (- (/ -1.0 u0) -1.0) alphay))
     (+
      0.5
      (*
       -0.5
       (cos (* 2.0 (atan (/ (tan (* PI 0.5)) (/ alphax alphay))))))))))))
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f / (1.0f + (-0.5f * ((alphay / (((-1.0f / u0) - -1.0f) / alphay)) / (0.5f + (-0.5f * cosf((2.0f * atanf((tanf((((float) M_PI) * 0.5f)) / (alphax / alphay))))))))));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(-0.5) * Float32(Float32(alphay / Float32(Float32(Float32(Float32(-1.0) / u0) - Float32(-1.0)) / alphay)) / Float32(Float32(0.5) + Float32(Float32(-0.5) * cos(Float32(Float32(2.0) * atan(Float32(tan(Float32(Float32(pi) * Float32(0.5))) / Float32(alphax / alphay)))))))))))
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0) / (single(1.0) + (single(-0.5) * ((alphay / (((single(-1.0) / u0) - single(-1.0)) / alphay)) / (single(0.5) + (single(-0.5) * cos((single(2.0) * atan((tan((single(pi) * single(0.5))) / (alphax / alphay))))))))));
end
\begin{array}{l}

\\
\frac{1}{1 + -0.5 \cdot \frac{\frac{alphay}{\frac{\frac{-1}{u0} - -1}{alphay}}}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)}}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

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

    \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(1 + \frac{1}{2} \cdot \frac{{alphay}^{2} \cdot u0}{{\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} \cdot \left(1 - u0\right)}\right)}\right) \]
  5. Simplified97.3%

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

    \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)}\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right)\right) \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right)\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\mathsf{*.f32}\left(\mathsf{PI}\left(\right), \frac{1}{2}\right)\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right)\right) \]
    3. PI-lowering-PI.f3297.3%

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right)\right) \]
  8. Simplified97.3%

    \[\leadsto \frac{1}{1 + \frac{0.5 \cdot \left(u0 \cdot \left(alphay \cdot alphay\right)\right)}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \color{blue}{\left(\pi \cdot 0.5\right)}}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  9. Applied egg-rr97.3%

    \[\leadsto \frac{1}{\color{blue}{1 - -0.5 \cdot \frac{\frac{alphay}{\frac{\frac{1}{u0} + -1}{alphay}}}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)}}} \]
  10. Final simplification97.3%

    \[\leadsto \frac{1}{1 + -0.5 \cdot \frac{\frac{alphay}{\frac{\frac{-1}{u0} - -1}{alphay}}}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)}} \]
  11. Add Preprocessing

Alternative 8: 96.5% accurate, 4.2× speedup?

\[\begin{array}{l} \\ 1 + \frac{\frac{-0.5}{\frac{1 - u0}{u0 \cdot \left(alphay \cdot alphay\right)}}}{0.5 - 0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (+
  1.0
  (/
   (/ -0.5 (/ (- 1.0 u0) (* u0 (* alphay alphay))))
   (-
    0.5
    (* 0.5 (cos (* 2.0 (atan (/ (tan (* PI 0.5)) (/ alphax alphay))))))))))
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f + ((-0.5f / ((1.0f - u0) / (u0 * (alphay * alphay)))) / (0.5f - (0.5f * cosf((2.0f * atanf((tanf((((float) M_PI) * 0.5f)) / (alphax / alphay))))))));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) + Float32(Float32(Float32(-0.5) / Float32(Float32(Float32(1.0) - u0) / Float32(u0 * Float32(alphay * alphay)))) / Float32(Float32(0.5) - Float32(Float32(0.5) * cos(Float32(Float32(2.0) * atan(Float32(tan(Float32(Float32(pi) * Float32(0.5))) / Float32(alphax / alphay)))))))))
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0) + ((single(-0.5) / ((single(1.0) - u0) / (u0 * (alphay * alphay)))) / (single(0.5) - (single(0.5) * cos((single(2.0) * atan((tan((single(pi) * single(0.5))) / (alphax / alphay))))))));
end
\begin{array}{l}

\\
1 + \frac{\frac{-0.5}{\frac{1 - u0}{u0 \cdot \left(alphay \cdot alphay\right)}}}{0.5 - 0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. 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 \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}} \]
  5. Simplified97.3%

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

    \[\leadsto \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)}\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right) \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\mathsf{*.f32}\left(\mathsf{PI}\left(\right), \frac{1}{2}\right)\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right) \]
    3. PI-lowering-PI.f3297.2%

      \[\leadsto \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right)\right), \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{sin.f32}\left(\mathsf{atan.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(alphay, \mathsf{tan.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right), alphax\right)\right)\right), 2\right), \mathsf{\_.f32}\left(1, u0\right)\right)\right)\right) \]
  8. Simplified97.2%

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

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

      \[\leadsto \mathsf{+.f32}\left(\left(\frac{\frac{-1}{2} \cdot \left(u0 \cdot \left(alphay \cdot alphay\right)\right)}{{\sin \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)}{alphax}\right)}^{2} \cdot \left(1 - u0\right)}\right), \color{blue}{1}\right) \]
  10. Applied egg-rr97.2%

    \[\leadsto \color{blue}{\frac{\frac{-0.5}{\frac{1 - u0}{u0 \cdot \left(alphay \cdot alphay\right)}}}{0.5 - 0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)} + 1} \]
  11. Final simplification97.2%

    \[\leadsto 1 + \frac{\frac{-0.5}{\frac{1 - u0}{u0 \cdot \left(alphay \cdot alphay\right)}}}{0.5 - 0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot 0.5\right)}{\frac{alphax}{alphay}}\right)\right)} \]
  12. Add Preprocessing

Alternative 9: 94.9% accurate, 4.2× speedup?

\[\begin{array}{l} \\ 1 + \frac{-0.5 \cdot \left(u0 \cdot \left(alphay \cdot alphay\right)\right)}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right) \cdot alphay}{alphax}\right)\right)} \end{array} \]
(FPCore (u0 u1 alphax alphay)
 :precision binary32
 (+
  1.0
  (/
   (* -0.5 (* u0 (* alphay alphay)))
   (+
    0.5
    (*
     -0.5
     (cos
      (*
       2.0
       (atan (/ (* (tan (* PI (+ 0.5 (* 2.0 u1)))) alphay) alphax)))))))))
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f + ((-0.5f * (u0 * (alphay * alphay))) / (0.5f + (-0.5f * cosf((2.0f * atanf(((tanf((((float) M_PI) * (0.5f + (2.0f * u1)))) * alphay) / alphax)))))));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) + Float32(Float32(Float32(-0.5) * Float32(u0 * Float32(alphay * alphay))) / Float32(Float32(0.5) + Float32(Float32(-0.5) * cos(Float32(Float32(2.0) * atan(Float32(Float32(tan(Float32(Float32(pi) * Float32(Float32(0.5) + Float32(Float32(2.0) * u1)))) * alphay) / alphax))))))))
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0) + ((single(-0.5) * (u0 * (alphay * alphay))) / (single(0.5) + (single(-0.5) * cos((single(2.0) * atan(((tan((single(pi) * (single(0.5) + (single(2.0) * u1)))) * alphay) / alphax)))))));
end
\begin{array}{l}

\\
1 + \frac{-0.5 \cdot \left(u0 \cdot \left(alphay \cdot alphay\right)\right)}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{\tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right) \cdot alphay}{alphax}\right)\right)}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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. Simplified99.5%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + \frac{\frac{u0}{1 - u0}}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphax \cdot alphax} + \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right) \cdot \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)\right)}{alphay \cdot alphay}}}}} \]
  3. Add Preprocessing
  4. Applied egg-rr100.0%

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

    \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\color{blue}{\left(\frac{{alphay}^{2} \cdot u0}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)}\right)}\right), \frac{-1}{2}\right)\right) \]
  6. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\left({alphay}^{2} \cdot u0\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\left(u0 \cdot {alphay}^{2}\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \left({alphay}^{2}\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \left(alphay \cdot alphay\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \left(\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right) \cdot \left(1 - u0\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \left(\left(1 - u0\right) \cdot \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\left(1 - u0\right), \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    8. --lowering--.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    9. +-lowering-+.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{-1}{2} \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    11. cos-lowering-cos.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{cos.f32}\left(\left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(u0, \mathsf{*.f32}\left(alphay, alphay\right)\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u0\right), \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(\frac{-1}{2}, \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \tan^{-1} \left(\frac{alphay \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} + 2 \cdot u1\right)\right)}{alphax}\right)\right)\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right)\right) \]
  7. Simplified98.3%

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

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

    \[\leadsto \color{blue}{1 + \frac{-0.5 \cdot \left(\left(alphay \cdot alphay\right) \cdot u0\right)}{0.5 + -0.5 \cdot \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \tan \left(\pi \cdot \left(0.5 + 2 \cdot u1\right)\right)}{alphax}\right)\right)}} \]
  10. Final simplification95.7%

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

Alternative 10: 91.3% accurate, 1375.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.5%

    \[\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. Simplified99.5%

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

    \[\leadsto \color{blue}{1} \]
  5. Step-by-step derivation
    1. Simplified92.9%

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

    Reproduce

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