Average Error: 0.2 → 0.2
Time: 22.9s
Precision: binary32
\[\left(10^{-5} \leq u \land u \leq 1\right) \land \left(0 \leq v \land v \leq 109.746574\right)\]
\[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
\[1 + v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right) \]
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
1 + v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (fma (exp (/ -2.0 v)) (- 1.0 u) u)))))
float code(float u, float v) {
	return 1.0f + (v * logf(u + ((1.0f - u) * expf(-2.0f / v))));
}
float code(float u, float v) {
	return 1.0f + (v * logf(fmaf(expf(-2.0f / v), (1.0f - u), u)));
}

Error

Bits error versus u

Bits error versus v

Derivation

  1. Initial program 0.2

    \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
  2. Applied add-sqr-sqrt_binary320.2

    \[\leadsto 1 + v \cdot \log \color{blue}{\left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}} \cdot \sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)} \]
  3. Applied log-prod_binary320.2

    \[\leadsto 1 + v \cdot \color{blue}{\left(\log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right) + \log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)\right)} \]
  4. Simplified0.2

    \[\leadsto 1 + v \cdot \left(\color{blue}{\log \left(\sqrt{\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)}\right)} + \log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)\right) \]
  5. Simplified0.2

    \[\leadsto 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)}\right) + \color{blue}{\log \left(\sqrt{\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)}\right)}\right) \]
  6. Applied pow1_binary320.2

    \[\leadsto 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)}\right) + \log \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}^{1}}}\right)\right) \]
  7. Applied sqrt-pow1_binary320.2

    \[\leadsto 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)}\right) + \log \color{blue}{\left({\left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \]
  8. Applied log-pow_binary320.2

    \[\leadsto 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)}\right) + \color{blue}{\frac{1}{2} \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}\right) \]
  9. Applied pow1_binary320.2

    \[\leadsto 1 + v \cdot \left(\log \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}^{1}}}\right) + \frac{1}{2} \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)\right) \]
  10. Applied sqrt-pow1_binary320.2

    \[\leadsto 1 + v \cdot \left(\log \color{blue}{\left({\left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}^{\left(\frac{1}{2}\right)}\right)} + \frac{1}{2} \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)\right) \]
  11. Applied log-pow_binary320.2

    \[\leadsto 1 + v \cdot \left(\color{blue}{\frac{1}{2} \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)} + \frac{1}{2} \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)\right) \]
  12. Applied distribute-rgt-out_binary320.2

    \[\leadsto 1 + v \cdot \color{blue}{\left(\log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right) \cdot \left(\frac{1}{2} + \frac{1}{2}\right)\right)} \]
  13. Applied associate-*r*_binary320.2

    \[\leadsto 1 + \color{blue}{\left(v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)\right) \cdot \left(\frac{1}{2} + \frac{1}{2}\right)} \]
  14. Final simplification0.2

    \[\leadsto 1 + v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right) \]

Reproduce

herbie shell --seed 2022063 
(FPCore (u v)
  :name "HairBSDF, sample_f, cosTheta"
  :precision binary32
  :pre (and (and (<= 1e-5 u) (<= u 1.0)) (and (<= 0.0 v) (<= v 109.746574)))
  (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))