Beckmann Distribution sample, tan2theta, alphax == alphay

Percentage Accurate: 55.6% → 89.7%
Time: 6.7s
Alternatives: 5
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 5 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.6% 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.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998499751091003:\\ \;\;\;\;\left({\alpha}^{2.5} \cdot \left({\alpha}^{1.5} \cdot \left(-{\alpha}^{-2}\right)\right)\right) \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u0 \cdot \alpha\right) \cdot \alpha\\ \end{array} \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (if (<= (- 1.0 u0) 0.9998499751091003)
   (*
    (* (pow alpha 2.5) (* (pow alpha 1.5) (- (pow alpha -2.0))))
    (log (- 1.0 u0)))
   (* (* u0 alpha) alpha)))
float code(float alpha, float u0) {
	float tmp;
	if ((1.0f - u0) <= 0.9998499751091003f) {
		tmp = (powf(alpha, 2.5f) * (powf(alpha, 1.5f) * -powf(alpha, -2.0f))) * logf((1.0f - u0));
	} else {
		tmp = (u0 * alpha) * alpha;
	}
	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.9998499751091003e0) then
        tmp = ((alpha ** 2.5e0) * ((alpha ** 1.5e0) * -(alpha ** (-2.0e0)))) * log((1.0e0 - u0))
    else
        tmp = (u0 * alpha) * alpha
    end if
    code = tmp
end function
function code(alpha, u0)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - u0) <= Float32(0.9998499751091003))
		tmp = Float32(Float32((alpha ^ Float32(2.5)) * Float32((alpha ^ Float32(1.5)) * Float32(-(alpha ^ Float32(-2.0))))) * log(Float32(Float32(1.0) - u0)));
	else
		tmp = Float32(Float32(u0 * alpha) * alpha);
	end
	return tmp
end
function tmp_2 = code(alpha, u0)
	tmp = single(0.0);
	if ((single(1.0) - u0) <= single(0.9998499751091003))
		tmp = ((alpha ^ single(2.5)) * ((alpha ^ single(1.5)) * -(alpha ^ single(-2.0)))) * log((single(1.0) - u0));
	else
		tmp = (u0 * alpha) * alpha;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;1 - u0 \leq 0.9998499751091003:\\
\;\;\;\;\left({\alpha}^{2.5} \cdot \left({\alpha}^{1.5} \cdot \left(-{\alpha}^{-2}\right)\right)\right) \cdot \log \left(1 - u0\right)\\

