Average Error: 12.3 → 0.2
Time: 7.9s
Precision: binary32
Cost: 9792
\[\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{expm1}\left(\mathsf{log1p}\left(\left(-\mathsf{log1p}\left(u \cdot -4\right)\right) \cdot s\right)\right) \]
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
(FPCore (s u) :precision binary32 (expm1 (log1p (* (- (log1p (* u -4.0))) s))))
float code(float s, float u) {
	return s * logf((1.0f / (1.0f - (4.0f * u))));
}
float code(float s, float u) {
	return expm1f(log1pf((-log1pf((u * -4.0f)) * s)));
}
function code(s, u)
	return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u)))))
end
function code(s, u)
	return expm1(log1p(Float32(Float32(-log1p(Float32(u * Float32(-4.0)))) * s)))
end
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-\mathsf{log1p}\left(u \cdot -4\right)\right) \cdot s\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 12.3

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

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

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

Alternatives

Alternative 1
Error0.2
Cost3392
\[\left(-\mathsf{log1p}\left(u \cdot -4\right)\right) \cdot s \]
Alternative 2
Error2.8
Cost480
\[s \cdot \left(u \cdot 4 + \left(u \cdot u\right) \cdot \left(8 + u \cdot 21.333333333333332\right)\right) \]
Alternative 3
Error3.0
Cost416
\[\left(4 + u \cdot \left(8 + u \cdot 21.333333333333332\right)\right) \cdot \left(u \cdot s\right) \]
Alternative 4
Error2.9
Cost416
\[s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot 21.333333333333332\right)\right)\right) \]
Alternative 5
Error4.2
Cost352
\[s \cdot \left(u \cdot 4 + u \cdot \left(u \cdot 8\right)\right) \]
Alternative 6
Error4.3
Cost288
\[\left(u \cdot s\right) \cdot \left(4 + u \cdot 8\right) \]
Alternative 7
Error4.2
Cost288
\[u \cdot \left(s \cdot \left(4 + u \cdot 8\right)\right) \]
Alternative 8
Error4.2
Cost288
\[s \cdot \left(u \cdot \left(4 + u \cdot 8\right)\right) \]
Alternative 9
Error8.4
Cost160
\[4 \cdot \left(u \cdot s\right) \]
Alternative 10
Error8.3
Cost160
\[u \cdot \left(s \cdot 4\right) \]

Error

Reproduce

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