Beckmann Distribution sample, tan2theta, alphax == alphay

Percentage Accurate: 55.3% → 74.9%
Time: 6.9s
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.3% 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: 74.9% 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 56.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-*.f3275.0

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

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

Alternative 2: 63.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9987499713897705:\\ \;\;\;\;\log \left(1 - u0\right) \cdot \frac{{\alpha}^{3}}{-\alpha}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\ \end{array} \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (if (<= (- 1.0 u0) 0.9987499713897705)
   (* (log (- 1.0 u0)) (/ (pow alpha 3.0) (- alpha)))
   (/
    (*
     (-
      (* (* (fma (fma -0.25 u0 -0.3333333333333333) u0 -0.5) alpha) u0)
      alpha)
     u0)
    (/ -1.0 alpha))))
float code(float alpha, float u0) {
	float tmp;
	if ((1.0f - u0) <= 0.9987499713897705f) {
		tmp = logf((1.0f - u0)) * (powf(alpha, 3.0f) / -alpha);
	} else {
		tmp = ((((fmaf(fmaf(-0.25f, u0, -0.3333333333333333f), u0, -0.5f) * alpha) * u0) - alpha) * u0) / (-1.0f / alpha);
	}
	return tmp;
}
function code(alpha, u0)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - u0) <= Float32(0.9987499713897705))
		tmp = Float32(log(Float32(Float32(1.0) - u0)) * Float32((alpha ^ Float32(3.0)) / Float32(-alpha)));
	else
		tmp = Float32(Float32(Float32(Float32(Float32(fma(fma(Float32(-0.25), u0, Float32(-0.3333333333333333)), u0, Float32(-0.5)) * alpha) * u0) - alpha) * u0) / Float32(Float32(-1.0) / alpha));
	end
	return tmp
end
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\


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

    1. Initial program 90.1%

      \[\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-*.f3290.1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 43.3%

      \[\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-*.f3243.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 rewrites43.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
    5. Taylor expanded in u0 around 0

      \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(-1 \cdot u0\right)} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(\mathsf{neg}\left(u0\right)\right)} \]
      2. lower-neg.f3285.9

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot \left(-u0\right)}{\color{blue}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha} \cdot \frac{1}{\alpha}}} \]
      9. times-fracN/A

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

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

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(-u0\right)}{\frac{1}{\alpha}}}}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha}} \]
      12. *-lft-identityN/A

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

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

      \[\leadsto \color{blue}{\frac{\left(-u0\right) \cdot \alpha}{\frac{-1}{\alpha}}} \]
    10. Taylor expanded in u0 around 0

      \[\leadsto \frac{\color{blue}{u0 \cdot \left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right)}}{\frac{-1}{\alpha}} \]
    11. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right) \cdot u0}}{\frac{-1}{\alpha}} \]
    12. Applied rewrites97.9%

      \[\leadsto \frac{\color{blue}{\left(\left(\alpha \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right)\right) \cdot u0 - \alpha\right) \cdot u0}}{\frac{-1}{\alpha}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9987499713897705:\\ \;\;\;\;\log \left(1 - u0\right) \cdot \frac{{\alpha}^{3}}{-\alpha}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 63.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u0 \leq 0.0012499999720603228:\\ \;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}{\alpha} \cdot \log \left(1 - u0\right)\\ \end{array} \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (if (<= u0 0.0012499999720603228)
   (/
    (*
     (-
      (* (* (fma (fma -0.25 u0 -0.3333333333333333) u0 -0.5) alpha) u0)
      alpha)
     u0)
    (/ -1.0 alpha))
   (* (/ (* (* (- alpha) alpha) alpha) alpha) (log (- 1.0 u0)))))
