Beckmann Distribution sample, tan2theta, alphax == alphay

Percentage Accurate: 55.9% → 89.8%
Time: 6.4s
Alternatives: 7
Speedup: 10.5×

Specification

?
\[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
\[\begin{array}{l} \\ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (* (* (- alpha) alpha) (log (- 1.0 u0))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf((1.0f - u0));
}
real(4) function code(alpha, u0)
    real(4), intent (in) :: alpha
    real(4), intent (in) :: u0
    code = (-alpha * alpha) * log((1.0e0 - u0))
end function
function code(alpha, u0)
	return Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)))
end
function tmp = code(alpha, u0)
	tmp = (-alpha * alpha) * log((single(1.0) - u0));
end
\begin{array}{l}

\\
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\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 7 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: 55.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (* (* (- alpha) alpha) (log (- 1.0 u0))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf((1.0f - u0));
}
real(4) function code(alpha, u0)
    real(4), intent (in) :: alpha
    real(4), intent (in) :: u0
    code = (-alpha * alpha) * log((1.0e0 - u0))
end function
function code(alpha, u0)
	return Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)))
end
function tmp = code(alpha, u0)
	tmp = (-alpha * alpha) * log((single(1.0) - u0));
end
\begin{array}{l}

\\
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\end{array}

Alternative 1: 89.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\ \;\;\;\;\log \left(1 - u0\right) \cdot \frac{-1}{\frac{\alpha \cdot \alpha}{{\alpha}^{4}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\ \end{array} \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (if (<= (- 1.0 u0) 0.9998624920845032)
   (* (log (- 1.0 u0)) (/ -1.0 (/ (* alpha alpha) (pow alpha 4.0))))
   (/ u0 (pow alpha -2.0))))
float code(float alpha, float u0) {
	float tmp;
	if ((1.0f - u0) <= 0.9998624920845032f) {
		tmp = logf((1.0f - u0)) * (-1.0f / ((alpha * alpha) / powf(alpha, 4.0f)));
	} else {
		tmp = u0 / powf(alpha, -2.0f);
	}
	return tmp;
}
real(4) function code(alpha, u0)
    real(4), intent (in) :: alpha
    real(4), intent (in) :: u0
    real(4) :: tmp
    if ((1.0e0 - u0) <= 0.9998624920845032e0) then
        tmp = log((1.0e0 - u0)) * ((-1.0e0) / ((alpha * alpha) / (alpha ** 4.0e0)))
    else
        tmp = u0 / (alpha ** (-2.0e0))
    end if
    code = tmp
end function
function code(alpha, u0)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - u0) <= Float32(0.9998624920845032))
		tmp = Float32(log(Float32(Float32(1.0) - u0)) * Float32(Float32(-1.0) / Float32(Float32(alpha * alpha) / (alpha ^ Float32(4.0)))));
	else
		tmp = Float32(u0 / (alpha ^ Float32(-2.0)));
	end
	return tmp
end
function tmp_2 = code(alpha, u0)
	tmp = single(0.0);
	if ((single(1.0) - u0) <= single(0.9998624920845032))
		tmp = log((single(1.0) - u0)) * (single(-1.0) / ((alpha * alpha) / (alpha ^ single(4.0))));
	else
		tmp = u0 / (alpha ^ single(-2.0));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\
