Disney BSSRDF, sample scattering profile, lower

Percentage Accurate: 61.0% → 98.5%
Time: 7.6s
Alternatives: 8
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 8 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.0% 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: 98.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t\_0 \leq 0.9599999785423279:\\ \;\;\;\;s \cdot \log \left(\frac{1}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)\\ \end{array} \end{array} \]
(FPCore (s u)
 :precision binary32
 (let* ((t_0 (- 1.0 (* 4.0 u))))
   (if (<= t_0 0.9599999785423279)
     (* s (log (/ 1.0 t_0)))
     (*
      (* (- (* (- (* (- (* -64.0 u) 21.333333333333332) u) 8.0) u) 4.0) u)
      (- s)))))
float code(float s, float u) {
	float t_0 = 1.0f - (4.0f * u);
	float tmp;
	if (t_0 <= 0.9599999785423279f) {
		tmp = s * logf((1.0f / t_0));
	} else {
		tmp = (((((((-64.0f * u) - 21.333333333333332f) * u) - 8.0f) * 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 - (4.0e0 * u)
    if (t_0 <= 0.9599999785423279e0) then
        tmp = s * log((1.0e0 / t_0))
    else
        tmp = ((((((((-64.0e0) * u) - 21.333333333333332e0) * u) - 8.0e0) * u) - 4.0e0) * u) * -s
    end if
    code = tmp
end function
function code(s, u)
	t_0 = Float32(Float32(1.0) - Float32(Float32(4.0) * u))
	tmp = Float32(0.0)
	if (t_0 <= Float32(0.9599999785423279))
		tmp = Float32(s * log(Float32(Float32(1.0) / t_0)));
	else
		tmp = Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(-64.0) * u) - Float32(21.333333333333332)) * u) - Float32(8.0)) * u) - Float32(4.0)) * u) * Float32(-s));
	end
	return tmp
end
function tmp_2 = code(s, u)
	t_0 = single(1.0) - (single(4.0) * u);
	tmp = single(0.0);
	if (t_0 <= single(0.9599999785423279))
		tmp = s * log((single(1.0) / t_0));
	else
		tmp = (((((((single(-64.0) * u) - single(21.333333333333332)) * u) - single(8.0)) * u) - single(4.0)) * u) * -s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)\\


\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.959999979

    1. Initial program 95.6%

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

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

    1. Initial program 54.9%

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

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

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

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

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

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

      \[\leadsto s \cdot \log \left(\frac{1}{\color{blue}{\left(\frac{1}{u} - 4\right) \cdot u}}\right) \]
    6. Step-by-step derivation
      1. lift-*.f32N/A

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

        \[\leadsto \color{blue}{\log \left(\frac{1}{\left(\frac{1}{u} - 4\right) \cdot u}\right) \cdot s} \]
      3. lower-*.f3254.2

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\left(u \cdot \left(u \cdot \left(-64 \cdot u - \frac{64}{3}\right) - 8\right) - 4\right) \cdot u}\right) \cdot s \]
      2. lower-*.f32N/A

        \[\leadsto \left(-\color{blue}{\left(u \cdot \left(u \cdot \left(-64 \cdot u - \frac{64}{3}\right) - 8\right) - 4\right) \cdot u}\right) \cdot s \]
    10. Applied rewrites99.0%

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

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

Alternative 2: 93.5% accurate, 3.4× speedup?

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

