Average Error: 14.1 → 0.3
Time: 4.5s
Precision: binary32
\[\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) \]
\[\alpha \cdot \left(\left(-\alpha\right) \cdot \mathsf{log1p}\left(-u0\right)\right) \]
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\alpha \cdot \left(\left(-\alpha\right) \cdot \mathsf{log1p}\left(-u0\right)\right)
(FPCore (alpha u0)
 :precision binary32
 (* (* (- alpha) alpha) (log (- 1.0 u0))))
(FPCore (alpha u0) :precision binary32 (* alpha (* (- alpha) (log1p (- u0)))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf(1.0f - u0);
}
float code(float alpha, float u0) {
	return alpha * (-alpha * log1pf(-u0));
}

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. Initial program 14.1

    \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
  2. Simplified0.3

    \[\leadsto \color{blue}{\left(\alpha \cdot \left(-\alpha\right)\right) \cdot \mathsf{log1p}\left(-u0\right)} \]
  3. Applied associate-*l*_binary320.3

    \[\leadsto \color{blue}{\alpha \cdot \left(\left(-\alpha\right) \cdot \mathsf{log1p}\left(-u0\right)\right)} \]
  4. Final simplification0.3

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

Reproduce

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