s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.9650177359580994:\\
\;\;\;\;\left(-\log \left(1 - 4 \cdot u\right)\right) \cdot s\\
\mathbf{else}:\\
\;\;\;\;s \cdot \left(\left(4 \cdot u + 8 \cdot \left(u \cdot u\right)\right) + \left(21.333333333333332 \cdot {u}^{3} + 64 \cdot {u}^{4}\right)\right)\\
\end{array}(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
(FPCore (s u)
:precision binary32
(if (<= (- 1.0 (* 4.0 u)) 0.9650177359580994)
(* (- (log (- 1.0 (* 4.0 u)))) s)
(*
s
(+
(+ (* 4.0 u) (* 8.0 (* u u)))
(+ (* 21.333333333333332 (pow u 3.0)) (* 64.0 (pow u 4.0)))))))float code(float s, float u) {
return s * logf(1.0f / (1.0f - (4.0f * u)));
}
float code(float s, float u) {
float tmp;
if ((1.0f - (4.0f * u)) <= 0.9650177359580994f) {
tmp = -logf(1.0f - (4.0f * u)) * s;
} else {
tmp = s * (((4.0f * u) + (8.0f * (u * u))) + ((21.333333333333332f * powf(u, 3.0f)) + (64.0f * powf(u, 4.0f))));
}
return tmp;
}



Bits error versus s



Bits error versus u
Results
if (-.f32 1 (*.f32 4 u)) < 0.965017736Initial program 1.4
Simplified1.0
rmApplied *-commutative_binary321.0
if 0.965017736 < (-.f32 1 (*.f32 4 u)) Initial program 14.6
Simplified13.7
Taylor expanded around 0 0.4
Simplified0.3
rmApplied distribute-rgt-in_binary320.2
Simplified0.2
Simplified0.2
Final simplification0.4
herbie shell --seed 2021174
(FPCore (s u)
:name "Disney BSSRDF, sample scattering profile, lower"
:precision binary32
:pre (and (<= 0.0 s 256.0) (<= 2.328306437e-10 u 0.25))
(* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))