\\
\left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)
\end{array}
Derivation
  1. Initial program 61.3%

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

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

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

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

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

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

    \[\leadsto s \cdot \log \left(\frac{1}{\color{blue}{\left(\frac{1}{u} - 4\right) \cdot u}}\right) \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1}{\left(\frac{1}{u} - 4\right) \cdot u}\right) \cdot s} \]
    3. lower-*.f3260.4

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

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

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

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

      \[\leadsto \color{blue}{\left(-\log \left(\left(\frac{1}{u} - 4\right) \cdot u\right)\right)} \cdot s \]
    8. lower-log.f3261.8

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

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

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

      \[\leadsto \left(-\color{blue}{\left(u \cdot \left(u \cdot \left(-64 \cdot u - \frac{64}{3}\right) - 8\right) - 4\right) \cdot u}\right) \cdot s \]
    2. lower-*.f32N/A

      \[\leadsto \left(-\color{blue}{\left(u \cdot \left(u \cdot \left(-64 \cdot u - \frac{64}{3}\right) - 8\right) - 4\right) \cdot u}\right) \cdot s \]
  10. Applied rewrites93.3%

    \[\leadsto \left(-\color{blue}{\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u}\right) \cdot s \]
  11. Final simplification93.3%

    \[\leadsto \left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right) \]
  12. Add Preprocessing

Alternative 3: 91.4% accurate, 4.3× speedup?

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

\\
\left(\left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)
\end{array}
Derivation
  1. Initial program 61.3%

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

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

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

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

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

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

    \[\leadsto s \cdot \log \left(\frac{1}{\color{blue}{\left(\frac{1}{u} - 4\right) \cdot u}}\right) \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1}{\left(\frac{1}{u} - 4\right) \cdot u}\right) \cdot s} \]
    3. lower-*.f3260.4

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

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

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

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

      \[\leadsto \color{blue}{\left(-\log \left(\left(\frac{1}{u} - 4\right) \cdot u\right)\right)} \cdot s \]
    8. lower-log.f3261.8

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

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

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

      \[\leadsto \left(-\color{blue}{\left(u \cdot \left(\frac{-64}{3} \cdot u - 8\right) - 4\right) \cdot u}\right) \cdot s \]
    2. lower-*.f32N/A

      \[\leadsto \left(-\color{blue}{\left(u \cdot \left(\frac{-64}{3} \cdot u - 8\right) - 4\right) \cdot u}\right) \cdot s \]
    3. lower--.f32N/A

      \[\leadsto \left(-\color{blue}{\left(u \cdot \left(\frac{-64}{3} \cdot u - 8\right) - 4\right)} \cdot u\right) \cdot s \]
    4. *-commutativeN/A

      \[\leadsto \left(-\left(\color{blue}{\left(\frac{-64}{3} \cdot u - 8\right) \cdot u} - 4\right) \cdot u\right) \cdot s \]
    5. lower-*.f32N/A

      \[\leadsto \left(-\left(\color{blue}{\left(\frac{-64}{3} \cdot u - 8\right) \cdot u} - 4\right) \cdot u\right) \cdot s \]
    6. lower--.f32N/A

      \[\leadsto \left(-\left(\color{blue}{\left(\frac{-64}{3} \cdot u - 8\right)} \cdot u - 4\right) \cdot u\right) \cdot s \]
    7. lower-*.f3291.2

      \[\leadsto \left(-\left(\left(\color{blue}{-21.333333333333332 \cdot u} - 8\right) \cdot u - 4\right) \cdot u\right) \cdot s \]
  10. Applied rewrites91.2%

    \[\leadsto \left(-\color{blue}{\left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right) \cdot u}\right) \cdot s \]
  11. Final simplification91.2%

    \[\leadsto \left(\left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right) \]
  12. Add Preprocessing

Alternative 4: 91.4% accurate, 4.3× speedup?

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

