Disney BSSRDF, sample scattering profile, lower

Percentage Accurate: 61.5% → 89.1%
Time: 6.7s
Alternatives: 4
Speedup: 11.4×

Specification

?
\[\left(0 \leq s \land s \leq 256\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 0.25\right)\]
\[\begin{array}{l} \\ s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \end{array} \]
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
float code(float s, float u) {
	return s * logf((1.0f / (1.0f - (4.0f * u))));
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
function code(s, u)
	return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u)))))
end
function tmp = code(s, u)
	tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u))));
end
\begin{array}{l}

\\
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 61.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \end{array} \]
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
float code(float s, float u) {
	return s * logf((1.0f / (1.0f - (4.0f * u))));
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
function code(s, u)
	return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u)))))
end
function tmp = code(s, u)
	tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u))));
end
\begin{array}{l}

\\
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\end{array}

Alternative 1: 89.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u \cdot 4 \leq 0.999750018119812:\\ \;\;\;\;\log \left(\frac{1}{1 - e^{\log \left(u \cdot 4\right)}}\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s\\ \end{array} \end{array} \]
(FPCore (s u)
 :precision binary32
 (if (<= (- 1.0 (* u 4.0)) 0.999750018119812)
   (* (log (/ 1.0 (- 1.0 (exp (log (* u 4.0)))))) s)
   (* (/ (* -16.0 (* u u)) (* -4.0 u)) s)))
float code(float s, float u) {
	float tmp;
	if ((1.0f - (u * 4.0f)) <= 0.999750018119812f) {
		tmp = logf((1.0f / (1.0f - expf(logf((u * 4.0f)))))) * s;
	} else {
		tmp = ((-16.0f * (u * u)) / (-4.0f * u)) * s;
	}
	return tmp;
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: tmp
    if ((1.0e0 - (u * 4.0e0)) <= 0.999750018119812e0) then
        tmp = log((1.0e0 / (1.0e0 - exp(log((u * 4.0e0)))))) * s
    else
        tmp = (((-16.0e0) * (u * u)) / ((-4.0e0) * u)) * s
    end if
    code = tmp
end function
function code(s, u)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(u * Float32(4.0))) <= Float32(0.999750018119812))
		tmp = Float32(log(Float32(Float32(1.0) / Float32(Float32(1.0) - exp(log(Float32(u * Float32(4.0))))))) * s);
	else
		tmp = Float32(Float32(Float32(Float32(-16.0) * Float32(u * u)) / Float32(Float32(-4.0) * u)) * s);
	end
	return tmp
end
function tmp_2 = code(s, u)
	tmp = single(0.0);
	if ((single(1.0) - (u * single(4.0))) <= single(0.999750018119812))
		tmp = log((single(1.0) / (single(1.0) - exp(log((u * single(4.0))))))) * s;
	else
		tmp = ((single(-16.0) * (u * u)) / (single(-4.0) * u)) * s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;1 - u \cdot 4 \leq 0.999750018119812:\\
\;\;\;\;\log \left(\frac{1}{1 - e^{\log \left(u \cdot 4\right)}}\right) \cdot s\\

