Average Error: 1.3 → 0.7
Time: 4.4s
Precision: binary32
\[\left(0 \leq s \land s \leq 256\right) \land \left(0.25 \leq u \land u \leq 1\right)\]
\[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
\[-3 \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot s\right) \]
(FPCore (s u)
 :precision binary32
 (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))
(FPCore (s u)
 :precision binary32
 (* -3.0 (* (log1p (fma u -1.3333333333333333 0.3333333333333333)) s)))
float code(float s, float u) {
	return (3.0f * s) * logf((1.0f / (1.0f - ((u - 0.25f) / 0.75f))));
}
float code(float s, float u) {
	return -3.0f * (log1pf(fmaf(u, -1.3333333333333333f, 0.3333333333333333f)) * s);
}
function code(s, u)
	return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75))))))
end
function code(s, u)
	return Float32(Float32(-3.0) * Float32(log1p(fma(u, Float32(-1.3333333333333333), Float32(0.3333333333333333))) * s))
end
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
-3 \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot s\right)

Error

Bits error versus s

Bits error versus u

Derivation

  1. Initial program 1.3

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Simplified0.7

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot \left(s \cdot -3\right)} \]
  3. Applied egg-rr0.7

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot \left(s \cdot -3\right)\right)\right)} \]
  4. Applied egg-rr0.7

    \[\leadsto \color{blue}{-3 \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot s\right)} \]
  5. Final simplification0.7

    \[\leadsto -3 \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot s\right) \]

Reproduce

herbie shell --seed 2022150 
(FPCore (s u)
  :name "Disney BSSRDF, sample scattering profile, upper"
  :precision binary32
  :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0)))
  (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))