\;\;\;\;\log \left(1 - u0\right) \cdot \frac{-1}{\frac{\alpha \cdot \alpha}{{\alpha}^{4}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{u0}{{\alpha}^{-2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f32 #s(literal 1 binary32) u0) < 0.999862492

    1. Initial program 86.8%

      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \color{blue}{\left(\left(-\alpha\right) \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
      2. lift-neg.f32N/A

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\alpha\right)\right)} \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\alpha \cdot \alpha\right)\right)} \cdot \log \left(1 - u0\right) \]
      4. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - \alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
      5. flip--N/A

        \[\leadsto \color{blue}{\frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{0 + \alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
      6. +-lft-identityN/A

        \[\leadsto \frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{\color{blue}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
      7. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
      8. lower-/.f32N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
      9. lower-/.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\alpha \cdot \alpha}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
      10. lower-*.f32N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\alpha \cdot \alpha}}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
      11. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{\color{blue}{0} - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
      12. sub0-negN/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{\color{blue}{\mathsf{neg}\left(\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)\right)}}} \cdot \log \left(1 - u0\right) \]
      13. lower-neg.f32N/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{\color{blue}{-\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
      14. pow2N/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-\color{blue}{{\alpha}^{2}} \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
      15. pow2N/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{2} \cdot \color{blue}{{\alpha}^{2}}}} \cdot \log \left(1 - u0\right) \]
      16. pow-prod-upN/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-\color{blue}{{\alpha}^{\left(2 + 2\right)}}}} \cdot \log \left(1 - u0\right) \]
      17. lower-pow.f32N/A

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-\color{blue}{{\alpha}^{\left(2 + 2\right)}}}} \cdot \log \left(1 - u0\right) \]
      18. metadata-eval87.0

        \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{\color{blue}{4}}}} \cdot \log \left(1 - u0\right) \]
    4. Applied rewrites87.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{4}}}} \cdot \log \left(1 - u0\right) \]

    if 0.999862492 < (-.f32 #s(literal 1 binary32) u0)

    1. Initial program 36.3%

      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
    2. Add Preprocessing
    3. Taylor expanded in u0 around 0

      \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
    4. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
      2. unpow2N/A

        \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
      3. lower-*.f3290.9

        \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
    5. Applied rewrites90.9%

      \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
    6. Step-by-step derivation
      1. Applied rewrites90.7%

        \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
      2. Step-by-step derivation
        1. Applied rewrites90.9%

          \[\leadsto \frac{u0}{\color{blue}{{\alpha}^{-2}}} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification89.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\ \;\;\;\;\log \left(1 - u0\right) \cdot \frac{-1}{\frac{\alpha \cdot \alpha}{{\alpha}^{4}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 2: 89.8% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\ \;\;\;\;\frac{-{\alpha}^{4}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\ \end{array} \end{array} \]
      (FPCore (alpha u0)
       :precision binary32
       (if (<= (- 1.0 u0) 0.9998624920845032)
         (* (/ (- (pow alpha 4.0)) (* alpha alpha)) (log (- 1.0 u0)))
         (/ u0 (pow alpha -2.0))))
      float code(float alpha, float u0) {
      	float tmp;
      	if ((1.0f - u0) <= 0.9998624920845032f) {
      		tmp = (-powf(alpha, 4.0f) / (alpha * alpha)) * logf((1.0f - u0));
      	} else {
      		tmp = u0 / powf(alpha, -2.0f);
      	}
      	return tmp;
      }
      
      real(4) function code(alpha, u0)
          real(4), intent (in) :: alpha
          real(4), intent (in) :: u0
          real(4) :: tmp
          if ((1.0e0 - u0) <= 0.9998624920845032e0) then
              tmp = (-(alpha ** 4.0e0) / (alpha * alpha)) * log((1.0e0 - u0))
          else
              tmp = u0 / (alpha ** (-2.0e0))
          end if
          code = tmp
      end function
      
      function code(alpha, u0)
      	tmp = Float32(0.0)
      	if (Float32(Float32(1.0) - u0) <= Float32(0.9998624920845032))
      		tmp = Float32(Float32(Float32(-(alpha ^ Float32(4.0))) / Float32(alpha * alpha)) * log(Float32(Float32(1.0) - u0)));
      	else
      		tmp = Float32(u0 / (alpha ^ Float32(-2.0)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(alpha, u0)
      	tmp = single(0.0);
      	if ((single(1.0) - u0) <= single(0.9998624920845032))
      		tmp = (-(alpha ^ single(4.0)) / (alpha * alpha)) * log((single(1.0) - u0));
      	else
      		tmp = u0 / (alpha ^ single(-2.0));
      	end
      	tmp_2 = tmp;
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\
      \;\;\;\;\frac{-{\alpha}^{4}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (-.f32 #s(literal 1 binary32) u0) < 0.999862492

        1. Initial program 86.8%

          \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \color{blue}{\left(\left(-\alpha\right) \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
          2. lift-neg.f32N/A

            \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\alpha\right)\right)} \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
          3. distribute-lft-neg-outN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\alpha \cdot \alpha\right)\right)} \cdot \log \left(1 - u0\right) \]
          4. neg-sub0N/A

            \[\leadsto \color{blue}{\left(0 - \alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
          5. flip--N/A

            \[\leadsto \color{blue}{\frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{0 + \alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
          6. +-lft-identityN/A

            \[\leadsto \frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{\color{blue}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
          7. lower-/.f32N/A

            \[\leadsto \color{blue}{\frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
          8. metadata-evalN/A

            \[\leadsto \frac{\color{blue}{0} - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          9. sub0-negN/A

            \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)\right)}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          10. lower-neg.f32N/A

            \[\leadsto \frac{\color{blue}{-\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          11. pow2N/A

            \[\leadsto \frac{-\color{blue}{{\alpha}^{2}} \cdot \left(\alpha \cdot \alpha\right)}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          12. pow2N/A

            \[\leadsto \frac{-{\alpha}^{2} \cdot \color{blue}{{\alpha}^{2}}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          13. pow-prod-upN/A

            \[\leadsto \frac{-\color{blue}{{\alpha}^{\left(2 + 2\right)}}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          14. lower-pow.f32N/A

            \[\leadsto \frac{-\color{blue}{{\alpha}^{\left(2 + 2\right)}}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          15. metadata-evalN/A

            \[\leadsto \frac{-{\alpha}^{\color{blue}{4}}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
          16. lower-*.f3286.9

            \[\leadsto \frac{-{\alpha}^{4}}{\color{blue}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
        4. Applied rewrites86.9%

          \[\leadsto \color{blue}{\frac{-{\alpha}^{4}}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]

        if 0.999862492 < (-.f32 #s(literal 1 binary32) u0)

        1. Initial program 36.3%

          \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
        2. Add Preprocessing
        3. Taylor expanded in u0 around 0

          \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
        4. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
          2. unpow2N/A

            \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
          3. lower-*.f3290.9

            \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
        5. Applied rewrites90.9%

          \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
        6. Step-by-step derivation
          1. Applied rewrites90.7%

            \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
          2. Step-by-step derivation
            1. Applied rewrites90.9%

              \[\leadsto \frac{u0}{\color{blue}{{\alpha}^{-2}}} \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 3: 89.8% accurate, 0.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\ \;\;\;\;\frac{-1}{{\alpha}^{-2}} \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\ \end{array} \end{array} \]
          (FPCore (alpha u0)
           :precision binary32
           (if (<= (- 1.0 u0) 0.9998624920845032)
             (* (/ -1.0 (pow alpha -2.0)) (log (- 1.0 u0)))
             (/ u0 (pow alpha -2.0))))
          float code(float alpha, float u0) {
          	float tmp;
          	if ((1.0f - u0) <= 0.9998624920845032f) {
          		tmp = (-1.0f / powf(alpha, -2.0f)) * logf((1.0f - u0));
          	} else {
          		tmp = u0 / powf(alpha, -2.0f);
          	}
          	return tmp;
          }
          
          real(4) function code(alpha, u0)
              real(4), intent (in) :: alpha
              real(4), intent (in) :: u0
              real(4) :: tmp
              if ((1.0e0 - u0) <= 0.9998624920845032e0) then
                  tmp = ((-1.0e0) / (alpha ** (-2.0e0))) * log((1.0e0 - u0))
              else
                  tmp = u0 / (alpha ** (-2.0e0))
              end if
              code = tmp
          end function
          
          function code(alpha, u0)
          	tmp = Float32(0.0)
          	if (Float32(Float32(1.0) - u0) <= Float32(0.9998624920845032))
          		tmp = Float32(Float32(Float32(-1.0) / (alpha ^ Float32(-2.0))) * log(Float32(Float32(1.0) - u0)));
          	else
          		tmp = Float32(u0 / (alpha ^ Float32(-2.0)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(alpha, u0)
          	tmp = single(0.0);
          	if ((single(1.0) - u0) <= single(0.9998624920845032))
          		tmp = (single(-1.0) / (alpha ^ single(-2.0))) * log((single(1.0) - u0));
          	else
          		tmp = u0 / (alpha ^ single(-2.0));
          	end
          	tmp_2 = tmp;
          end
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\
          \;\;\;\;\frac{-1}{{\alpha}^{-2}} \cdot \log \left(1 - u0\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (-.f32 #s(literal 1 binary32) u0) < 0.999862492

            1. Initial program 86.8%

              \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift-*.f32N/A

                \[\leadsto \color{blue}{\left(\left(-\alpha\right) \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
              2. lift-neg.f32N/A

                \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\alpha\right)\right)} \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
              3. distribute-lft-neg-outN/A

                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\alpha \cdot \alpha\right)\right)} \cdot \log \left(1 - u0\right) \]
              4. neg-sub0N/A

                \[\leadsto \color{blue}{\left(0 - \alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
              5. flip--N/A

                \[\leadsto \color{blue}{\frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{0 + \alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
              6. +-lft-identityN/A

                \[\leadsto \frac{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}{\color{blue}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
              7. clear-numN/A

                \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
              8. lower-/.f32N/A

                \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
              9. lower-/.f32N/A

                \[\leadsto \frac{1}{\color{blue}{\frac{\alpha \cdot \alpha}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
              10. lower-*.f32N/A

                \[\leadsto \frac{1}{\frac{\color{blue}{\alpha \cdot \alpha}}{0 \cdot 0 - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
              11. metadata-evalN/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{\color{blue}{0} - \left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
              12. sub0-negN/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{\color{blue}{\mathsf{neg}\left(\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)\right)}}} \cdot \log \left(1 - u0\right) \]
              13. lower-neg.f32N/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{\color{blue}{-\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}}} \cdot \log \left(1 - u0\right) \]
              14. pow2N/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-\color{blue}{{\alpha}^{2}} \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
              15. pow2N/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{2} \cdot \color{blue}{{\alpha}^{2}}}} \cdot \log \left(1 - u0\right) \]
              16. pow-prod-upN/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-\color{blue}{{\alpha}^{\left(2 + 2\right)}}}} \cdot \log \left(1 - u0\right) \]
              17. lower-pow.f32N/A

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-\color{blue}{{\alpha}^{\left(2 + 2\right)}}}} \cdot \log \left(1 - u0\right) \]
              18. metadata-eval87.0

                \[\leadsto \frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{\color{blue}{4}}}} \cdot \log \left(1 - u0\right) \]
            4. Applied rewrites87.0%

              \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{4}}}} \cdot \log \left(1 - u0\right) \]
            5. Step-by-step derivation
              1. lift-/.f32N/A

                \[\leadsto \color{blue}{\frac{1}{\frac{\alpha \cdot \alpha}{-{\alpha}^{4}}}} \cdot \log \left(1 - u0\right) \]
              2. lift-/.f32N/A

                \[\leadsto \frac{1}{\color{blue}{\frac{\alpha \cdot \alpha}{-{\alpha}^{4}}}} \cdot \log \left(1 - u0\right) \]
              3. clear-numN/A

                \[\leadsto \color{blue}{\frac{-{\alpha}^{4}}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
              4. lift-neg.f32N/A

                \[\leadsto \frac{\color{blue}{\mathsf{neg}\left({\alpha}^{4}\right)}}{\alpha \cdot \alpha} \cdot \log \left(1 - u0\right) \]
              5. distribute-frac-negN/A

                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{{\alpha}^{4}}{\alpha \cdot \alpha}\right)\right)} \cdot \log \left(1 - u0\right) \]
              6. lift-pow.f32N/A

                \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{{\alpha}^{4}}}{\alpha \cdot \alpha}\right)\right) \cdot \log \left(1 - u0\right) \]
              7. lift-*.f32N/A

                \[\leadsto \left(\mathsf{neg}\left(\frac{{\alpha}^{4}}{\color{blue}{\alpha \cdot \alpha}}\right)\right) \cdot \log \left(1 - u0\right) \]
              8. pow2N/A

                \[\leadsto \left(\mathsf{neg}\left(\frac{{\alpha}^{4}}{\color{blue}{{\alpha}^{2}}}\right)\right) \cdot \log \left(1 - u0\right) \]
              9. pow-divN/A

                \[\leadsto \left(\mathsf{neg}\left(\color{blue}{{\alpha}^{\left(4 - 2\right)}}\right)\right) \cdot \log \left(1 - u0\right) \]
              10. metadata-evalN/A

                \[\leadsto \left(\mathsf{neg}\left({\alpha}^{\color{blue}{2}}\right)\right) \cdot \log \left(1 - u0\right) \]
              11. pow2N/A

                \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\alpha \cdot \alpha}\right)\right) \cdot \log \left(1 - u0\right) \]
              12. lift-*.f32N/A

                \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\alpha \cdot \alpha}\right)\right) \cdot \log \left(1 - u0\right) \]
              13. remove-double-divN/A

                \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{1}{\frac{1}{\alpha \cdot \alpha}}}\right)\right) \cdot \log \left(1 - u0\right) \]
              14. distribute-neg-fracN/A

                \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\frac{1}{\alpha \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
              15. metadata-evalN/A

                \[\leadsto \frac{\color{blue}{-1}}{\frac{1}{\alpha \cdot \alpha}} \cdot \log \left(1 - u0\right) \]
              16. lower-/.f32N/A

                \[\leadsto \color{blue}{\frac{-1}{\frac{1}{\alpha \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
              17. lift-*.f32N/A

                \[\leadsto \frac{-1}{\frac{1}{\color{blue}{\alpha \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
              18. pow2N/A

                \[\leadsto \frac{-1}{\frac{1}{\color{blue}{{\alpha}^{2}}}} \cdot \log \left(1 - u0\right) \]
              19. pow-flipN/A

                \[\leadsto \frac{-1}{\color{blue}{{\alpha}^{\left(\mathsf{neg}\left(2\right)\right)}}} \cdot \log \left(1 - u0\right) \]
              20. lower-pow.f32N/A

                \[\leadsto \frac{-1}{\color{blue}{{\alpha}^{\left(\mathsf{neg}\left(2\right)\right)}}} \cdot \log \left(1 - u0\right) \]
              21. metadata-eval86.9

                \[\leadsto \frac{-1}{{\alpha}^{\color{blue}{-2}}} \cdot \log \left(1 - u0\right) \]
            6. Applied rewrites86.9%

              \[\leadsto \color{blue}{\frac{-1}{{\alpha}^{-2}}} \cdot \log \left(1 - u0\right) \]

            if 0.999862492 < (-.f32 #s(literal 1 binary32) u0)

            1. Initial program 36.3%

              \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
            2. Add Preprocessing
            3. Taylor expanded in u0 around 0

              \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
            4. Step-by-step derivation
              1. lower-*.f32N/A

                \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
              2. unpow2N/A

                \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
              3. lower-*.f3290.9

                \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
            5. Applied rewrites90.9%

              \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
            6. Step-by-step derivation
              1. Applied rewrites90.7%

                \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
              2. Step-by-step derivation
                1. Applied rewrites90.9%

                  \[\leadsto \frac{u0}{\color{blue}{{\alpha}^{-2}}} \]
              3. Recombined 2 regimes into one program.
              4. Add Preprocessing

              Alternative 4: 89.8% accurate, 0.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\ \;\;\;\;\frac{\alpha}{\frac{-1}{\alpha}} \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\ \end{array} \end{array} \]
              (FPCore (alpha u0)
               :precision binary32
               (if (<= (- 1.0 u0) 0.9998624920845032)
                 (* (/ alpha (/ -1.0 alpha)) (log (- 1.0 u0)))
                 (/ u0 (pow alpha -2.0))))
              float code(float alpha, float u0) {
              	float tmp;
              	if ((1.0f - u0) <= 0.9998624920845032f) {
              		tmp = (alpha / (-1.0f / alpha)) * logf((1.0f - u0));
              	} else {
              		tmp = u0 / powf(alpha, -2.0f);
              	}
              	return tmp;
              }
              
              real(4) function code(alpha, u0)
                  real(4), intent (in) :: alpha
                  real(4), intent (in) :: u0
                  real(4) :: tmp
                  if ((1.0e0 - u0) <= 0.9998624920845032e0) then
                      tmp = (alpha / ((-1.0e0) / alpha)) * log((1.0e0 - u0))
                  else
                      tmp = u0 / (alpha ** (-2.0e0))
                  end if
                  code = tmp
              end function
              
              function code(alpha, u0)
              	tmp = Float32(0.0)
              	if (Float32(Float32(1.0) - u0) <= Float32(0.9998624920845032))
              		tmp = Float32(Float32(alpha / Float32(Float32(-1.0) / alpha)) * log(Float32(Float32(1.0) - u0)));
              	else
              		tmp = Float32(u0 / (alpha ^ Float32(-2.0)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(alpha, u0)
              	tmp = single(0.0);
              	if ((single(1.0) - u0) <= single(0.9998624920845032))
              		tmp = (alpha / (single(-1.0) / alpha)) * log((single(1.0) - u0));
              	else
              		tmp = u0 / (alpha ^ single(-2.0));
              	end
              	tmp_2 = tmp;
              end
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\
              \;\;\;\;\frac{\alpha}{\frac{-1}{\alpha}} \cdot \log \left(1 - u0\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (-.f32 #s(literal 1 binary32) u0) < 0.999862492

                1. Initial program 86.8%

                  \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-*.f32N/A

                    \[\leadsto \color{blue}{\left(\left(-\alpha\right) \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  2. lift-neg.f32N/A

                    \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\alpha\right)\right)} \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                  3. distribute-lft-neg-outN/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\alpha \cdot \alpha\right)\right)} \cdot \log \left(1 - u0\right) \]
                  4. neg-sub0N/A

                    \[\leadsto \color{blue}{\left(0 - \alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  5. flip3--N/A

                    \[\leadsto \color{blue}{\frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{0 \cdot 0 + \left(\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right) + 0 \cdot \left(\alpha \cdot \alpha\right)\right)}} \cdot \log \left(1 - u0\right) \]
                  6. metadata-evalN/A

                    \[\leadsto \frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\color{blue}{0} + \left(\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right) + 0 \cdot \left(\alpha \cdot \alpha\right)\right)} \cdot \log \left(1 - u0\right) \]
                  7. +-lft-identityN/A

                    \[\leadsto \frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\color{blue}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right) + 0 \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
                  8. mul0-lftN/A

                    \[\leadsto \frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right) + \color{blue}{0}} \cdot \log \left(1 - u0\right) \]
                  9. metadata-evalN/A

                    \[\leadsto \frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right) + \color{blue}{\left(\mathsf{neg}\left(0\right)\right)}} \cdot \log \left(1 - u0\right) \]
                  10. sub-negN/A

                    \[\leadsto \frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\color{blue}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right) - 0}} \cdot \log \left(1 - u0\right) \]
                  11. --rgt-identityN/A

                    \[\leadsto \frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\color{blue}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
                  12. lower-/.f32N/A

                    \[\leadsto \color{blue}{\frac{{0}^{3} - {\left(\alpha \cdot \alpha\right)}^{3}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)}} \cdot \log \left(1 - u0\right) \]
                  13. metadata-evalN/A

                    \[\leadsto \frac{\color{blue}{0} - {\left(\alpha \cdot \alpha\right)}^{3}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  14. sub0-negN/A

                    \[\leadsto \frac{\color{blue}{\mathsf{neg}\left({\left(\alpha \cdot \alpha\right)}^{3}\right)}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  15. lower-neg.f32N/A

                    \[\leadsto \frac{\color{blue}{-{\left(\alpha \cdot \alpha\right)}^{3}}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  16. pow2N/A

                    \[\leadsto \frac{-{\color{blue}{\left({\alpha}^{2}\right)}}^{3}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  17. pow-powN/A

                    \[\leadsto \frac{-\color{blue}{{\alpha}^{\left(2 \cdot 3\right)}}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  18. lower-pow.f32N/A

                    \[\leadsto \frac{-\color{blue}{{\alpha}^{\left(2 \cdot 3\right)}}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  19. metadata-evalN/A

                    \[\leadsto \frac{-{\alpha}^{\color{blue}{6}}}{\left(\alpha \cdot \alpha\right) \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  20. pow2N/A

                    \[\leadsto \frac{-{\alpha}^{6}}{\color{blue}{{\alpha}^{2}} \cdot \left(\alpha \cdot \alpha\right)} \cdot \log \left(1 - u0\right) \]
                  21. pow2N/A

                    \[\leadsto \frac{-{\alpha}^{6}}{{\alpha}^{2} \cdot \color{blue}{{\alpha}^{2}}} \cdot \log \left(1 - u0\right) \]
                  22. pow-prod-upN/A

                    \[\leadsto \frac{-{\alpha}^{6}}{\color{blue}{{\alpha}^{\left(2 + 2\right)}}} \cdot \log \left(1 - u0\right) \]
                  23. lower-pow.f32N/A

                    \[\leadsto \frac{-{\alpha}^{6}}{\color{blue}{{\alpha}^{\left(2 + 2\right)}}} \cdot \log \left(1 - u0\right) \]
                  24. metadata-eval86.8

                    \[\leadsto \frac{-{\alpha}^{6}}{{\alpha}^{\color{blue}{4}}} \cdot \log \left(1 - u0\right) \]
                4. Applied rewrites86.8%

                  \[\leadsto \color{blue}{\frac{-{\alpha}^{6}}{{\alpha}^{4}}} \cdot \log \left(1 - u0\right) \]
                5. Step-by-step derivation
                  1. lift-/.f32N/A

                    \[\leadsto \color{blue}{\frac{-{\alpha}^{6}}{{\alpha}^{4}}} \cdot \log \left(1 - u0\right) \]
                  2. lift-neg.f32N/A

                    \[\leadsto \frac{\color{blue}{\mathsf{neg}\left({\alpha}^{6}\right)}}{{\alpha}^{4}} \cdot \log \left(1 - u0\right) \]
                  3. distribute-frac-negN/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{{\alpha}^{6}}{{\alpha}^{4}}\right)\right)} \cdot \log \left(1 - u0\right) \]
                  4. lift-pow.f32N/A

                    \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{{\alpha}^{6}}}{{\alpha}^{4}}\right)\right) \cdot \log \left(1 - u0\right) \]
                  5. lift-pow.f32N/A

                    \[\leadsto \left(\mathsf{neg}\left(\frac{{\alpha}^{6}}{\color{blue}{{\alpha}^{4}}}\right)\right) \cdot \log \left(1 - u0\right) \]
                  6. pow-divN/A

                    \[\leadsto \left(\mathsf{neg}\left(\color{blue}{{\alpha}^{\left(6 - 4\right)}}\right)\right) \cdot \log \left(1 - u0\right) \]
                  7. metadata-evalN/A

                    \[\leadsto \left(\mathsf{neg}\left({\alpha}^{\color{blue}{2}}\right)\right) \cdot \log \left(1 - u0\right) \]
                  8. pow2N/A

                    \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\alpha \cdot \alpha}\right)\right) \cdot \log \left(1 - u0\right) \]
                  9. distribute-rgt-neg-inN/A

                    \[\leadsto \color{blue}{\left(\alpha \cdot \left(\mathsf{neg}\left(\alpha\right)\right)\right)} \cdot \log \left(1 - u0\right) \]
                  10. lift-neg.f32N/A

                    \[\leadsto \left(\alpha \cdot \color{blue}{\left(-\alpha\right)}\right) \cdot \log \left(1 - u0\right) \]
                  11. remove-double-divN/A

                    \[\leadsto \left(\alpha \cdot \color{blue}{\frac{1}{\frac{1}{-\alpha}}}\right) \cdot \log \left(1 - u0\right) \]
                  12. lift-/.f32N/A

                    \[\leadsto \left(\alpha \cdot \frac{1}{\color{blue}{\frac{1}{-\alpha}}}\right) \cdot \log \left(1 - u0\right) \]
                  13. un-div-invN/A

                    \[\leadsto \color{blue}{\frac{\alpha}{\frac{1}{-\alpha}}} \cdot \log \left(1 - u0\right) \]
                  14. lower-/.f3286.9

                    \[\leadsto \color{blue}{\frac{\alpha}{\frac{1}{-\alpha}}} \cdot \log \left(1 - u0\right) \]
                  15. lift-/.f32N/A

                    \[\leadsto \frac{\alpha}{\color{blue}{\frac{1}{-\alpha}}} \cdot \log \left(1 - u0\right) \]
                  16. frac-2negN/A

                    \[\leadsto \frac{\alpha}{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(-\alpha\right)\right)}}} \cdot \log \left(1 - u0\right) \]
                  17. metadata-evalN/A

                    \[\leadsto \frac{\alpha}{\frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(-\alpha\right)\right)}} \cdot \log \left(1 - u0\right) \]
                  18. lift-neg.f32N/A

                    \[\leadsto \frac{\alpha}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\alpha\right)\right)}\right)}} \cdot \log \left(1 - u0\right) \]
                  19. remove-double-negN/A

                    \[\leadsto \frac{\alpha}{\frac{-1}{\color{blue}{\alpha}}} \cdot \log \left(1 - u0\right) \]
                  20. lower-/.f3286.9

                    \[\leadsto \frac{\alpha}{\color{blue}{\frac{-1}{\alpha}}} \cdot \log \left(1 - u0\right) \]
                6. Applied rewrites86.9%

                  \[\leadsto \color{blue}{\frac{\alpha}{\frac{-1}{\alpha}}} \cdot \log \left(1 - u0\right) \]

                if 0.999862492 < (-.f32 #s(literal 1 binary32) u0)

                1. Initial program 36.3%

                  \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                2. Add Preprocessing
                3. Taylor expanded in u0 around 0

                  \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                4. Step-by-step derivation
                  1. lower-*.f32N/A

                    \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                  2. unpow2N/A

                    \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                  3. lower-*.f3290.9

                    \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                5. Applied rewrites90.9%

                  \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
                6. Step-by-step derivation
                  1. Applied rewrites90.7%

                    \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
                  2. Step-by-step derivation
                    1. Applied rewrites90.9%

                      \[\leadsto \frac{u0}{\color{blue}{{\alpha}^{-2}}} \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 5: 89.8% accurate, 0.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\ \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\ \end{array} \end{array} \]
                  (FPCore (alpha u0)
                   :precision binary32
                   (if (<= (- 1.0 u0) 0.9998624920845032)
                     (* (* (- alpha) alpha) (log (- 1.0 u0)))
                     (/ u0 (pow alpha -2.0))))
                  float code(float alpha, float u0) {
                  	float tmp;
                  	if ((1.0f - u0) <= 0.9998624920845032f) {
                  		tmp = (-alpha * alpha) * logf((1.0f - u0));
                  	} else {
                  		tmp = u0 / powf(alpha, -2.0f);
                  	}
                  	return tmp;
                  }
                  
                  real(4) function code(alpha, u0)
                      real(4), intent (in) :: alpha
                      real(4), intent (in) :: u0
                      real(4) :: tmp
                      if ((1.0e0 - u0) <= 0.9998624920845032e0) then
                          tmp = (-alpha * alpha) * log((1.0e0 - u0))
                      else
                          tmp = u0 / (alpha ** (-2.0e0))
                      end if
                      code = tmp
                  end function
                  
                  function code(alpha, u0)
                  	tmp = Float32(0.0)
                  	if (Float32(Float32(1.0) - u0) <= Float32(0.9998624920845032))
                  		tmp = Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)));
                  	else
                  		tmp = Float32(u0 / (alpha ^ Float32(-2.0)));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(alpha, u0)
                  	tmp = single(0.0);
                  	if ((single(1.0) - u0) <= single(0.9998624920845032))
                  		tmp = (-alpha * alpha) * log((single(1.0) - u0));
                  	else
                  		tmp = u0 / (alpha ^ single(-2.0));
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;1 - u0 \leq 0.9998624920845032:\\
                  \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{u0}{{\alpha}^{-2}}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (-.f32 #s(literal 1 binary32) u0) < 0.999862492

                    1. Initial program 86.8%

                      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                    2. Add Preprocessing

                    if 0.999862492 < (-.f32 #s(literal 1 binary32) u0)

                    1. Initial program 36.3%

                      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                    2. Add Preprocessing
                    3. Taylor expanded in u0 around 0

                      \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                    4. Step-by-step derivation
                      1. lower-*.f32N/A

                        \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                      2. unpow2N/A

                        \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                      3. lower-*.f3290.9

                        \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                    5. Applied rewrites90.9%

                      \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
                    6. Step-by-step derivation
                      1. Applied rewrites90.7%

                        \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
                      2. Step-by-step derivation
                        1. Applied rewrites90.9%

                          \[\leadsto \frac{u0}{\color{blue}{{\alpha}^{-2}}} \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 6: 74.5% accurate, 1.0× speedup?

                      \[\begin{array}{l} \\ \frac{u0}{{\alpha}^{-2}} \end{array} \]
                      (FPCore (alpha u0) :precision binary32 (/ u0 (pow alpha -2.0)))
                      float code(float alpha, float u0) {
                      	return u0 / powf(alpha, -2.0f);
                      }
                      
                      real(4) function code(alpha, u0)
                          real(4), intent (in) :: alpha
                          real(4), intent (in) :: u0
                          code = u0 / (alpha ** (-2.0e0))
                      end function
                      
                      function code(alpha, u0)
                      	return Float32(u0 / (alpha ^ Float32(-2.0)))
                      end
                      
                      function tmp = code(alpha, u0)
                      	tmp = u0 / (alpha ^ single(-2.0));
                      end
                      
                      \begin{array}{l}
                      
                      \\
                      \frac{u0}{{\alpha}^{-2}}
                      \end{array}
                      
                      Derivation
                      1. Initial program 58.8%

                        \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                      2. Add Preprocessing
                      3. Taylor expanded in u0 around 0

                        \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                      4. Step-by-step derivation
                        1. lower-*.f32N/A

                          \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                        2. unpow2N/A

                          \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                        3. lower-*.f3272.2

                          \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                      5. Applied rewrites72.2%

                        \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
                      6. Step-by-step derivation
                        1. Applied rewrites72.1%

                          \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
                        2. Step-by-step derivation
                          1. Applied rewrites72.2%

                            \[\leadsto \frac{u0}{\color{blue}{{\alpha}^{-2}}} \]
                          2. Add Preprocessing

                          Alternative 7: 74.5% accurate, 10.5× speedup?

                          \[\begin{array}{l} \\ \left(\alpha \cdot \alpha\right) \cdot u0 \end{array} \]
                          (FPCore (alpha u0) :precision binary32 (* (* alpha alpha) u0))
                          float code(float alpha, float u0) {
                          	return (alpha * alpha) * u0;
                          }
                          
                          real(4) function code(alpha, u0)
                              real(4), intent (in) :: alpha
                              real(4), intent (in) :: u0
                              code = (alpha * alpha) * u0
                          end function
                          
                          function code(alpha, u0)
                          	return Float32(Float32(alpha * alpha) * u0)
                          end
                          
                          function tmp = code(alpha, u0)
                          	tmp = (alpha * alpha) * u0;
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          \left(\alpha \cdot \alpha\right) \cdot u0
                          \end{array}
                          
                          Derivation
                          1. Initial program 58.8%

                            \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                          2. Add Preprocessing
                          3. Taylor expanded in u0 around 0

                            \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                          4. Step-by-step derivation
                            1. lower-*.f32N/A

                              \[\leadsto \color{blue}{{\alpha}^{2} \cdot u0} \]
                            2. unpow2N/A

                              \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                            3. lower-*.f3272.2

                              \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right)} \cdot u0 \]
                          5. Applied rewrites72.2%

                            \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot u0} \]
                          6. Add Preprocessing

                          Reproduce

                          ?
                          herbie shell --seed 2024332 
                          (FPCore (alpha u0)
                            :name "Beckmann Distribution sample, tan2theta, alphax == alphay"
                            :precision binary32
                            :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0)) (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                            (* (* (- alpha) alpha) (log (- 1.0 u0))))