Average Error: 0.2 → 0.2
Time: 9.4s
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) \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)\\ t_1 := \log \left({t_0}^{0.16666666666666666}\right)\\ 1 + v \cdot \left(\left(t_1 + t_1\right) + \log \left(\sqrt[3]{{t_0}^{2}}\right)\right) \end{array} \]
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
(FPCore (u v)
 :precision binary32
 (let* ((t_0 (fma (- 1.0 u) (exp (/ -2.0 v)) u))
        (t_1 (log (pow t_0 0.16666666666666666))))
   (+ 1.0 (* v (+ (+ t_1 t_1) (log (cbrt (pow t_0 2.0))))))))
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) {
	float t_0 = fmaf((1.0f - u), expf((-2.0f / v)), u);
	float t_1 = logf(powf(t_0, 0.16666666666666666f));
	return 1.0f + (v * ((t_1 + t_1) + logf(cbrtf(powf(t_0, 2.0f)))));
}
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))))
end
function code(u, v)
	t_0 = fma(Float32(Float32(1.0) - u), exp(Float32(Float32(-2.0) / v)), u)
	t_1 = log((t_0 ^ Float32(0.16666666666666666)))
	return Float32(Float32(1.0) + Float32(v * Float32(Float32(t_1 + t_1) + log(cbrt((t_0 ^ Float32(2.0)))))))
end
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
\begin{array}{l}
t_0 := \mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)\\
t_1 := \log \left({t_0}^{0.16666666666666666}\right)\\
1 + v \cdot \left(\left(t_1 + t_1\right) + \log \left(\sqrt[3]{{t_0}^{2}}\right)\right)
\end{array}

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. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(v, \log \left(\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)\right), 1\right)} \]
  3. Applied egg-rr0.2

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

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

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

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

Reproduce

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