Average Error: 12.5 → 0.4
Time: 9.4s
Precision: binary32
\[0 \leq s \land s \leq 256 \land 2.328306437 \cdot 10^{-10} \leq u \land u \leq 0.25\]
\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
\[\begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.959128737449646:\\ \;\;\;\;s \cdot \left(\log \left(1 + 4 \cdot u\right) - \log \left(1 - u \cdot \left(u \cdot 16\right)\right)\right)\\ \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} \]
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.959128737449646:\\
\;\;\;\;s \cdot \left(\log \left(1 + 4 \cdot u\right) - \log \left(1 - u \cdot \left(u \cdot 16\right)\right)\right)\\

\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.959128737449646)
   (* s (- (log (+ 1.0 (* 4.0 u))) (log (- 1.0 (* u (* u 16.0))))))
   (*
    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.959128737449646f) {
		tmp = s * (logf(1.0f + (4.0f * u)) - logf(1.0f - (u * (u * 16.0f))));
	} else {
		tmp = s * (((4.0f * u) + (8.0f * (u * u))) + ((21.333333333333332f * powf(u, 3.0f)) + (64.0f * powf(u, 4.0f))));
	}
	return tmp;
}

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. Split input into 2 regimes
  2. if (-.f32 1 (*.f32 4 u)) < 0.959128737

    1. Initial program 1.3

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

      \[\leadsto \color{blue}{s \cdot \left(-\log \left(1 - 4 \cdot u\right)\right)} \]
    3. Using strategy rm
    4. Applied flip--_binary321.4

      \[\leadsto s \cdot \left(-\log \color{blue}{\left(\frac{1 \cdot 1 - \left(4 \cdot u\right) \cdot \left(4 \cdot u\right)}{1 + 4 \cdot u}\right)}\right) \]
    5. Applied log-div_binary321.4

      \[\leadsto s \cdot \left(-\color{blue}{\left(\log \left(1 \cdot 1 - \left(4 \cdot u\right) \cdot \left(4 \cdot u\right)\right) - \log \left(1 + 4 \cdot u\right)\right)}\right) \]
    6. Simplified1.4

      \[\leadsto s \cdot \left(-\left(\color{blue}{\log \left(1 - u \cdot \left(u \cdot 16\right)\right)} - \log \left(1 + 4 \cdot u\right)\right)\right) \]
    7. Simplified1.4

      \[\leadsto s \cdot \left(-\left(\log \left(1 - u \cdot \left(u \cdot 16\right)\right) - \color{blue}{\log \left(u \cdot 4 + 1\right)}\right)\right) \]

    if 0.959128737 < (-.f32 1 (*.f32 4 u))

    1. Initial program 14.6

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

      \[\leadsto \color{blue}{s \cdot \left(-\log \left(1 - 4 \cdot u\right)\right)} \]
    3. Taylor expanded around 0 0.4

      \[\leadsto \color{blue}{8 \cdot \left(s \cdot {u}^{2}\right) + \left(21.333333333333332 \cdot \left(s \cdot {u}^{3}\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right)\right)} \]
    4. Simplified0.4

      \[\leadsto \color{blue}{s \cdot \left(u \cdot \left(4 + u \cdot 8\right) + \left(21.333333333333332 \cdot {u}^{3} + 64 \cdot {u}^{4}\right)\right)} \]
    5. Using strategy rm
    6. Applied distribute-rgt-in_binary320.3

      \[\leadsto s \cdot \left(\color{blue}{\left(4 \cdot u + \left(u \cdot 8\right) \cdot u\right)} + \left(21.333333333333332 \cdot {u}^{3} + 64 \cdot {u}^{4}\right)\right) \]
    7. Simplified0.3

      \[\leadsto s \cdot \left(\left(\color{blue}{u \cdot 4} + \left(u \cdot 8\right) \cdot u\right) + \left(21.333333333333332 \cdot {u}^{3} + 64 \cdot {u}^{4}\right)\right) \]
    8. Simplified0.3

      \[\leadsto s \cdot \left(\left(u \cdot 4 + \color{blue}{8 \cdot \left(u \cdot u\right)}\right) + \left(21.333333333333332 \cdot {u}^{3} + 64 \cdot {u}^{4}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.959128737449646:\\ \;\;\;\;s \cdot \left(\log \left(1 + 4 \cdot u\right) - \log \left(1 - u \cdot \left(u \cdot 16\right)\right)\right)\\ \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} \]

Reproduce

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