Average Error: 12.5 → 0.2
Time: 6.4s
Precision: binary32
\[\left(0 \leq s \land s \leq 256\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 0.25\right)\]
\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-\mathsf{log1p}\left(u \cdot -4\right)\right)\right)\right) \]
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-\mathsf{log1p}\left(u \cdot -4\right)\right)\right)\right)
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
(FPCore (s u) :precision binary32 (log1p (expm1 (* s (- (log1p (* 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) {
	return log1pf(expm1f(s * -log1pf(u * -4.0f)));
}

Error

Bits error versus s

Bits error versus u

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 12.5

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Simplified0.2

    \[\leadsto \color{blue}{s \cdot \left(-\mathsf{log1p}\left(u \cdot -4\right)\right)} \]
  3. Applied log1p-expm1-u_binary320.2

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-\mathsf{log1p}\left(u \cdot -4\right)\right)\right)\right)} \]
  4. Final simplification0.2

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-\mathsf{log1p}\left(u \cdot -4\right)\right)\right)\right) \]

Reproduce

herbie shell --seed 2022087 
(FPCore (s u)
  :name "Disney BSSRDF, sample scattering profile, lower"
  :precision binary32
  :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 2.328306437e-10 u) (<= u 0.25)))
  (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))