Average Error: 14.2 → 0.5
Time: 9.5s
Precision: binary32
\[0.0001 \leq \alpha \land \alpha \leq 1 \land 2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\]
\[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\]
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9592684507369995:\\ \;\;\;\;\log \left(1 - u0\right) \cdot \left(\alpha \cdot \left(-\alpha\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(u0 \cdot \alpha + \left(0.25 \cdot \left(\alpha \cdot {u0}^{4}\right) + \left(0.5 \cdot \left(\alpha \cdot {u0}^{2}\right) + 0.3333333333333333 \cdot \left(\alpha \cdot {u0}^{3}\right)\right)\right)\right)\\ \end{array}\]
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\begin{array}{l}
\mathbf{if}\;1 - u0 \leq 0.9592684507369995:\\
\;\;\;\;\log \left(1 - u0\right) \cdot \left(\alpha \cdot \left(-\alpha\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\alpha \cdot \left(u0 \cdot \alpha + \left(0.25 \cdot \left(\alpha \cdot {u0}^{4}\right) + \left(0.5 \cdot \left(\alpha \cdot {u0}^{2}\right) + 0.3333333333333333 \cdot \left(\alpha \cdot {u0}^{3}\right)\right)\right)\right)\\

\end{array}
(FPCore (alpha u0)
 :precision binary32
 (* (* (- alpha) alpha) (log (- 1.0 u0))))
(FPCore (alpha u0)
 :precision binary32
 (if (<= (- 1.0 u0) 0.9592684507369995)
   (* (log (- 1.0 u0)) (* alpha (- alpha)))
   (*
    alpha
    (+
     (* u0 alpha)
     (+
      (* 0.25 (* alpha (pow u0 4.0)))
      (+
       (* 0.5 (* alpha (pow u0 2.0)))
       (* 0.3333333333333333 (* alpha (pow u0 3.0)))))))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf(1.0f - u0);
}
float code(float alpha, float u0) {
	float tmp;
	if ((1.0f - u0) <= 0.9592684507369995f) {
		tmp = logf(1.0f - u0) * (alpha * -alpha);
	} else {
		tmp = alpha * ((u0 * alpha) + ((0.25f * (alpha * powf(u0, 4.0f))) + ((0.5f * (alpha * powf(u0, 2.0f))) + (0.3333333333333333f * (alpha * powf(u0, 3.0f))))));
	}
	return tmp;
}

Error

Bits error versus alpha

Bits error versus u0

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (-.f32 1 u0) < 0.959268451

    1. Initial program 1.0

      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)\]
    2. Using strategy rm
    3. Applied *-commutative_binary321.0

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

    if 0.959268451 < (-.f32 1 u0)

    1. Initial program 16.5

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

      \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \color{blue}{\left(-\left(u0 + \left(0.25 \cdot {u0}^{4} + \left(0.5 \cdot {u0}^{2} + 0.3333333333333333 \cdot {u0}^{3}\right)\right)\right)\right)}\]
    3. Simplified0.4

      \[\leadsto \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \color{blue}{\left({u0}^{4} \cdot -0.25 - \left(u0 + \left(u0 \cdot u0\right) \cdot \left(0.5 + u0 \cdot 0.3333333333333333\right)\right)\right)}\]
    4. Using strategy rm
    5. Applied associate-*l*_binary320.4

      \[\leadsto \color{blue}{\left(-\alpha\right) \cdot \left(\alpha \cdot \left({u0}^{4} \cdot -0.25 - \left(u0 + \left(u0 \cdot u0\right) \cdot \left(0.5 + u0 \cdot 0.3333333333333333\right)\right)\right)\right)}\]
    6. Simplified0.5

      \[\leadsto \left(-\alpha\right) \cdot \color{blue}{\left(\alpha \cdot \left(u0 \cdot \left(-1 - u0 \cdot \left(0.3333333333333333 \cdot u0 + 0.5\right)\right) + {u0}^{4} \cdot -0.25\right)\right)}\]
    7. Taylor expanded around 0 0.4

      \[\leadsto \left(-\alpha\right) \cdot \color{blue}{\left(-\left(\alpha \cdot u0 + \left(0.25 \cdot \left(\alpha \cdot {u0}^{4}\right) + \left(0.5 \cdot \left(\alpha \cdot {u0}^{2}\right) + 0.3333333333333333 \cdot \left(\alpha \cdot {u0}^{3}\right)\right)\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9592684507369995:\\ \;\;\;\;\log \left(1 - u0\right) \cdot \left(\alpha \cdot \left(-\alpha\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(u0 \cdot \alpha + \left(0.25 \cdot \left(\alpha \cdot {u0}^{4}\right) + \left(0.5 \cdot \left(\alpha \cdot {u0}^{2}\right) + 0.3333333333333333 \cdot \left(\alpha \cdot {u0}^{3}\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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