\mathbf{else}:\\
\;\;\;\;\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u)) < 0.999750018

    1. Initial program 87.9%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. rem-exp-logN/A

        \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{e^{\log \left(4 \cdot u\right)}}}\right) \]
      2. lower-exp.f32N/A

        \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{e^{\log \left(4 \cdot u\right)}}}\right) \]
      3. lower-log.f3287.9

        \[\leadsto s \cdot \log \left(\frac{1}{1 - e^{\color{blue}{\log \left(4 \cdot u\right)}}}\right) \]
      4. lift-*.f32N/A

        \[\leadsto s \cdot \log \left(\frac{1}{1 - e^{\log \color{blue}{\left(4 \cdot u\right)}}}\right) \]
      5. *-commutativeN/A

        \[\leadsto s \cdot \log \left(\frac{1}{1 - e^{\log \color{blue}{\left(u \cdot 4\right)}}}\right) \]
      6. lower-*.f3287.9

        \[\leadsto s \cdot \log \left(\frac{1}{1 - e^{\log \color{blue}{\left(u \cdot 4\right)}}}\right) \]
    4. Applied rewrites87.9%

      \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{e^{\log \left(u \cdot 4\right)}}}\right) \]

    if 0.999750018 < (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u))

    1. Initial program 45.4%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-log.f32N/A

        \[\leadsto s \cdot \color{blue}{\log \left(\frac{1}{1 - 4 \cdot u}\right)} \]
      2. lift-/.f32N/A

        \[\leadsto s \cdot \log \color{blue}{\left(\frac{1}{1 - 4 \cdot u}\right)} \]
      3. log-divN/A

        \[\leadsto s \cdot \color{blue}{\left(\log 1 - \log \left(1 - 4 \cdot u\right)\right)} \]
      4. flip--N/A

        \[\leadsto s \cdot \color{blue}{\frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log 1 + \log \left(1 - 4 \cdot u\right)}} \]
      5. metadata-evalN/A

        \[\leadsto s \cdot \frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\color{blue}{0} + \log \left(1 - 4 \cdot u\right)} \]
      6. +-lft-identityN/A

        \[\leadsto s \cdot \frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\color{blue}{\log \left(1 - 4 \cdot u\right)}} \]
      7. lower-/.f32N/A

        \[\leadsto s \cdot \color{blue}{\frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log \left(1 - 4 \cdot u\right)}} \]
    4. Applied rewrites69.6%

      \[\leadsto s \cdot \color{blue}{\frac{-{\left(\mathsf{log1p}\left(-4 \cdot u\right)\right)}^{2}}{\mathsf{log1p}\left(-4 \cdot u\right)}} \]
    5. Taylor expanded in u around 0

      \[\leadsto s \cdot \frac{\color{blue}{-16 \cdot {u}^{2}}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto s \cdot \frac{\color{blue}{{u}^{2} \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      2. lower-*.f32N/A

        \[\leadsto s \cdot \frac{\color{blue}{{u}^{2} \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      3. unpow2N/A

        \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right)} \cdot -16}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      4. lower-*.f3289.5

        \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right)} \cdot -16}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    7. Applied rewrites89.5%

      \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right) \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    8. Taylor expanded in u around 0

      \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{-4 \cdot u}} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
      2. lower-*.f3290.2

        \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
    10. Applied rewrites90.2%

      \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u \cdot 4 \leq 0.999750018119812:\\ \;\;\;\;\log \left(\frac{1}{1 - e^{\log \left(u \cdot 4\right)}}\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 89.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - u \cdot 4\\ \mathbf{if}\;t\_0 \leq 0.999750018119812:\\ \;\;\;\;\log \left(\frac{1}{t\_0}\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s\\ \end{array} \end{array} \]
(FPCore (s u)
 :precision binary32
 (let* ((t_0 (- 1.0 (* u 4.0))))
   (if (<= t_0 0.999750018119812)
     (* (log (/ 1.0 t_0)) s)
     (* (/ (* -16.0 (* u u)) (* -4.0 u)) s))))
float code(float s, float u) {
	float t_0 = 1.0f - (u * 4.0f);
	float tmp;
	if (t_0 <= 0.999750018119812f) {
		tmp = logf((1.0f / t_0)) * s;
	} else {
		tmp = ((-16.0f * (u * u)) / (-4.0f * u)) * s;
	}
	return tmp;
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: t_0
    real(4) :: tmp
    t_0 = 1.0e0 - (u * 4.0e0)
    if (t_0 <= 0.999750018119812e0) then
        tmp = log((1.0e0 / t_0)) * s
    else
        tmp = (((-16.0e0) * (u * u)) / ((-4.0e0) * u)) * s
    end if
    code = tmp
end function
function code(s, u)
	t_0 = Float32(Float32(1.0) - Float32(u * Float32(4.0)))
	tmp = Float32(0.0)
	if (t_0 <= Float32(0.999750018119812))
		tmp = Float32(log(Float32(Float32(1.0) / t_0)) * s);
	else
		tmp = Float32(Float32(Float32(Float32(-16.0) * Float32(u * u)) / Float32(Float32(-4.0) * u)) * s);
	end
	return tmp
end
function tmp_2 = code(s, u)
	t_0 = single(1.0) - (u * single(4.0));
	tmp = single(0.0);
	if (t_0 <= single(0.999750018119812))
		tmp = log((single(1.0) / t_0)) * s;
	else
		tmp = ((single(-16.0) * (u * u)) / (single(-4.0) * u)) * s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - u \cdot 4\\
\mathbf{if}\;t\_0 \leq 0.999750018119812:\\
\;\;\;\;\log \left(\frac{1}{t\_0}\right) \cdot s\\

\mathbf{else}:\\
\;\;\;\;\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u)) < 0.999750018

    1. Initial program 87.9%

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

    if 0.999750018 < (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u))

    1. Initial program 45.4%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-log.f32N/A

        \[\leadsto s \cdot \color{blue}{\log \left(\frac{1}{1 - 4 \cdot u}\right)} \]
      2. lift-/.f32N/A

        \[\leadsto s \cdot \log \color{blue}{\left(\frac{1}{1 - 4 \cdot u}\right)} \]
      3. log-divN/A

        \[\leadsto s \cdot \color{blue}{\left(\log 1 - \log \left(1 - 4 \cdot u\right)\right)} \]
      4. flip--N/A

        \[\leadsto s \cdot \color{blue}{\frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log 1 + \log \left(1 - 4 \cdot u\right)}} \]
      5. metadata-evalN/A

        \[\leadsto s \cdot \frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\color{blue}{0} + \log \left(1 - 4 \cdot u\right)} \]
      6. +-lft-identityN/A

        \[\leadsto s \cdot \frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\color{blue}{\log \left(1 - 4 \cdot u\right)}} \]
      7. lower-/.f32N/A

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

      \[\leadsto s \cdot \color{blue}{\frac{-{\left(\mathsf{log1p}\left(-4 \cdot u\right)\right)}^{2}}{\mathsf{log1p}\left(-4 \cdot u\right)}} \]
    5. Taylor expanded in u around 0

      \[\leadsto s \cdot \frac{\color{blue}{-16 \cdot {u}^{2}}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto s \cdot \frac{\color{blue}{{u}^{2} \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      2. lower-*.f32N/A

        \[\leadsto s \cdot \frac{\color{blue}{{u}^{2} \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      3. unpow2N/A

        \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right)} \cdot -16}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      4. lower-*.f3289.5

        \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right)} \cdot -16}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    7. Applied rewrites89.5%

      \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right) \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    8. Taylor expanded in u around 0

      \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{-4 \cdot u}} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
      2. lower-*.f3290.2

        \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
    10. Applied rewrites90.2%

      \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u \cdot 4 \leq 0.999750018119812:\\ \;\;\;\;\log \left(\frac{1}{1 - u \cdot 4}\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.6% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s \end{array} \]