float code(float alpha, float u0) {
	float tmp;
	if (u0 <= 0.0012499999720603228f) {
		tmp = ((((fmaf(fmaf(-0.25f, u0, -0.3333333333333333f), u0, -0.5f) * alpha) * u0) - alpha) * u0) / (-1.0f / alpha);
	} else {
		tmp = (((-alpha * alpha) * alpha) / alpha) * logf((1.0f - u0));
	}
	return tmp;
}
function code(alpha, u0)
	tmp = Float32(0.0)
	if (u0 <= Float32(0.0012499999720603228))
		tmp = Float32(Float32(Float32(Float32(Float32(fma(fma(Float32(-0.25), u0, Float32(-0.3333333333333333)), u0, Float32(-0.5)) * alpha) * u0) - alpha) * u0) / Float32(Float32(-1.0) / alpha));
	else
		tmp = Float32(Float32(Float32(Float32(Float32(-alpha) * alpha) * alpha) / alpha) * log(Float32(Float32(1.0) - u0)));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;u0 \leq 0.0012499999720603228:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}{\alpha} \cdot \log \left(1 - u0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if u0 < 0.00124999997

    1. Initial program 43.3%

      \[\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-*.f3243.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 rewrites43.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
    5. Taylor expanded in u0 around 0

      \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(-1 \cdot u0\right)} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(\mathsf{neg}\left(u0\right)\right)} \]
      2. lower-neg.f3285.9

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot \left(-u0\right)}{\color{blue}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha} \cdot \frac{1}{\alpha}}} \]
      9. times-fracN/A

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

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

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(-u0\right)}{\frac{1}{\alpha}}}}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha}} \]
      12. *-lft-identityN/A

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

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

      \[\leadsto \color{blue}{\frac{\left(-u0\right) \cdot \alpha}{\frac{-1}{\alpha}}} \]
    10. Taylor expanded in u0 around 0

      \[\leadsto \frac{\color{blue}{u0 \cdot \left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right)}}{\frac{-1}{\alpha}} \]
    11. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right) \cdot u0}}{\frac{-1}{\alpha}} \]
    12. Applied rewrites97.9%

      \[\leadsto \frac{\color{blue}{\left(\left(\alpha \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right)\right) \cdot u0 - \alpha\right) \cdot u0}}{\frac{-1}{\alpha}} \]

    if 0.00124999997 < u0

    1. Initial program 90.1%

      \[\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. lower-/.f32N/A

        \[\leadsto \color{blue}{\frac{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}{\alpha}} \cdot \log \left(1 - u0\right) \]
      13. lower-*.f3290.2

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

      \[\leadsto \color{blue}{\frac{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}{\alpha}} \cdot \log \left(1 - u0\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;u0 \leq 0.0012499999720603228:\\ \;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}{\alpha} \cdot \log \left(1 - u0\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 63.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u0 \leq 0.0012499999720603228:\\ \;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\ \end{array} \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (if (<= u0 0.0012499999720603228)
   (/
    (*
     (-
      (* (* (fma (fma -0.25 u0 -0.3333333333333333) u0 -0.5) alpha) u0)
      alpha)
     u0)
    (/ -1.0 alpha))
   (* (* (- alpha) alpha) (log (- 1.0 u0)))))
float code(float alpha, float u0) {
	float tmp;
	if (u0 <= 0.0012499999720603228f) {
		tmp = ((((fmaf(fmaf(-0.25f, u0, -0.3333333333333333f), u0, -0.5f) * alpha) * u0) - alpha) * u0) / (-1.0f / alpha);
	} else {
		tmp = (-alpha * alpha) * logf((1.0f - u0));
	}
	return tmp;
}
function code(alpha, u0)
	tmp = Float32(0.0)
	if (u0 <= Float32(0.0012499999720603228))
		tmp = Float32(Float32(Float32(Float32(Float32(fma(fma(Float32(-0.25), u0, Float32(-0.3333333333333333)), u0, Float32(-0.5)) * alpha) * u0) - alpha) * u0) / Float32(Float32(-1.0) / alpha));
	else
		tmp = Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;u0 \leq 0.0012499999720603228:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if u0 < 0.00124999997

    1. Initial program 43.3%

      \[\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-*.f3243.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 rewrites43.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
    5. Taylor expanded in u0 around 0

      \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(-1 \cdot u0\right)} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(\mathsf{neg}\left(u0\right)\right)} \]
      2. lower-neg.f3285.9

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot \left(-u0\right)}{\color{blue}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha} \cdot \frac{1}{\alpha}}} \]
      9. times-fracN/A

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

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

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(-u0\right)}{\frac{1}{\alpha}}}}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha}} \]
      12. *-lft-identityN/A

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

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

      \[\leadsto \color{blue}{\frac{\left(-u0\right) \cdot \alpha}{\frac{-1}{\alpha}}} \]
    10. Taylor expanded in u0 around 0

      \[\leadsto \frac{\color{blue}{u0 \cdot \left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right)}}{\frac{-1}{\alpha}} \]
    11. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right) \cdot u0}}{\frac{-1}{\alpha}} \]
    12. Applied rewrites97.9%

      \[\leadsto \frac{\color{blue}{\left(\left(\alpha \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right)\right) \cdot u0 - \alpha\right) \cdot u0}}{\frac{-1}{\alpha}} \]

    if 0.00124999997 < u0

    1. Initial program 90.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;u0 \leq 0.0012499999720603228:\\ \;\;\;\;\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 44.4% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}} \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (/
  (*
   (- (* (* (fma (fma -0.25 u0 -0.3333333333333333) u0 -0.5) alpha) u0) alpha)
   u0)
  (/ -1.0 alpha)))
