Beckmann Distribution sample, tan2theta, alphax == alphay

Percentage Accurate: 55.6% → 99.0%
Time: 3.5s
Alternatives: 10
Speedup: 1.8×

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)\]
\[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
(FPCore (alpha u0)
  :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))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf((1.0f - u0));
}
real(4) function code(alpha, u0)
use fmin_fmax_functions
    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
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 55.6% accurate, 1.0× speedup?

\[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
\[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
(FPCore (alpha u0)
  :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))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf((1.0f - u0));
}
real(4) function code(alpha, u0)
use fmin_fmax_functions
    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
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)

Alternative 1: 99.0% accurate, 0.9× speedup?

\[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
\[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \mathsf{log1p}\left(-u0\right) \]
(FPCore (alpha u0)
  :precision binary32
  :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
     (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
  (* (* (- alpha) alpha) (log1p (- u0))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * log1pf(-u0);
}
function code(alpha, u0)
	return Float32(Float32(Float32(-alpha) * alpha) * log1p(Float32(-u0)))
end
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \mathsf{log1p}\left(-u0\right)
Derivation
  1. Initial program 55.6%

    \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
  2. Step-by-step derivation
    1. Applied rewrites99.0%

      \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \mathsf{log1p}\left(-u0\right) \]
    2. Add Preprocessing

    Alternative 2: 99.0% accurate, 0.9× speedup?

    \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
    \[-\left(\mathsf{log1p}\left(-u0\right) \cdot \alpha\right) \cdot \alpha \]
    (FPCore (alpha u0)
      :precision binary32
      :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
         (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
      (- (* (* (log1p (- u0)) alpha) alpha)))
    float code(float alpha, float u0) {
    	return -((log1pf(-u0) * alpha) * alpha);
    }
    
    function code(alpha, u0)
    	return Float32(-Float32(Float32(log1p(Float32(-u0)) * alpha) * alpha))
    end
    
    -\left(\mathsf{log1p}\left(-u0\right) \cdot \alpha\right) \cdot \alpha
    
    Derivation
    1. Initial program 55.6%

      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
    2. Step-by-step derivation
      1. Applied rewrites55.6%

        \[\leadsto -\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha \]
      2. Step-by-step derivation
        1. Applied rewrites99.0%

          \[\leadsto -\left(\mathsf{log1p}\left(-u0\right) \cdot \alpha\right) \cdot \alpha \]
        2. Add Preprocessing

        Alternative 3: 97.1% accurate, 0.8× speedup?

        \[\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} \mathbf{if}\;u0 \leq 0.003907772712409496:\\ \;\;\;\;\frac{\alpha \cdot \alpha}{\frac{1 + -0.5 \cdot u0}{u0}}\\ \mathbf{else}:\\ \;\;\;\;-\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha\\ \end{array} \]
        (FPCore (alpha u0)
          :precision binary32
          :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
             (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
          (if (<= u0 0.003907772712409496)
          (/ (* alpha alpha) (/ (+ 1.0 (* -0.5 u0)) u0))
          (- (* (* (log (- 1.0 u0)) alpha) alpha))))
        float code(float alpha, float u0) {
        	float tmp;
        	if (u0 <= 0.003907772712409496f) {
        		tmp = (alpha * alpha) / ((1.0f + (-0.5f * u0)) / u0);
        	} else {
        		tmp = -((logf((1.0f - u0)) * alpha) * alpha);
        	}
        	return tmp;
        }
        
        real(4) function code(alpha, u0)
        use fmin_fmax_functions
            real(4), intent (in) :: alpha
            real(4), intent (in) :: u0
            real(4) :: tmp
            if (u0 <= 0.003907772712409496e0) then
                tmp = (alpha * alpha) / ((1.0e0 + ((-0.5e0) * u0)) / u0)
            else
                tmp = -((log((1.0e0 - u0)) * alpha) * alpha)
            end if
            code = tmp
        end function
        
        function code(alpha, u0)
        	tmp = Float32(0.0)
        	if (u0 <= Float32(0.003907772712409496))
        		tmp = Float32(Float32(alpha * alpha) / Float32(Float32(Float32(1.0) + Float32(Float32(-0.5) * u0)) / u0));
        	else
        		tmp = Float32(-Float32(Float32(log(Float32(Float32(1.0) - u0)) * alpha) * alpha));
        	end
        	return tmp
        end
        
        function tmp_2 = code(alpha, u0)
        	tmp = single(0.0);
        	if (u0 <= single(0.003907772712409496))
        		tmp = (alpha * alpha) / ((single(1.0) + (single(-0.5) * u0)) / u0);
        	else
        		tmp = -((log((single(1.0) - u0)) * alpha) * alpha);
        	end
        	tmp_2 = tmp;
        end
        
        \begin{array}{l}
        \mathbf{if}\;u0 \leq 0.003907772712409496:\\
        \;\;\;\;\frac{\alpha \cdot \alpha}{\frac{1 + -0.5 \cdot u0}{u0}}\\
        
        \mathbf{else}:\\
        \;\;\;\;-\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if u0 < 0.00390777271

          1. Initial program 55.6%

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

            \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(u0 \cdot \left(\frac{-1}{2} \cdot u0 - 1\right)\right) \]
          3. Step-by-step derivation
            1. Applied rewrites87.0%

              \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(u0 \cdot \left(-0.5 \cdot u0 - 1\right)\right) \]
            2. Step-by-step derivation
              1. Applied rewrites87.0%

                \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(\mathsf{fma}\left(-0.5, u0, -1\right) \cdot u0\right) \]
              2. Step-by-step derivation
                1. Applied rewrites86.9%

                  \[\leadsto \frac{\alpha \cdot \alpha}{\frac{-1}{\mathsf{fma}\left(-0.5, u0, -1\right) \cdot u0}} \]
                2. Taylor expanded in u0 around 0

                  \[\leadsto \frac{\alpha \cdot \alpha}{\frac{1 + \frac{-1}{2} \cdot u0}{u0}} \]
                3. Step-by-step derivation
                  1. Applied rewrites88.9%

                    \[\leadsto \frac{\alpha \cdot \alpha}{\frac{1 + -0.5 \cdot u0}{u0}} \]

                  if 0.00390777271 < u0

                  1. Initial program 55.6%

                    \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                  2. Step-by-step derivation
                    1. Applied rewrites55.6%

                      \[\leadsto -\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 4: 96.8% accurate, 0.8× speedup?

                  \[\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} \mathbf{if}\;u0 \leq 0.0029454126488417387:\\ \;\;\;\;u0 \cdot \left(\alpha \cdot \left(\alpha + 0.5 \cdot \left(\alpha \cdot u0\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha\\ \end{array} \]
                  (FPCore (alpha u0)
                    :precision binary32
                    :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                       (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                    (if (<= u0 0.0029454126488417387)
                    (* u0 (* alpha (+ alpha (* 0.5 (* alpha u0)))))
                    (- (* (* (log (- 1.0 u0)) alpha) alpha))))
                  float code(float alpha, float u0) {
                  	float tmp;
                  	if (u0 <= 0.0029454126488417387f) {
                  		tmp = u0 * (alpha * (alpha + (0.5f * (alpha * u0))));
                  	} else {
                  		tmp = -((logf((1.0f - u0)) * alpha) * alpha);
                  	}
                  	return tmp;
                  }
                  
                  real(4) function code(alpha, u0)
                  use fmin_fmax_functions
                      real(4), intent (in) :: alpha
                      real(4), intent (in) :: u0
                      real(4) :: tmp
                      if (u0 <= 0.0029454126488417387e0) then
                          tmp = u0 * (alpha * (alpha + (0.5e0 * (alpha * u0))))
                      else
                          tmp = -((log((1.0e0 - u0)) * alpha) * alpha)
                      end if
                      code = tmp
                  end function
                  
                  function code(alpha, u0)
                  	tmp = Float32(0.0)
                  	if (u0 <= Float32(0.0029454126488417387))
                  		tmp = Float32(u0 * Float32(alpha * Float32(alpha + Float32(Float32(0.5) * Float32(alpha * u0)))));
                  	else
                  		tmp = Float32(-Float32(Float32(log(Float32(Float32(1.0) - u0)) * alpha) * alpha));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(alpha, u0)
                  	tmp = single(0.0);
                  	if (u0 <= single(0.0029454126488417387))
                  		tmp = u0 * (alpha * (alpha + (single(0.5) * (alpha * u0))));
                  	else
                  		tmp = -((log((single(1.0) - u0)) * alpha) * alpha);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  \begin{array}{l}
                  \mathbf{if}\;u0 \leq 0.0029454126488417387:\\
                  \;\;\;\;u0 \cdot \left(\alpha \cdot \left(\alpha + 0.5 \cdot \left(\alpha \cdot u0\right)\right)\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;-\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if u0 < 0.00294541265

                    1. Initial program 55.6%

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

                      \[\leadsto u0 \cdot \left(\frac{1}{2} \cdot \left({\alpha}^{2} \cdot u0\right) + {\alpha}^{2}\right) \]
                    3. Step-by-step derivation
                      1. Applied rewrites87.2%

                        \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, {\alpha}^{2} \cdot u0, {\alpha}^{2}\right) \]
                      2. Step-by-step derivation
                        1. Applied rewrites87.0%

                          \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, \frac{1}{{\alpha}^{-2}} \cdot u0, \frac{1}{{\alpha}^{-2}}\right) \]
                        2. Step-by-step derivation
                          1. Applied rewrites87.1%

                            \[\leadsto u0 \cdot \left(\alpha \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot \alpha\right)\right) \]
                          2. Taylor expanded in u0 around 0

                            \[\leadsto u0 \cdot \left(\alpha \cdot \left(\alpha + \frac{1}{2} \cdot \left(\alpha \cdot u0\right)\right)\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites87.2%

                              \[\leadsto u0 \cdot \left(\alpha \cdot \left(\alpha + 0.5 \cdot \left(\alpha \cdot u0\right)\right)\right) \]

                            if 0.00294541265 < u0

                            1. Initial program 55.6%

                              \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
                            2. Step-by-step derivation
                              1. Applied rewrites55.6%

                                \[\leadsto -\left(\log \left(1 - u0\right) \cdot \alpha\right) \cdot \alpha \]
                            3. Recombined 2 regimes into one program.
                            4. Add Preprocessing

                            Alternative 5: 87.2% accurate, 1.1× speedup?

                            \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
                            \[u0 \cdot \left(\alpha \cdot \left(\alpha + 0.5 \cdot \left(\alpha \cdot u0\right)\right)\right) \]
                            (FPCore (alpha u0)
                              :precision binary32
                              :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                                 (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                              (* u0 (* alpha (+ alpha (* 0.5 (* alpha u0))))))
                            float code(float alpha, float u0) {
                            	return u0 * (alpha * (alpha + (0.5f * (alpha * u0))));
                            }
                            
                            real(4) function code(alpha, u0)
                            use fmin_fmax_functions
                                real(4), intent (in) :: alpha
                                real(4), intent (in) :: u0
                                code = u0 * (alpha * (alpha + (0.5e0 * (alpha * u0))))
                            end function
                            
                            function code(alpha, u0)
                            	return Float32(u0 * Float32(alpha * Float32(alpha + Float32(Float32(0.5) * Float32(alpha * u0)))))
                            end
                            
                            function tmp = code(alpha, u0)
                            	tmp = u0 * (alpha * (alpha + (single(0.5) * (alpha * u0))));
                            end
                            
                            u0 \cdot \left(\alpha \cdot \left(\alpha + 0.5 \cdot \left(\alpha \cdot u0\right)\right)\right)
                            
                            Derivation
                            1. Initial program 55.6%

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

                              \[\leadsto u0 \cdot \left(\frac{1}{2} \cdot \left({\alpha}^{2} \cdot u0\right) + {\alpha}^{2}\right) \]
                            3. Step-by-step derivation
                              1. Applied rewrites87.2%

                                \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, {\alpha}^{2} \cdot u0, {\alpha}^{2}\right) \]
                              2. Step-by-step derivation
                                1. Applied rewrites87.0%

                                  \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, \frac{1}{{\alpha}^{-2}} \cdot u0, \frac{1}{{\alpha}^{-2}}\right) \]
                                2. Step-by-step derivation
                                  1. Applied rewrites87.1%

                                    \[\leadsto u0 \cdot \left(\alpha \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot \alpha\right)\right) \]
                                  2. Taylor expanded in u0 around 0

                                    \[\leadsto u0 \cdot \left(\alpha \cdot \left(\alpha + \frac{1}{2} \cdot \left(\alpha \cdot u0\right)\right)\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites87.2%

                                      \[\leadsto u0 \cdot \left(\alpha \cdot \left(\alpha + 0.5 \cdot \left(\alpha \cdot u0\right)\right)\right) \]
                                    2. Add Preprocessing

                                    Alternative 6: 87.2% accurate, 1.1× speedup?

                                    \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
                                    \[\left(\alpha \cdot \alpha\right) \cdot \mathsf{fma}\left(u0, 0.5 \cdot u0, u0\right) \]
                                    (FPCore (alpha u0)
                                      :precision binary32
                                      :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                                         (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                                      (* (* alpha alpha) (fma u0 (* 0.5 u0) u0)))
                                    float code(float alpha, float u0) {
                                    	return (alpha * alpha) * fmaf(u0, (0.5f * u0), u0);
                                    }
                                    
                                    function code(alpha, u0)
                                    	return Float32(Float32(alpha * alpha) * fma(u0, Float32(Float32(0.5) * u0), u0))
                                    end
                                    
                                    \left(\alpha \cdot \alpha\right) \cdot \mathsf{fma}\left(u0, 0.5 \cdot u0, u0\right)
                                    
                                    Derivation
                                    1. Initial program 55.6%

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

                                      \[\leadsto u0 \cdot \left(\frac{1}{2} \cdot \left({\alpha}^{2} \cdot u0\right) + {\alpha}^{2}\right) \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites87.2%

                                        \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, {\alpha}^{2} \cdot u0, {\alpha}^{2}\right) \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites87.3%

                                          \[\leadsto \mathsf{fma}\left(u0, \alpha \cdot \alpha, \left(\left(0.5 \cdot \left(\alpha \cdot \alpha\right)\right) \cdot u0\right) \cdot u0\right) \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites87.0%

                                            \[\leadsto \left(\alpha \cdot \alpha\right) \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot u0\right) \]
                                          2. Step-by-step derivation
                                            1. Applied rewrites87.2%

                                              \[\leadsto \left(\alpha \cdot \alpha\right) \cdot \mathsf{fma}\left(u0, 0.5 \cdot u0, u0\right) \]
                                            2. Add Preprocessing

                                            Alternative 7: 87.1% accurate, 1.1× speedup?

                                            \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
                                            \[\left(\alpha \cdot \alpha\right) \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot u0\right) \]
                                            (FPCore (alpha u0)
                                              :precision binary32
                                              :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                                                 (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                                              (* (* alpha alpha) (* (fma 0.5 u0 1.0) u0)))
                                            float code(float alpha, float u0) {
                                            	return (alpha * alpha) * (fmaf(0.5f, u0, 1.0f) * u0);
                                            }
                                            
                                            function code(alpha, u0)
                                            	return Float32(Float32(alpha * alpha) * Float32(fma(Float32(0.5), u0, Float32(1.0)) * u0))
                                            end
                                            
                                            \left(\alpha \cdot \alpha\right) \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot u0\right)
                                            
                                            Derivation
                                            1. Initial program 55.6%

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

                                              \[\leadsto u0 \cdot \left(\frac{1}{2} \cdot \left({\alpha}^{2} \cdot u0\right) + {\alpha}^{2}\right) \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites87.2%

                                                \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, {\alpha}^{2} \cdot u0, {\alpha}^{2}\right) \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites87.3%

                                                  \[\leadsto \mathsf{fma}\left(u0, \alpha \cdot \alpha, \left(\left(0.5 \cdot \left(\alpha \cdot \alpha\right)\right) \cdot u0\right) \cdot u0\right) \]
                                                2. Step-by-step derivation
                                                  1. Applied rewrites87.0%

                                                    \[\leadsto \left(\alpha \cdot \alpha\right) \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot u0\right) \]
                                                  2. Add Preprocessing

                                                  Alternative 8: 87.0% accurate, 1.1× speedup?

                                                  \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
                                                  \[u0 \cdot \left(\alpha \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot \alpha\right)\right) \]
                                                  (FPCore (alpha u0)
                                                    :precision binary32
                                                    :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                                                       (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                                                    (* u0 (* alpha (* (fma 0.5 u0 1.0) alpha))))
                                                  float code(float alpha, float u0) {
                                                  	return u0 * (alpha * (fmaf(0.5f, u0, 1.0f) * alpha));
                                                  }
                                                  
                                                  function code(alpha, u0)
                                                  	return Float32(u0 * Float32(alpha * Float32(fma(Float32(0.5), u0, Float32(1.0)) * alpha)))
                                                  end
                                                  
                                                  u0 \cdot \left(\alpha \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot \alpha\right)\right)
                                                  
                                                  Derivation
                                                  1. Initial program 55.6%

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

                                                    \[\leadsto u0 \cdot \left(\frac{1}{2} \cdot \left({\alpha}^{2} \cdot u0\right) + {\alpha}^{2}\right) \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites87.2%

                                                      \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, {\alpha}^{2} \cdot u0, {\alpha}^{2}\right) \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites87.0%

                                                        \[\leadsto u0 \cdot \mathsf{fma}\left(0.5, \frac{1}{{\alpha}^{-2}} \cdot u0, \frac{1}{{\alpha}^{-2}}\right) \]
                                                      2. Step-by-step derivation
                                                        1. Applied rewrites87.1%

                                                          \[\leadsto u0 \cdot \left(\alpha \cdot \left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot \alpha\right)\right) \]
                                                        2. Add Preprocessing

                                                        Alternative 9: 74.5% accurate, 1.8× speedup?

                                                        \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
                                                        \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-u0\right) \]
                                                        (FPCore (alpha u0)
                                                          :precision binary32
                                                          :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                                                             (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                                                          (* (* (- alpha) alpha) (- u0)))
                                                        float code(float alpha, float u0) {
                                                        	return (-alpha * alpha) * -u0;
                                                        }
                                                        
                                                        real(4) function code(alpha, u0)
                                                        use fmin_fmax_functions
                                                            real(4), intent (in) :: alpha
                                                            real(4), intent (in) :: u0
                                                            code = (-alpha * alpha) * -u0
                                                        end function
                                                        
                                                        function code(alpha, u0)
                                                        	return Float32(Float32(Float32(-alpha) * alpha) * Float32(-u0))
                                                        end
                                                        
                                                        function tmp = code(alpha, u0)
                                                        	tmp = (-alpha * alpha) * -u0;
                                                        end
                                                        
                                                        \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-u0\right)
                                                        
                                                        Derivation
                                                        1. Initial program 55.6%

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

                                                          \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-1 \cdot u0\right) \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites74.5%

                                                            \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-1 \cdot u0\right) \]
                                                          2. Step-by-step derivation
                                                            1. Applied rewrites74.5%

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

                                                            Alternative 10: 74.5% accurate, 1.8× speedup?

                                                            \[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
                                                            \[-\alpha \cdot \left(\left(-u0\right) \cdot \alpha\right) \]
                                                            (FPCore (alpha u0)
                                                              :precision binary32
                                                              :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0))
                                                                 (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
                                                              (- (* alpha (* (- u0) alpha))))
                                                            float code(float alpha, float u0) {
                                                            	return -(alpha * (-u0 * alpha));
                                                            }
                                                            
                                                            real(4) function code(alpha, u0)
                                                            use fmin_fmax_functions
                                                                real(4), intent (in) :: alpha
                                                                real(4), intent (in) :: u0
                                                                code = -(alpha * (-u0 * alpha))
                                                            end function
                                                            
                                                            function code(alpha, u0)
                                                            	return Float32(-Float32(alpha * Float32(Float32(-u0) * alpha)))
                                                            end
                                                            
                                                            function tmp = code(alpha, u0)
                                                            	tmp = -(alpha * (-u0 * alpha));
                                                            end
                                                            
                                                            -\alpha \cdot \left(\left(-u0\right) \cdot \alpha\right)
                                                            
                                                            Derivation
                                                            1. Initial program 55.6%

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

                                                              \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-1 \cdot u0\right) \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites74.5%

                                                                \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-1 \cdot u0\right) \]
                                                              2. Step-by-step derivation
                                                                1. Applied rewrites74.5%

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

                                                                Reproduce

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