Trowbridge-Reitz Sample, sample surface normal, cosTheta

Percentage Accurate: 99.4% → 99.4%
Time: 59.9s
Alternatives: 3
Speedup: 1.1×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

Alternative 1: 99.4% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(6.2831854820251465 \cdot u1 + 1.5707963705062866\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 (+ (* 6.2831854820251465 u1) 1.5707963705062866)))))
       (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(((6.2831854820251465f * u1) + 1.5707963705062866f))));
	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))));
}
real(4) function code(u0, u1, alphax, alphay)
use fmin_fmax_functions
    real(4), intent (in) :: u0
    real(4), intent (in) :: u1
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4) :: t_0
    real(4) :: t_1
    real(4) :: t_2
    t_0 = atan(((alphay / alphax) * tan(((6.2831854820251465e0 * u1) + 1.5707963705062866e0))))
    t_1 = sin(t_0)
    t_2 = cos(t_0)
    code = 1.0e0 / sqrt((1.0e0 + (((1.0e0 / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (1.0e0 - u0))))
end function
function code(u0, u1, alphax, alphay)
	t_0 = atan(Float32(Float32(alphay / alphax) * tan(Float32(Float32(Float32(6.2831854820251465) * u1) + Float32(1.5707963705062866)))))
	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(6.2831854820251465) * u1) + single(1.5707963705062866)))));
	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(6.2831854820251465 \cdot u1 + 1.5707963705062866\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}
Derivation
  1. Initial program 99.4%

    \[\frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  2. Evaluated real constant99.4%

    \[\leadsto \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 + \color{blue}{1.5707963705062866}\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}}} \]
  3. Evaluated real constant99.4%

    \[\leadsto \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 + 1.5707963705062866\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \color{blue}{1.5707963705062866}\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}}} \]
  4. Evaluated real constant99.4%

    \[\leadsto \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 + 1.5707963705062866\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \color{blue}{1.5707963705062866}\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}}} \]
  5. Evaluated real constant99.4%

    \[\leadsto \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 + 1.5707963705062866\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + \color{blue}{1.5707963705062866}\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  6. Evaluated real constant99.4%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\color{blue}{6.2831854820251465} \cdot u1 + 1.5707963705062866\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  7. Evaluated real constant99.4%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(6.2831854820251465 \cdot u1 + 1.5707963705062866\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\color{blue}{6.2831854820251465} \cdot u1 + 1.5707963705062866\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  8. Evaluated real constant99.4%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(6.2831854820251465 \cdot u1 + 1.5707963705062866\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(6.2831854820251465 \cdot u1 + 1.5707963705062866\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\color{blue}{6.2831854820251465} \cdot u1 + 1.5707963705062866\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\left(2 \cdot \pi\right) \cdot u1 + 1.5707963705062866\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  9. Evaluated real constant99.4%

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

Alternative 2: 97.6% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\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 1.5707963705062866))))
       (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(1.5707963705062866f)));
	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))));
}
real(4) function code(u0, u1, alphax, alphay)
use fmin_fmax_functions
    real(4), intent (in) :: u0
    real(4), intent (in) :: u1
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4) :: t_0
    real(4) :: t_1
    real(4) :: t_2
    t_0 = atan(((alphay / alphax) * tan(1.5707963705062866e0)))
    t_1 = sin(t_0)
    t_2 = cos(t_0)
    code = 1.0e0 / sqrt((1.0e0 + (((1.0e0 / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / (1.0e0 - u0))))
end function
function code(u0, u1, alphax, alphay)
	t_0 = atan(Float32(Float32(alphay / alphax) * tan(Float32(1.5707963705062866))))
	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(1.5707963705062866))));
	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 1.5707963705062866\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}
Derivation
  1. Initial program 99.4%

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

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(\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 + 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}}} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\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. lower-PI.f3297.7%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(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}}} \]
  4. Applied rewrites97.7%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(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}}} \]
  5. Taylor expanded in u1 around 0

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(\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 + 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}}} \]
  6. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\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. lower-PI.f3297.7%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(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}}} \]
  7. Applied rewrites97.7%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(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}}} \]
  8. Taylor expanded in u1 around 0

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(\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 + 0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  9. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\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. lower-PI.f3297.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(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}}} \]
  10. Applied rewrites97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(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}}} \]
  11. Taylor expanded in u1 around 0

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  13. Applied rewrites97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(0.5 \cdot \pi\right)}\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  14. Evaluated real constant97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  15. Evaluated real constant97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  16. Evaluated real constant97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  17. Evaluated real constant97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  18. Add Preprocessing

Alternative 3: 94.6% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\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}}} \end{array} \]
(FPCore (u0 u1 alphax alphay)
  :precision binary32
  (let* ((t_0 (atan (* (/ alphay alphax) (tan 1.5707963705062866))))
       (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))))))
float code(float u0, float u1, float alphax, float alphay) {
	float t_0 = atanf(((alphay / alphax) * tanf(1.5707963705062866f)));
	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)));
}
real(4) function code(u0, u1, alphax, alphay)
use fmin_fmax_functions
    real(4), intent (in) :: u0
    real(4), intent (in) :: u1
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4) :: t_0
    real(4) :: t_1
    real(4) :: t_2
    t_0 = atan(((alphay / alphax) * tan(1.5707963705062866e0)))
    t_1 = sin(t_0)
    t_2 = cos(t_0)
    code = 1.0e0 / sqrt((1.0e0 + (((1.0e0 / (((t_2 * t_2) / (alphax * alphax)) + ((t_1 * t_1) / (alphay * alphay)))) * u0) / 1.0e0)))
end function
function code(u0, u1, alphax, alphay)
	t_0 = atan(Float32(Float32(alphay / alphax) * tan(Float32(1.5707963705062866))))
	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(1.0)))))
end
function tmp = code(u0, u1, alphax, alphay)
	t_0 = atan(((alphay / alphax) * tan(single(1.5707963705062866))));
	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))));
end
\begin{array}{l}
t_0 := \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\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}}}
\end{array}
Derivation
  1. Initial program 99.4%

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

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(\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 + 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}}} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\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. lower-PI.f3297.7%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(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}}} \]
  4. Applied rewrites97.7%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(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}}} \]
  5. Taylor expanded in u1 around 0

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(\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 + 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}}} \]
  6. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\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. lower-PI.f3297.7%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(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}}} \]
  7. Applied rewrites97.7%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(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}}} \]
  8. Taylor expanded in u1 around 0

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(\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 + 0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  9. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\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. lower-PI.f3297.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(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}}} \]
  10. Applied rewrites97.6%

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \color{blue}{\left(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}}} \]
  11. Taylor expanded in u1 around 0

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

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

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1 - u0}}} \]
  13. Applied rewrites97.6%

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

    \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{\color{blue}{1}}}} \]
  15. Step-by-step derivation
    1. Applied rewrites94.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{\color{blue}{1}}}} \]
    2. Evaluated real constant94.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1}}} \]
    3. Evaluated real constant94.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1}}} \]
    4. Evaluated real constant94.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan \left(0.5 \cdot \pi\right)\right)}{alphay \cdot alphay}} \cdot u0}{1}}} \]
    5. Evaluated real constant94.6%

      \[\leadsto \frac{1}{\sqrt{1 + \frac{\frac{1}{\frac{\cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \cos \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphax \cdot alphax} + \frac{\sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right) \cdot \sin \tan^{-1} \left(\frac{alphay}{alphax} \cdot \tan 1.5707963705062866\right)}{alphay \cdot alphay}} \cdot u0}{1}}} \]
    6. Add Preprocessing

    Reproduce

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