float code(float alpha, float u0) {
	return ((((fmaf(fmaf(-0.25f, u0, -0.3333333333333333f), u0, -0.5f) * alpha) * u0) - alpha) * u0) / (-1.0f / alpha);
}
function code(alpha, u0)
	return Float32(Float32(Float32(Float32(Float32(fma(fma(Float32(-0.25), u0, Float32(-0.3333333333333333)), u0, Float32(-0.5)) * alpha) * u0) - alpha) * u0) / Float32(Float32(-1.0) / alpha))
end
\begin{array}{l}

\\
\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}}
\end{array}
Derivation
  1. Initial program 56.3%

    \[\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-*.f3256.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 rewrites56.3%

    \[\leadsto \color{blue}{\frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}}} \cdot \log \left(1 - u0\right) \]
  5. Taylor expanded in u0 around 0

    \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(-1 \cdot u0\right)} \]
  6. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(\mathsf{neg}\left(u0\right)\right)} \]
    2. lower-neg.f3274.8

      \[\leadsto \frac{1}{\frac{\alpha}{\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \alpha}} \cdot \color{blue}{\left(-u0\right)} \]
  7. Applied rewrites74.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1 \cdot \left(-u0\right)}{\color{blue}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha} \cdot \frac{1}{\alpha}}} \]
    9. times-fracN/A

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

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(-u0\right)}{\frac{1}{\alpha}}}}{\frac{\alpha}{\left(-\alpha\right) \cdot \alpha}} \]
    12. *-lft-identityN/A

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

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

    \[\leadsto \color{blue}{\frac{\left(-u0\right) \cdot \alpha}{\frac{-1}{\alpha}}} \]
  10. Taylor expanded in u0 around 0

    \[\leadsto \frac{\color{blue}{u0 \cdot \left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right)}}{\frac{-1}{\alpha}} \]
  11. Step-by-step derivation
    1. *-commutativeN/A

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

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot \alpha + u0 \cdot \left(\frac{-1}{2} \cdot \alpha + u0 \cdot \left(\frac{-1}{3} \cdot \alpha + \frac{-1}{4} \cdot \left(\alpha \cdot u0\right)\right)\right)\right) \cdot u0}}{\frac{-1}{\alpha}} \]
  12. Applied rewrites88.6%

    \[\leadsto \frac{\color{blue}{\left(\left(\alpha \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right)\right) \cdot u0 - \alpha\right) \cdot u0}}{\frac{-1}{\alpha}} \]
  13. Final simplification88.9%

    \[\leadsto \frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, u0, -0.3333333333333333\right), u0, -0.5\right) \cdot \alpha\right) \cdot u0 - \alpha\right) \cdot u0}{\frac{-1}{\alpha}} \]
  14. Add Preprocessing

Reproduce

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