\mathbf{else}:\\
\;\;\;\;\left(u0 \cdot \alpha\right) \cdot \alpha\\


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

    1. Initial program 87.6%

      \[\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. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
      15. lower-*.f3287.3

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

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

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

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

    1. Initial program 33.4%

      \[\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-*.f3291.8

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

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

        \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 2: 89.7% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998499751091003:\\ \;\;\;\;\left(\left(\left(\alpha \cdot \alpha\right) \cdot \frac{-1}{\alpha}\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u0 \cdot \alpha\right) \cdot \alpha\\ \end{array} \end{array} \]
    (FPCore (alpha u0)
     :precision binary32
     (if (<= (- 1.0 u0) 0.9998499751091003)
       (* (* (* (* alpha alpha) (/ -1.0 alpha)) alpha) (log (- 1.0 u0)))
       (* (* u0 alpha) alpha)))
    float code(float alpha, float u0) {
    	float tmp;
    	if ((1.0f - u0) <= 0.9998499751091003f) {
    		tmp = (((alpha * alpha) * (-1.0f / alpha)) * alpha) * logf((1.0f - u0));
    	} else {
    		tmp = (u0 * alpha) * alpha;
    	}
    	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.9998499751091003e0) then
            tmp = (((alpha * alpha) * ((-1.0e0) / alpha)) * alpha) * log((1.0e0 - u0))
        else
            tmp = (u0 * alpha) * alpha
        end if
        code = tmp
    end function
    
    function code(alpha, u0)
    	tmp = Float32(0.0)
    	if (Float32(Float32(1.0) - u0) <= Float32(0.9998499751091003))
    		tmp = Float32(Float32(Float32(Float32(alpha * alpha) * Float32(Float32(-1.0) / alpha)) * alpha) * log(Float32(Float32(1.0) - u0)));
    	else
    		tmp = Float32(Float32(u0 * alpha) * alpha);
    	end
    	return tmp
    end
    
    function tmp_2 = code(alpha, u0)
    	tmp = single(0.0);
    	if ((single(1.0) - u0) <= single(0.9998499751091003))
    		tmp = (((alpha * alpha) * (single(-1.0) / alpha)) * alpha) * log((single(1.0) - u0));
    	else
    		tmp = (u0 * alpha) * alpha;
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;1 - u0 \leq 0.9998499751091003:\\
    \;\;\;\;\left(\left(\left(\alpha \cdot \alpha\right) \cdot \frac{-1}{\alpha}\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(u0 \cdot \alpha\right) \cdot \alpha\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (-.f32 #s(literal 1 binary32) u0) < 0.999849975

      1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\left(\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \frac{1}{\color{blue}{\alpha}}\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
        12. lower-/.f3287.6

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

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

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

      1. Initial program 33.4%

        \[\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-*.f3291.8

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

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

          \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
      7. Recombined 2 regimes into one program.
      8. Final simplification90.4%

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

      Alternative 3: 89.7% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998499751091003:\\ \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u0 \cdot \alpha\right) \cdot \alpha\\ \end{array} \end{array} \]
      (FPCore (alpha u0)
       :precision binary32
       (if (<= (- 1.0 u0) 0.9998499751091003)
         (* (* (- alpha) alpha) (log (- 1.0 u0)))
         (* (* u0 alpha) alpha)))
      float code(float alpha, float u0) {
      	float tmp;
      	if ((1.0f - u0) <= 0.9998499751091003f) {
      		tmp = (-alpha * alpha) * logf((1.0f - u0));
      	} else {
      		tmp = (u0 * alpha) * alpha;
      	}
      	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.9998499751091003e0) then
              tmp = (-alpha * alpha) * log((1.0e0 - u0))
          else
              tmp = (u0 * alpha) * alpha
          end if
          code = tmp
      end function
      
      function code(alpha, u0)
      	tmp = Float32(0.0)
      	if (Float32(Float32(1.0) - u0) <= Float32(0.9998499751091003))
      		tmp = Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)));
      	else
      		tmp = Float32(Float32(u0 * alpha) * alpha);
      	end
      	return tmp
      end
      
      function tmp_2 = code(alpha, u0)
      	tmp = single(0.0);
      	if ((single(1.0) - u0) <= single(0.9998499751091003))
      		tmp = (-alpha * alpha) * log((single(1.0) - u0));
      	else
      		tmp = (u0 * alpha) * alpha;
      	end
      	tmp_2 = tmp;
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;1 - u0 \leq 0.9998499751091003:\\
      \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(u0 \cdot \alpha\right) \cdot \alpha\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (-.f32 #s(literal 1 binary32) u0) < 0.999849975

        1. Initial program 87.6%

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

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

        1. Initial program 33.4%

          \[\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-*.f3291.8

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

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

            \[\leadsto \left(u0 \cdot \alpha\right) \cdot \color{blue}{\alpha} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 4: 74.8% accurate, 10.5× speedup?

        \[\begin{array}{l} \\ \left(u0 \cdot \alpha\right) \cdot \alpha \end{array} \]
        (FPCore (alpha u0) :precision binary32 (* (* u0 alpha) alpha))
        float code(float alpha, float u0) {
        	return (u0 * alpha) * alpha;
        }
        
        real(4) function code(alpha, u0)
            real(4), intent (in) :: alpha
            real(4), intent (in) :: u0
            code = (u0 * alpha) * alpha
        end function
        
        function code(alpha, u0)
        	return Float32(Float32(u0 * alpha) * alpha)
        end
        
        function tmp = code(alpha, u0)
        	tmp = (u0 * alpha) * alpha;
        end
        
        \begin{array}{l}
        
        \\
        \left(u0 \cdot \alpha\right) \cdot \alpha
        \end{array}
        
        Derivation
        1. Initial program 53.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-*.f3276.4

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

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

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

          Alternative 5: 74.7% 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 53.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-*.f3276.4

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

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

          Reproduce

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