\\
\left(\left(-s\right) \cdot \left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right)\right) \cdot u
\end{array}
Derivation
  1. Initial program 61.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. metadata-evalN/A

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

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

      \[\leadsto s \cdot \frac{0 \cdot 0 - \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{0 \cdot 0 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log \left(1 - 4 \cdot u\right)}} \]
  4. Applied rewrites42.0%

    \[\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}{{u}^{2} \cdot \left(-64 \cdot u - 16\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

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

      \[\leadsto s \cdot \frac{\left(-64 \cdot u - 16\right) \cdot \color{blue}{\left(u \cdot u\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    3. associate-*r*N/A

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right)\right) \cdot u} \]
    2. lower-*.f32N/A

      \[\leadsto \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right)\right) \cdot u} \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{\left(u \cdot \left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right) + 4 \cdot s\right)} \cdot u \]
    4. *-commutativeN/A

      \[\leadsto \left(\color{blue}{\left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right) \cdot u} + 4 \cdot s\right) \cdot u \]
    5. lower-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right), u, 4 \cdot s\right)} \cdot u \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{64}{3} \cdot \left(s \cdot u\right) + 8 \cdot s}, u, 4 \cdot s\right) \cdot u \]
    7. lower-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{64}{3}, s \cdot u, 8 \cdot s\right)}, u, 4 \cdot s\right) \cdot u \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, \color{blue}{u \cdot s}, 8 \cdot s\right), u, 4 \cdot s\right) \cdot u \]
    9. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, \color{blue}{u \cdot s}, 8 \cdot s\right), u, 4 \cdot s\right) \cdot u \]
    10. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u \cdot s, \color{blue}{8 \cdot s}\right), u, 4 \cdot s\right) \cdot u \]
    11. lower-*.f3273.1

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u \cdot s, 8 \cdot s\right), u, \color{blue}{4 \cdot s}\right) \cdot u \]
  10. Applied rewrites72.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u \cdot s, 8 \cdot s\right), u, 4 \cdot s\right) \cdot u} \]
  11. Taylor expanded in s around -inf

    \[\leadsto \left(-1 \cdot \left(s \cdot \left(u \cdot \left(\frac{-64}{3} \cdot u - 8\right) - 4\right)\right)\right) \cdot u \]
  12. Step-by-step derivation
    1. Applied rewrites91.2%

      \[\leadsto \left(\left(-s\right) \cdot \left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right)\right) \cdot u \]
    2. Add Preprocessing

    Alternative 5: 91.1% accurate, 4.3× speedup?

    \[\begin{array}{l} \\ \left(\left(-s\right) \cdot u\right) \cdot \left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right) \end{array} \]
    (FPCore (s u)
     :precision binary32
     (* (* (- s) u) (- (* (- (* -21.333333333333332 u) 8.0) u) 4.0)))
    float code(float s, float u) {
    	return (-s * u) * ((((-21.333333333333332f * u) - 8.0f) * u) - 4.0f);
    }
    
    real(4) function code(s, u)
        real(4), intent (in) :: s
        real(4), intent (in) :: u
        code = (-s * u) * (((((-21.333333333333332e0) * u) - 8.0e0) * u) - 4.0e0)
    end function
    
    function code(s, u)
    	return Float32(Float32(Float32(-s) * u) * Float32(Float32(Float32(Float32(Float32(-21.333333333333332) * u) - Float32(8.0)) * u) - Float32(4.0)))
    end
    
    function tmp = code(s, u)
    	tmp = (-s * u) * ((((single(-21.333333333333332) * u) - single(8.0)) * u) - single(4.0));
    end
    
    \begin{array}{l}
    
    \\
    \left(\left(-s\right) \cdot u\right) \cdot \left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right)
    \end{array}
    
    Derivation
    1. Initial program 61.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. metadata-evalN/A

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

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

        \[\leadsto s \cdot \frac{0 \cdot 0 - \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{0 \cdot 0 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log \left(1 - 4 \cdot u\right)}} \]
    4. Applied rewrites43.2%

      \[\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}{{u}^{2} \cdot \left(-64 \cdot u - 16\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto s \cdot \frac{\left(-64 \cdot u - 16\right) \cdot \color{blue}{\left(u \cdot u\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      3. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right)\right) \cdot u} \]
      2. lower-*.f32N/A

        \[\leadsto \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right)\right) \cdot u} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(u \cdot \left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right) + 4 \cdot s\right)} \cdot u \]
      4. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right)\right) \cdot u} + 4 \cdot s\right) \cdot u \]
      5. lower-fma.f32N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(8 \cdot s + \frac{64}{3} \cdot \left(s \cdot u\right), u, 4 \cdot s\right)} \cdot u \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{64}{3} \cdot \left(s \cdot u\right) + 8 \cdot s}, u, 4 \cdot s\right) \cdot u \]
      7. lower-fma.f32N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{64}{3}, s \cdot u, 8 \cdot s\right)}, u, 4 \cdot s\right) \cdot u \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, \color{blue}{u \cdot s}, 8 \cdot s\right), u, 4 \cdot s\right) \cdot u \]
      9. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, \color{blue}{u \cdot s}, 8 \cdot s\right), u, 4 \cdot s\right) \cdot u \]
      10. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u \cdot s, \color{blue}{8 \cdot s}\right), u, 4 \cdot s\right) \cdot u \]
      11. lower-*.f3273.1

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u \cdot s, 8 \cdot s\right), u, \color{blue}{4 \cdot s}\right) \cdot u \]
    10. Applied rewrites73.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u \cdot s, 8 \cdot s\right), u, 4 \cdot s\right) \cdot u} \]
    11. Taylor expanded in s around -inf

      \[\leadsto -1 \cdot \color{blue}{\left(s \cdot \left(u \cdot \left(u \cdot \left(\frac{-64}{3} \cdot u - 8\right) - 4\right)\right)\right)} \]
    12. Step-by-step derivation
      1. Applied rewrites90.9%

        \[\leadsto \left(\left(-s\right) \cdot u\right) \cdot \color{blue}{\left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right)} \]
      2. Add Preprocessing

      Alternative 6: 87.3% accurate, 5.2× speedup?

      \[\begin{array}{l} \\ s \cdot \left(\left(8 \cdot u\right) \cdot u + u \cdot 4\right) \end{array} \]
      (FPCore (s u) :precision binary32 (* s (+ (* (* 8.0 u) u) (* u 4.0))))
      float code(float s, float u) {
      	return s * (((8.0f * u) * u) + (u * 4.0f));
      }
      
      real(4) function code(s, u)
          real(4), intent (in) :: s
          real(4), intent (in) :: u
          code = s * (((8.0e0 * u) * u) + (u * 4.0e0))
      end function
      
      function code(s, u)
      	return Float32(s * Float32(Float32(Float32(Float32(8.0) * u) * u) + Float32(u * Float32(4.0))))
      end
      
      function tmp = code(s, u)
      	tmp = s * (((single(8.0) * u) * u) + (u * single(4.0)));
      end
      
      \begin{array}{l}
      
      \\
      s \cdot \left(\left(8 \cdot u\right) \cdot u + u \cdot 4\right)
      \end{array}
      
      Derivation
      1. Initial program 61.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. metadata-evalN/A

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

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

          \[\leadsto s \cdot \frac{0 \cdot 0 - \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{0 \cdot 0 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log \left(1 - 4 \cdot u\right)}} \]
      4. Applied rewrites42.5%

        \[\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}{{u}^{2} \cdot \left(-64 \cdot u - 16\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

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

          \[\leadsto s \cdot \frac{\left(-64 \cdot u - 16\right) \cdot \color{blue}{\left(u \cdot u\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
        3. associate-*r*N/A

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

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

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

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

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

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

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

          \[\leadsto s \cdot \color{blue}{\left(\left(4 + 8 \cdot u\right) \cdot u\right)} \]
        2. lower-*.f32N/A

          \[\leadsto s \cdot \color{blue}{\left(\left(4 + 8 \cdot u\right) \cdot u\right)} \]
        3. +-commutativeN/A

          \[\leadsto s \cdot \left(\color{blue}{\left(8 \cdot u + 4\right)} \cdot u\right) \]
        4. lower-fma.f3273.1

          \[\leadsto s \cdot \left(\color{blue}{\mathsf{fma}\left(8, u, 4\right)} \cdot u\right) \]
      10. Applied rewrites72.9%

        \[\leadsto s \cdot \color{blue}{\left(\mathsf{fma}\left(8, u, 4\right) \cdot u\right)} \]
      11. Step-by-step derivation
        1. Applied rewrites86.7%

          \[\leadsto s \cdot \left(\left(8 \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
        2. Add Preprocessing

        Alternative 7: 87.1% accurate, 6.6× speedup?

        \[\begin{array}{l} \\ s \cdot \left(\left(4 - -8 \cdot u\right) \cdot u\right) \end{array} \]
        (FPCore (s u) :precision binary32 (* s (* (- 4.0 (* -8.0 u)) u)))
        float code(float s, float u) {
        	return s * ((4.0f - (-8.0f * u)) * u);
        }
        
        real(4) function code(s, u)
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = s * ((4.0e0 - ((-8.0e0) * u)) * u)
        end function
        
        function code(s, u)
        	return Float32(s * Float32(Float32(Float32(4.0) - Float32(Float32(-8.0) * u)) * u))
        end
        
        function tmp = code(s, u)
        	tmp = s * ((single(4.0) - (single(-8.0) * u)) * u);
        end
        
        \begin{array}{l}
        
        \\
        s \cdot \left(\left(4 - -8 \cdot u\right) \cdot u\right)
        \end{array}
        
        Derivation
        1. Initial program 61.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. metadata-evalN/A

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

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

            \[\leadsto s \cdot \frac{0 \cdot 0 - \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{0 \cdot 0 - \log \left(1 - 4 \cdot u\right) \cdot \log \left(1 - 4 \cdot u\right)}{\log \left(1 - 4 \cdot u\right)}} \]
        4. Applied rewrites40.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}{{u}^{2} \cdot \left(-64 \cdot u - 16\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
        6. Step-by-step derivation
          1. *-commutativeN/A

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

            \[\leadsto s \cdot \frac{\left(-64 \cdot u - 16\right) \cdot \color{blue}{\left(u \cdot u\right)}}{\mathsf{log1p}\left(-4 \cdot u\right)} \]
          3. associate-*r*N/A

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

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

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

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

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

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

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

            \[\leadsto s \cdot \color{blue}{\left(\left(4 + 8 \cdot u\right) \cdot u\right)} \]
          2. lower-*.f32N/A

            \[\leadsto s \cdot \color{blue}{\left(\left(4 + 8 \cdot u\right) \cdot u\right)} \]
          3. +-commutativeN/A

            \[\leadsto s \cdot \left(\color{blue}{\left(8 \cdot u + 4\right)} \cdot u\right) \]
          4. lower-fma.f3273.1

            \[\leadsto s \cdot \left(\color{blue}{\mathsf{fma}\left(8, u, 4\right)} \cdot u\right) \]
        10. Applied rewrites72.9%

          \[\leadsto s \cdot \color{blue}{\left(\mathsf{fma}\left(8, u, 4\right) \cdot u\right)} \]
        11. Step-by-step derivation
          1. Applied rewrites86.6%

            \[\leadsto s \cdot \left(\left(4 - -8 \cdot u\right) \cdot u\right) \]
          2. Add Preprocessing

          Alternative 8: 74.2% accurate, 11.4× speedup?

          \[\begin{array}{l} \\ s \cdot \left(4 \cdot u\right) \end{array} \]
          (FPCore (s u) :precision binary32 (* s (* 4.0 u)))
          float code(float s, float u) {
          	return s * (4.0f * u);
          }
          
          real(4) function code(s, u)
              real(4), intent (in) :: s
              real(4), intent (in) :: u
              code = s * (4.0e0 * u)
          end function
          
          function code(s, u)
          	return Float32(s * Float32(Float32(4.0) * u))
          end
          
          function tmp = code(s, u)
          	tmp = s * (single(4.0) * u);
          end
          
          \begin{array}{l}
          
          \\
          s \cdot \left(4 \cdot u\right)
          \end{array}
          
          Derivation
          1. Initial program 61.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-*.f3273.1

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

            \[\leadsto s \cdot \color{blue}{\left(4 \cdot u\right)} \]
          6. Add Preprocessing

          Reproduce

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