(FPCore (s u) :precision binary32 (* (/ (* -16.0 (* u u)) (* -4.0 u)) s))
float code(float s, float u) {
	return ((-16.0f * (u * u)) / (-4.0f * u)) * s;
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = (((-16.0e0) * (u * u)) / ((-4.0e0) * u)) * s
end function
function code(s, u)
	return Float32(Float32(Float32(Float32(-16.0) * Float32(u * u)) / Float32(Float32(-4.0) * u)) * s)
end
function tmp = code(s, u)
	tmp = ((single(-16.0) * (u * u)) / (single(-4.0) * u)) * s;
end
\begin{array}{l}

\\
\frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s
\end{array}
Derivation
  1. Initial program 64.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-log.f32N/A

      \[\leadsto s \cdot \color{blue}{\log \left(\frac{1}{1 - 4 \cdot u}\right)} \]
    2. lift-/.f32N/A

      \[\leadsto s \cdot \log \color{blue}{\left(\frac{1}{1 - 4 \cdot u}\right)} \]
    3. log-divN/A

      \[\leadsto s \cdot \color{blue}{\left(\log 1 - \log \left(1 - 4 \cdot u\right)\right)} \]
    4. flip--N/A

      \[\leadsto s \cdot \color{blue}{\frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log 1 + \log \left(1 - 4 \cdot u\right)}} \]
    5. metadata-evalN/A

      \[\leadsto s \cdot \frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\color{blue}{0} + \log \left(1 - 4 \cdot u\right)} \]
    6. +-lft-identityN/A

      \[\leadsto s \cdot \frac{\log 1 \cdot \log 1 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\color{blue}{\log \left(1 - 4 \cdot u\right)}} \]
    7. lower-/.f32N/A

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

    \[\leadsto s \cdot \color{blue}{\frac{-{\left(\mathsf{log1p}\left(-4 \cdot u\right)\right)}^{2}}{\mathsf{log1p}\left(-4 \cdot u\right)}} \]
  5. Taylor expanded in u around 0

    \[\leadsto s \cdot \frac{\color{blue}{-16 \cdot {u}^{2}}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto s \cdot \frac{\color{blue}{{u}^{2} \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    2. lower-*.f32N/A

      \[\leadsto s \cdot \frac{\color{blue}{{u}^{2} \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    3. unpow2N/A

      \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right)} \cdot -16}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    4. lower-*.f3270.8

      \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right)} \cdot -16}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
  7. Applied rewrites70.8%

    \[\leadsto s \cdot \frac{\color{blue}{\left(u \cdot u\right) \cdot -16}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
  8. Taylor expanded in u around 0

    \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{-4 \cdot u}} \]
  9. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
    2. lower-*.f3271.2

      \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
  10. Applied rewrites71.2%

    \[\leadsto s \cdot \frac{\left(u \cdot u\right) \cdot -16}{\color{blue}{u \cdot -4}} \]
  11. Final simplification71.2%

    \[\leadsto \frac{-16 \cdot \left(u \cdot u\right)}{-4 \cdot u} \cdot s \]
  12. Add Preprocessing

Alternative 4: 73.6% accurate, 11.4× speedup?

\[\begin{array}{l} \\ \left(u \cdot 4\right) \cdot s \end{array} \]
(FPCore (s u) :precision binary32 (* (* u 4.0) s))
float code(float s, float u) {
	return (u * 4.0f) * s;
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = (u * 4.0e0) * s
end function
function code(s, u)
	return Float32(Float32(u * Float32(4.0)) * s)
end
function tmp = code(s, u)
	tmp = (u * single(4.0)) * s;
end
\begin{array}{l}

\\
\left(u \cdot 4\right) \cdot s
\end{array}
Derivation
  1. Initial program 64.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u around 0

    \[\leadsto s \cdot \color{blue}{\left(4 \cdot u\right)} \]
  4. Step-by-step derivation
    1. lower-*.f3271.2

      \[\leadsto s \cdot \color{blue}{\left(4 \cdot u\right)} \]
  5. Applied rewrites71.2%

    \[\leadsto s \cdot \color{blue}{\left(4 \cdot u\right)} \]
  6. Final simplification71.2%

    \[\leadsto \left(u \cdot 4\right) \cdot s \]
  7. Add Preprocessing

Reproduce

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