Trowbridge-Reitz Sample, sample surface normal, cosTheta

Percentage Accurate: 99.4% → 99.7%
Time: 6.5s
Alternatives: 6
Speedup: 1.7×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

Alternative 1: 99.7% accurate, 1.7× speedup?

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

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

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

Alternative 2: 99.2% accurate, 1.9× speedup?

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

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

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

Alternative 3: 98.0% accurate, 2.1× speedup?

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

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

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

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

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

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

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

Alternative 4: 97.6% accurate, 2.4× speedup?

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

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

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

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

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

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

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

Alternative 5: 96.8% accurate, 2.4× speedup?

\[1 + -1 \cdot \frac{{alphay}^{2} \cdot u0}{\left(1 - u0\right) \cdot \left(1 - \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \sin \left(-\frac{-1}{2} \cdot \pi\right)}{alphax \cdot \cos \left(2 \cdot \left(u1 \cdot \pi\right) - \frac{-1}{2} \cdot \pi\right)}\right)\right)\right)} \]
(FPCore (u0 u1 alphax alphay)
  :precision binary32
  (+
 1
 (*
  -1
  (/
   (* (pow alphay 2) u0)
   (*
    (- 1 u0)
    (-
     1
     (cos
      (*
       2
       (atan
        (/
         (* alphay (sin (- (* -1/2 PI))))
         (* alphax (cos (- (* 2 (* u1 PI)) (* -1/2 PI))))))))))))))
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f + (-1.0f * ((powf(alphay, 2.0f) * u0) / ((1.0f - u0) * (1.0f - cosf((2.0f * atanf(((alphay * sinf(-(-0.5f * ((float) M_PI)))) / (alphax * cosf(((2.0f * (u1 * ((float) M_PI))) - (-0.5f * ((float) M_PI)))))))))))));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) + Float32(Float32(-1.0) * Float32(Float32((alphay ^ Float32(2.0)) * u0) / Float32(Float32(Float32(1.0) - u0) * Float32(Float32(1.0) - cos(Float32(Float32(2.0) * atan(Float32(Float32(alphay * sin(Float32(-Float32(Float32(-0.5) * Float32(pi))))) / Float32(alphax * cos(Float32(Float32(Float32(2.0) * Float32(u1 * Float32(pi))) - Float32(Float32(-0.5) * Float32(pi))))))))))))))
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0) + (single(-1.0) * (((alphay ^ single(2.0)) * u0) / ((single(1.0) - u0) * (single(1.0) - cos((single(2.0) * atan(((alphay * sin(-(single(-0.5) * single(pi)))) / (alphax * cos(((single(2.0) * (u1 * single(pi))) - (single(-0.5) * single(pi)))))))))))));
end
1 + -1 \cdot \frac{{alphay}^{2} \cdot u0}{\left(1 - u0\right) \cdot \left(1 - \cos \left(2 \cdot \tan^{-1} \left(\frac{alphay \cdot \sin \left(-\frac{-1}{2} \cdot \pi\right)}{alphax \cdot \cos \left(2 \cdot \left(u1 \cdot \pi\right) - \frac{-1}{2} \cdot \pi\right)}\right)\right)\right)}
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 + \frac{1}{2} \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \frac{1}{2} \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 + \frac{1}{2} \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \frac{1}{2} \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  2. Applied rewrites99.2%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 96.3% accurate, 4.0× speedup?

\[1 - \frac{u0 \cdot \left(alphay \cdot alphay\right)}{\left(1 - \cos \left(\tan^{-1} \left(\tan \left(\frac{1}{2} \cdot \pi\right) \cdot \frac{alphay}{alphax}\right) \cdot 2\right)\right) \cdot \left(1 - u0\right)} \]
(FPCore (u0 u1 alphax alphay)
  :precision binary32
  (-
 1
 (/
  (* u0 (* alphay alphay))
  (*
   (- 1 (cos (* (atan (* (tan (* 1/2 PI)) (/ alphay alphax))) 2)))
   (- 1 u0)))))
float code(float u0, float u1, float alphax, float alphay) {
	return 1.0f - ((u0 * (alphay * alphay)) / ((1.0f - cosf((atanf((tanf((0.5f * ((float) M_PI))) * (alphay / alphax))) * 2.0f))) * (1.0f - u0)));
}
function code(u0, u1, alphax, alphay)
	return Float32(Float32(1.0) - Float32(Float32(u0 * Float32(alphay * alphay)) / Float32(Float32(Float32(1.0) - cos(Float32(atan(Float32(tan(Float32(Float32(0.5) * Float32(pi))) * Float32(alphay / alphax))) * Float32(2.0)))) * Float32(Float32(1.0) - u0))))
end
function tmp = code(u0, u1, alphax, alphay)
	tmp = single(1.0) - ((u0 * (alphay * alphay)) / ((single(1.0) - cos((atan((tan((single(0.5) * single(pi))) * (alphay / alphax))) * single(2.0)))) * (single(1.0) - u0)));
end
1 - \frac{u0 \cdot \left(alphay \cdot alphay\right)}{\left(1 - \cos \left(\tan^{-1} \left(\tan \left(\frac{1}{2} \cdot \pi\right) \cdot \frac{alphay}{alphax}\right) \cdot 2\right)\right) \cdot \left(1 - u0\right)}
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 + \frac{1}{2} \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \frac{1}{2} \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 + \frac{1}{2} \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \frac{1}{2} \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  2. Applied rewrites99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

?
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (u0 u1 alphax alphay)
  :name "Trowbridge-Reitz Sample, sample surface normal, cosTheta"
  :precision binary32
  :pre (and (and (and (and (<= 2328306437/10000000000000000000 u0) (<= u0 1)) (and (<= 2328306437/10000000000000000000 u1) (<= u1 1/2))) (and (<= 1/10000 alphax) (<= alphax 1))) (and (<= 1/10000 alphay) (<= alphay 1)))
  (/ 1 (sqrt (+ 1 (/ (* (/ 1 (+ (/ (* (cos (atan (* (/ alphay alphax) (tan (+ (* (* 2 PI) u1) (* 1/2 PI)))))) (cos (atan (* (/ alphay alphax) (tan (+ (* (* 2 PI) u1) (* 1/2 PI))))))) (* alphax alphax)) (/ (* (sin (atan (* (/ alphay alphax) (tan (+ (* (* 2 PI) u1) (* 1/2 PI)))))) (sin (atan (* (/ alphay alphax) (tan (+ (* (* 2 PI) u1) (* 1/2 PI))))))) (* alphay alphay)))) u0) (- 1 u0))))))