Average Error: 0.2 → 0.2
Time: 25.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) \]
\[\begin{array}{l} t_0 := e^{\frac{-2}{v}}\\ t_1 := \mathsf{fma}\left(2, \log v, \log \left({\log \left(\left(t_0 + u\right) - t_0 \cdot u\right)}^{2}\right)\right)\\ 1 + e^{\log \left(\sqrt[3]{e^{0.3333333333333333 \cdot t_1 + t_1 \cdot 0.6666666666666666}}\right)} \cdot \sqrt[3]{v \cdot \log \left(\mathsf{fma}\left(t_0, 1 - u, u\right)\right)} \end{array} \]
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
\begin{array}{l}
t_0 := e^{\frac{-2}{v}}\\
t_1 := \mathsf{fma}\left(2, \log v, \log \left({\log \left(\left(t_0 + u\right) - t_0 \cdot u\right)}^{2}\right)\right)\\
1 + e^{\log \left(\sqrt[3]{e^{0.3333333333333333 \cdot t_1 + t_1 \cdot 0.6666666666666666}}\right)} \cdot \sqrt[3]{v \cdot \log \left(\mathsf{fma}\left(t_0, 1 - u, u\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 (exp (/ -2.0 v)))
        (t_1 (fma 2.0 (log v) (log (pow (log (- (+ t_0 u) (* t_0 u))) 2.0)))))
   (+
    1.0
    (*
     (exp
      (log
       (cbrt (exp (+ (* 0.3333333333333333 t_1) (* t_1 0.6666666666666666))))))
     (cbrt (* v (log (fma t_0 (- 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) {
	float t_0 = expf(-2.0f / v);
	float t_1 = fmaf(2.0f, logf(v), logf(powf(logf((t_0 + u) - (t_0 * u)), 2.0f)));
	return 1.0f + (expf(logf(cbrtf(expf((0.3333333333333333f * t_1) + (t_1 * 0.6666666666666666f))))) * cbrtf(v * logf(fmaf(t_0, (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-cube-cbrt_binary320.2

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

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

    \[\leadsto 1 + \left(\sqrt[3]{v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)} \cdot \sqrt[3]{v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}\right) \cdot \color{blue}{\sqrt[3]{v \cdot \log \left(\mathsf{fma}\left(e^{\frac{-2}{v}}, 1 - u, u\right)\right)}} \]
  5. Taylor expanded in v around 0 0.2

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

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

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

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

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

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

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

Reproduce

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