Disney BSSRDF, sample scattering profile, lower

Percentage Accurate: 60.8% → 98.9%
Time: 49.9s
Alternatives: 14
Speedup: 2.8×

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)\]
\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
(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)
use fmin_fmax_functions
    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
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)

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 14 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: 60.8% accurate, 1.0× speedup?

\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
(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)
use fmin_fmax_functions
    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
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)

Alternative 1: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.9599999785423279:\\ \;\;\;\;s \cdot \left(-0.5 \cdot \log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot u\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= (- 1.0 (* 4.0 u)) 0.9599999785423279)
  (* s (* -0.5 (log (* (fma u 4.0 -1.0) (fma u 4.0 -1.0)))))
  (*
   (fma (* (fma (fma 64.0 u 21.333333333333332) u 8.0) s) u (* 4.0 s))
   u)))
float code(float s, float u) {
	float tmp;
	if ((1.0f - (4.0f * u)) <= 0.9599999785423279f) {
		tmp = s * (-0.5f * logf((fmaf(u, 4.0f, -1.0f) * fmaf(u, 4.0f, -1.0f))));
	} else {
		tmp = fmaf((fmaf(fmaf(64.0f, u, 21.333333333333332f), u, 8.0f) * s), u, (4.0f * s)) * u;
	}
	return tmp;
}
function code(s, u)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(Float32(4.0) * u)) <= Float32(0.9599999785423279))
		tmp = Float32(s * Float32(Float32(-0.5) * log(Float32(fma(u, Float32(4.0), Float32(-1.0)) * fma(u, Float32(4.0), Float32(-1.0))))));
	else
		tmp = Float32(fma(Float32(fma(fma(Float32(64.0), u, Float32(21.333333333333332)), u, Float32(8.0)) * s), u, Float32(Float32(4.0) * s)) * u);
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.9599999785423279:\\
\;\;\;\;s \cdot \left(-0.5 \cdot \log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)\right)\\

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


\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 60.8%

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

      \[\leadsto s \cdot \color{blue}{\left(-0.5 \cdot \log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)\right)} \]

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

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
      8. lower-*.f3293.5%

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. Applied rewrites93.5%

      \[\leadsto \color{blue}{u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(s \cdot u\right) - \left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right) \]
      11. sub-flipN/A

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

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

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

        \[\leadsto 4 \cdot \left(u \cdot s\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right)\right)\right) \]
      15. associate-*r*N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot u, \color{blue}{s}, u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right) \]
    6. Applied rewrites94.0%

      \[\leadsto \mathsf{fma}\left(u \cdot 4, \color{blue}{s}, \left(u \cdot u\right) \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8 \cdot s\right)\right) \]
    7. Step-by-step derivation
      1. lift-fma.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot s + u \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8 \cdot s\right)\right) \cdot \color{blue}{u} \]
    8. Applied rewrites93.5%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot \color{blue}{u} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 98.9% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.968999981880188:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot u\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= (- 1.0 (* 4.0 u)) 0.968999981880188)
  (* (- (log (fma -4.0 u 1.0))) s)
  (*
   (fma (* (fma (fma 64.0 u 21.333333333333332) u 8.0) s) u (* 4.0 s))
   u)))
float code(float s, float u) {
	float tmp;
	if ((1.0f - (4.0f * u)) <= 0.968999981880188f) {
		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
	} else {
		tmp = fmaf((fmaf(fmaf(64.0f, u, 21.333333333333332f), u, 8.0f) * s), u, (4.0f * s)) * u;
	}
	return tmp;
}
function code(s, u)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(Float32(4.0) * u)) <= Float32(0.968999981880188))
		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
	else
		tmp = Float32(fma(Float32(fma(fma(Float32(64.0), u, Float32(21.333333333333332)), u, Float32(8.0)) * s), u, Float32(Float32(4.0) * s)) * u);
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.968999981880188:\\
\;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\

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


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

    1. Initial program 60.8%

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

      \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]

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

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
      8. lower-*.f3293.5%

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. Applied rewrites93.5%

      \[\leadsto \color{blue}{u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(s \cdot u\right) - \left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right) \]
      11. sub-flipN/A

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

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

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

        \[\leadsto 4 \cdot \left(u \cdot s\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right)\right)\right) \]
      15. associate-*r*N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot u, \color{blue}{s}, u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right) \]
    6. Applied rewrites94.0%

      \[\leadsto \mathsf{fma}\left(u \cdot 4, \color{blue}{s}, \left(u \cdot u\right) \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8 \cdot s\right)\right) \]
    7. Step-by-step derivation
      1. lift-fma.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot s + u \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8 \cdot s\right)\right) \cdot \color{blue}{u} \]
    8. Applied rewrites93.5%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot \color{blue}{u} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 98.9% accurate, 0.7× speedup?

\[s \cdot \left(-0.5 \cdot \mathsf{log1p}\left(u \cdot \left(16 \cdot u - 8\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (* s (* -0.5 (log1p (* u (- (* 16.0 u) 8.0))))))
float code(float s, float u) {
	return s * (-0.5f * log1pf((u * ((16.0f * u) - 8.0f))));
}
function code(s, u)
	return Float32(s * Float32(Float32(-0.5) * log1p(Float32(u * Float32(Float32(Float32(16.0) * u) - Float32(8.0))))))
end
s \cdot \left(-0.5 \cdot \mathsf{log1p}\left(u \cdot \left(16 \cdot u - 8\right)\right)\right)
Derivation
  1. Initial program 60.8%

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

    \[\leadsto s \cdot \color{blue}{\left(-0.5 \cdot \log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-log.f32N/A

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

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \color{blue}{\left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)}\right) \]
    3. fabs-sqrN/A

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

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \left(\left|\color{blue}{\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)}\right|\right)\right) \]
    5. rem-exp-logN/A

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \left(\left|\color{blue}{e^{\log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)}}\right|\right)\right) \]
    6. lift-log.f32N/A

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \left(\left|e^{\color{blue}{\log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)}}\right|\right)\right) \]
    7. lift-log.f32N/A

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \left(\left|e^{\color{blue}{\log \left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)}}\right|\right)\right) \]
    8. rem-exp-logN/A

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

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \left(\left|\color{blue}{\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)}\right|\right)\right) \]
    10. fabs-sqrN/A

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \color{blue}{\left(\mathsf{fma}\left(u, 4, -1\right) \cdot \mathsf{fma}\left(u, 4, -1\right)\right)}\right) \]
    11. pow2N/A

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

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

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \log \left({\left(\color{blue}{u \cdot 4} + -1\right)}^{2}\right)\right) \]
    14. sum-square-powN/A

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

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

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

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \color{blue}{\mathsf{log1p}\left({\left(u \cdot 4\right)}^{2} + 2 \cdot \left(\left(u \cdot 4\right) \cdot -1\right)\right)}\right) \]
  4. Applied rewrites98.9%

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

    \[\leadsto s \cdot \left(-0.5 \cdot \mathsf{log1p}\left(\color{blue}{u \cdot \left(16 \cdot u - 8\right)}\right)\right) \]
  6. Step-by-step derivation
    1. lower-*.f32N/A

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

      \[\leadsto s \cdot \left(\frac{-1}{2} \cdot \mathsf{log1p}\left(u \cdot \left(16 \cdot u - \color{blue}{8}\right)\right)\right) \]
    3. lower-*.f3298.9%

      \[\leadsto s \cdot \left(-0.5 \cdot \mathsf{log1p}\left(u \cdot \left(16 \cdot u - 8\right)\right)\right) \]
  7. Applied rewrites98.9%

    \[\leadsto s \cdot \left(-0.5 \cdot \mathsf{log1p}\left(\color{blue}{u \cdot \left(16 \cdot u - 8\right)}\right)\right) \]
  8. Add Preprocessing

Alternative 4: 98.6% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.968999981880188:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\left(s \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right), u, 4\right)\right) \cdot u\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= (- 1.0 (* 4.0 u)) 0.968999981880188)
  (* (- (log (fma -4.0 u 1.0))) s)
  (* (* s (fma (fma (fma 64.0 u 21.333333333333332) u 8.0) u 4.0)) u)))
float code(float s, float u) {
	float tmp;
	if ((1.0f - (4.0f * u)) <= 0.968999981880188f) {
		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
	} else {
		tmp = (s * fmaf(fmaf(fmaf(64.0f, u, 21.333333333333332f), u, 8.0f), u, 4.0f)) * u;
	}
	return tmp;
}
function code(s, u)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(Float32(4.0) * u)) <= Float32(0.968999981880188))
		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
	else
		tmp = Float32(Float32(s * fma(fma(fma(Float32(64.0), u, Float32(21.333333333333332)), u, Float32(8.0)), u, Float32(4.0))) * u);
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.968999981880188:\\
\;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\

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


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

    1. Initial program 60.8%

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

      \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]

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

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
      8. lower-*.f3293.5%

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. Applied rewrites93.5%

      \[\leadsto \color{blue}{u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(s \cdot u\right) - \left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right) \]
      11. sub-flipN/A

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

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

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

        \[\leadsto 4 \cdot \left(u \cdot s\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right)\right)\right) \]
      15. associate-*r*N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot u, \color{blue}{s}, u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right) \]
    6. Applied rewrites94.0%

      \[\leadsto \mathsf{fma}\left(u \cdot 4, \color{blue}{s}, \left(u \cdot u\right) \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8 \cdot s\right)\right) \]
    7. Step-by-step derivation
      1. lift-fma.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot s + u \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8 \cdot s\right)\right) \cdot \color{blue}{u} \]
    8. Applied rewrites93.5%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot \color{blue}{u} \]
    9. Step-by-step derivation
      1. lift-fma.f32N/A

        \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8\right) \cdot s\right) \cdot u + 4 \cdot s\right) \cdot u \]
      2. lift-*.f32N/A

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

        \[\leadsto \left(\left(s \cdot \mathsf{fma}\left(\mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8\right)\right) \cdot u + 4 \cdot s\right) \cdot u \]
      4. associate-*l*N/A

        \[\leadsto \left(s \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8\right) \cdot u\right) + 4 \cdot s\right) \cdot u \]
      5. lift-*.f32N/A

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

        \[\leadsto \left(s \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8\right) \cdot u\right) + s \cdot 4\right) \cdot u \]
      7. distribute-lft-outN/A

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

        \[\leadsto \left(s \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8\right) \cdot u + 4\right)\right) \cdot u \]
      9. lower-fma.f3293.3%

        \[\leadsto \left(s \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right), u, 4\right)\right) \cdot u \]
    10. Applied rewrites93.3%

      \[\leadsto \left(s \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8\right), u, 4\right)\right) \cdot u \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.4% accurate, 0.7× speedup?

\[\begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.9850000143051147:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot u\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= (- 1.0 (* 4.0 u)) 0.9850000143051147)
  (* (- (log (fma -4.0 u 1.0))) s)
  (* (fma (* (fma 21.333333333333332 u 8.0) s) u (* 4.0 s)) u)))
float code(float s, float u) {
	float tmp;
	if ((1.0f - (4.0f * u)) <= 0.9850000143051147f) {
		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
	} else {
		tmp = fmaf((fmaf(21.333333333333332f, u, 8.0f) * s), u, (4.0f * s)) * u;
	}
	return tmp;
}
function code(s, u)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(Float32(4.0) * u)) <= Float32(0.9850000143051147))
		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
	else
		tmp = Float32(fma(Float32(fma(Float32(21.333333333333332), u, Float32(8.0)) * s), u, Float32(Float32(4.0) * s)) * u);
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.9850000143051147:\\
\;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot u\\


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

    1. Initial program 60.8%

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

      \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]

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

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
      8. lower-*.f3293.5%

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. Applied rewrites93.5%

      \[\leadsto \color{blue}{u \cdot \mathsf{fma}\left(4, s, u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(21.333333333333332, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(s \cdot u\right) - \left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right) \]
      11. sub-flipN/A

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

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

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

        \[\leadsto 4 \cdot \left(u \cdot s\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right)\right)\right)\right) \]
      15. associate-*r*N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot u, \color{blue}{s}, u \cdot \left(u \cdot \mathsf{fma}\left(8, s, u \cdot \mathsf{fma}\left(\frac{64}{3}, s, 64 \cdot \left(s \cdot u\right)\right)\right)\right)\right) \]
    6. Applied rewrites94.0%

      \[\leadsto \mathsf{fma}\left(u \cdot 4, \color{blue}{s}, \left(u \cdot u\right) \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, 21.333333333333332\right), u, 8 \cdot s\right)\right) \]
    7. Step-by-step derivation
      1. lift-fma.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot s + u \cdot \mathsf{fma}\left(s \cdot \mathsf{fma}\left(64, u, \frac{64}{3}\right), u, 8 \cdot s\right)\right) \cdot \color{blue}{u} \]
    8. Applied rewrites93.5%

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right) \cdot s, u, 4 \cdot s\right) \cdot u \]
    11. Recombined 2 regimes into one program.
    12. Add Preprocessing

    Alternative 6: 98.4% accurate, 0.8× speedup?

    \[\begin{array}{l} \mathbf{if}\;u \leq 0.004000000189989805:\\ \;\;\;\;\left(u - \mathsf{fma}\left(\mathsf{fma}\left(-21.333333333333332, u, -8\right), u, -3\right) \cdot u\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \end{array} \]
    (FPCore (s u)
      :precision binary32
      (if (<= u 0.004000000189989805)
      (* (- u (* (fma (fma -21.333333333333332 u -8.0) u -3.0) u)) s)
      (* (- (log (fma -4.0 u 1.0))) s)))
    float code(float s, float u) {
    	float tmp;
    	if (u <= 0.004000000189989805f) {
    		tmp = (u - (fmaf(fmaf(-21.333333333333332f, u, -8.0f), u, -3.0f) * u)) * s;
    	} else {
    		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
    	}
    	return tmp;
    }
    
    function code(s, u)
    	tmp = Float32(0.0)
    	if (u <= Float32(0.004000000189989805))
    		tmp = Float32(Float32(u - Float32(fma(fma(Float32(-21.333333333333332), u, Float32(-8.0)), u, Float32(-3.0)) * u)) * s);
    	else
    		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
    	end
    	return tmp
    end
    
    \begin{array}{l}
    \mathbf{if}\;u \leq 0.004000000189989805:\\
    \;\;\;\;\left(u - \mathsf{fma}\left(\mathsf{fma}\left(-21.333333333333332, u, -8\right), u, -3\right) \cdot u\right) \cdot s\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if u < 0.00400000019

      1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 4\right) \cdot u\right) \cdot s} \]
      6. Step-by-step derivation
        1. lift-fma.f32N/A

          \[\leadsto \left(\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right) \cdot u + 4\right) \cdot u\right) \cdot s \]
        2. metadata-evalN/A

          \[\leadsto \left(\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right) \cdot u + \left(3 + 1\right)\right) \cdot u\right) \cdot s \]
        3. associate-+r+N/A

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

          \[\leadsto \left(\left(\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right) \cdot u + 3\right) + 1\right) \cdot u\right) \cdot s \]
        5. lower-fma.f3291.1%

          \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right) + 1\right) \cdot u\right) \cdot s \]
      7. Applied rewrites91.1%

        \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right) + 1\right) \cdot u\right) \cdot s \]
      8. Step-by-step derivation
        1. lift-*.f32N/A

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

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

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

          \[\leadsto \left(u \cdot \left(1 + \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right), u, 3\right)}\right)\right) \cdot s \]
        5. distribute-rgt-inN/A

          \[\leadsto \left(1 \cdot u + \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right), u, 3\right) \cdot u}\right) \cdot s \]
        6. fp-cancel-sign-sub-invN/A

          \[\leadsto \left(1 \cdot u - \color{blue}{\left(\mathsf{neg}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right), u, 3\right)\right)\right) \cdot u}\right) \cdot s \]
        7. *-lft-identityN/A

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

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

          \[\leadsto \left(u - \left(\mathsf{neg}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right), u, 3\right)\right)\right) \cdot \color{blue}{u}\right) \cdot s \]
      9. Applied rewrites91.3%

        \[\leadsto \left(u - \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(-21.333333333333332, u, -8\right), u, -3\right) \cdot u}\right) \cdot s \]

      if 0.00400000019 < u

      1. Initial program 60.8%

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

        \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 7: 98.3% accurate, 0.9× speedup?

    \[\begin{array}{l} \mathbf{if}\;u \leq 0.004000000189989805:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right), u, u\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \end{array} \]
    (FPCore (s u)
      :precision binary32
      (if (<= u 0.004000000189989805)
      (* (fma (fma (fma 21.333333333333332 u 8.0) u 3.0) u u) s)
      (* (- (log (fma -4.0 u 1.0))) s)))
    float code(float s, float u) {
    	float tmp;
    	if (u <= 0.004000000189989805f) {
    		tmp = fmaf(fmaf(fmaf(21.333333333333332f, u, 8.0f), u, 3.0f), u, u) * s;
    	} else {
    		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
    	}
    	return tmp;
    }
    
    function code(s, u)
    	tmp = Float32(0.0)
    	if (u <= Float32(0.004000000189989805))
    		tmp = Float32(fma(fma(fma(Float32(21.333333333333332), u, Float32(8.0)), u, Float32(3.0)), u, u) * s);
    	else
    		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
    	end
    	return tmp
    end
    
    \begin{array}{l}
    \mathbf{if}\;u \leq 0.004000000189989805:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right), u, u\right) \cdot s\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if u < 0.00400000019

      1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 4\right) \cdot u\right) \cdot s} \]
      6. Step-by-step derivation
        1. lift-fma.f32N/A

          \[\leadsto \left(\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right) \cdot u + 4\right) \cdot u\right) \cdot s \]
        2. metadata-evalN/A

          \[\leadsto \left(\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right) \cdot u + \left(3 + 1\right)\right) \cdot u\right) \cdot s \]
        3. associate-+r+N/A

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

          \[\leadsto \left(\left(\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right) \cdot u + 3\right) + 1\right) \cdot u\right) \cdot s \]
        5. lower-fma.f3291.1%

          \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right) + 1\right) \cdot u\right) \cdot s \]
      7. Applied rewrites91.1%

        \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right) + 1\right) \cdot u\right) \cdot s \]
      8. Step-by-step derivation
        1. lift-*.f32N/A

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

          \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{64}{3}, u, 8\right), u, 3\right) + 1\right) \cdot u\right) \cdot s \]
        3. distribute-lft1-inN/A

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 3\right), \color{blue}{u}, u\right) \cdot s \]

      if 0.00400000019 < u

      1. Initial program 60.8%

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

        \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 8: 98.2% accurate, 0.9× speedup?

    \[\begin{array}{l} \mathbf{if}\;u \leq 0.004000000189989805:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 4\right) \cdot u\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \end{array} \]
    (FPCore (s u)
      :precision binary32
      (if (<= u 0.004000000189989805)
      (* (* (fma (fma 21.333333333333332 u 8.0) u 4.0) u) s)
      (* (- (log (fma -4.0 u 1.0))) s)))
    float code(float s, float u) {
    	float tmp;
    	if (u <= 0.004000000189989805f) {
    		tmp = (fmaf(fmaf(21.333333333333332f, u, 8.0f), u, 4.0f) * u) * s;
    	} else {
    		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
    	}
    	return tmp;
    }
    
    function code(s, u)
    	tmp = Float32(0.0)
    	if (u <= Float32(0.004000000189989805))
    		tmp = Float32(Float32(fma(fma(Float32(21.333333333333332), u, Float32(8.0)), u, Float32(4.0)) * u) * s);
    	else
    		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
    	end
    	return tmp
    end
    
    \begin{array}{l}
    \mathbf{if}\;u \leq 0.004000000189989805:\\
    \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 4\right) \cdot u\right) \cdot s\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if u < 0.00400000019

      1. Initial program 60.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(21.333333333333332, u, 8\right), u, 4\right) \cdot u\right) \cdot s} \]

      if 0.00400000019 < u

      1. Initial program 60.8%

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

        \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 9: 97.1% accurate, 1.0× speedup?

    \[\begin{array}{l} \mathbf{if}\;u \leq 0.0007999999797903001:\\ \;\;\;\;u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\ \end{array} \]
    (FPCore (s u)
      :precision binary32
      (if (<= u 0.0007999999797903001)
      (* u (fma 4.0 s (* 8.0 (* s u))))
      (* (- (log (fma -4.0 u 1.0))) s)))
    float code(float s, float u) {
    	float tmp;
    	if (u <= 0.0007999999797903001f) {
    		tmp = u * fmaf(4.0f, s, (8.0f * (s * u)));
    	} else {
    		tmp = -logf(fmaf(-4.0f, u, 1.0f)) * s;
    	}
    	return tmp;
    }
    
    function code(s, u)
    	tmp = Float32(0.0)
    	if (u <= Float32(0.0007999999797903001))
    		tmp = Float32(u * fma(Float32(4.0), s, Float32(Float32(8.0) * Float32(s * u))));
    	else
    		tmp = Float32(Float32(-log(fma(Float32(-4.0), u, Float32(1.0)))) * s);
    	end
    	return tmp
    end
    
    \begin{array}{l}
    \mathbf{if}\;u \leq 0.0007999999797903001:\\
    \;\;\;\;u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if u < 7.9999998e-4

      1. Initial program 60.8%

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

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

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

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

          \[\leadsto u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right) \]
        4. lower-*.f3287.3%

          \[\leadsto u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right) \]
      4. Applied rewrites87.3%

        \[\leadsto \color{blue}{u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right)} \]

      if 7.9999998e-4 < u

      1. Initial program 60.8%

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

        \[\leadsto \color{blue}{\left(-\log \left(\mathsf{fma}\left(-4, u, 1\right)\right)\right) \cdot s} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 10: 87.3% accurate, 1.3× speedup?

    \[u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right) \]
    (FPCore (s u)
      :precision binary32
      (* u (fma 4.0 s (* 8.0 (* s u)))))
    float code(float s, float u) {
    	return u * fmaf(4.0f, s, (8.0f * (s * u)));
    }
    
    function code(s, u)
    	return Float32(u * fma(Float32(4.0), s, Float32(Float32(8.0) * Float32(s * u))))
    end
    
    u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right)
    
    Derivation
    1. Initial program 60.8%

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

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

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

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

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right) \]
      4. lower-*.f3287.3%

        \[\leadsto u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right) \]
    4. Applied rewrites87.3%

      \[\leadsto \color{blue}{u \cdot \mathsf{fma}\left(4, s, 8 \cdot \left(s \cdot u\right)\right)} \]
    5. Add Preprocessing

    Alternative 11: 87.1% accurate, 1.6× speedup?

    \[\left(\mathsf{fma}\left(8, u, 4\right) \cdot u\right) \cdot s \]
    (FPCore (s u)
      :precision binary32
      (* (* (fma 8.0 u 4.0) u) s))
    float code(float s, float u) {
    	return (fmaf(8.0f, u, 4.0f) * u) * s;
    }
    
    function code(s, u)
    	return Float32(Float32(fma(Float32(8.0), u, Float32(4.0)) * u) * s)
    end
    
    \left(\mathsf{fma}\left(8, u, 4\right) \cdot u\right) \cdot s
    
    Derivation
    1. Initial program 60.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(8, u, 4\right) \cdot u\right) \cdot s \]
      2. Add Preprocessing

      Alternative 12: 74.4% accurate, 2.8× speedup?

      \[s \cdot \left(u \cdot 4\right) \]
      (FPCore (s u)
        :precision binary32
        (* s (* u 4.0)))
      float code(float s, float u) {
      	return s * (u * 4.0f);
      }
      
      real(4) function code(s, u)
      use fmin_fmax_functions
          real(4), intent (in) :: s
          real(4), intent (in) :: u
          code = s * (u * 4.0e0)
      end function
      
      function code(s, u)
      	return Float32(s * Float32(u * Float32(4.0)))
      end
      
      function tmp = code(s, u)
      	tmp = s * (u * single(4.0));
      end
      
      s \cdot \left(u \cdot 4\right)
      
      Derivation
      1. Initial program 60.8%

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

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

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

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

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

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

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

        \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + 21.333333333333332 \cdot u\right)\right)\right)} \]
      5. Taylor expanded in u around 0

        \[\leadsto s \cdot \left(u \cdot 4\right) \]
      6. Step-by-step derivation
        1. Applied rewrites74.4%

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

        Alternative 13: 74.2% accurate, 2.8× speedup?

        \[4 \cdot \left(s \cdot u\right) \]
        (FPCore (s u)
          :precision binary32
          (* 4.0 (* s u)))
        float code(float s, float u) {
        	return 4.0f * (s * u);
        }
        
        real(4) function code(s, u)
        use fmin_fmax_functions
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = 4.0e0 * (s * u)
        end function
        
        function code(s, u)
        	return Float32(Float32(4.0) * Float32(s * u))
        end
        
        function tmp = code(s, u)
        	tmp = single(4.0) * (s * u);
        end
        
        4 \cdot \left(s \cdot u\right)
        
        Derivation
        1. Initial program 60.8%

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

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

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

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

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

        Alternative 14: 16.6% accurate, 19.4× speedup?

        \[0 \]
        (FPCore (s u)
          :precision binary32
          0.0)
        float code(float s, float u) {
        	return 0.0f;
        }
        
        real(4) function code(s, u)
        use fmin_fmax_functions
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = 0.0e0
        end function
        
        function code(s, u)
        	return Float32(0.0)
        end
        
        function tmp = code(s, u)
        	tmp = single(0.0);
        end
        
        0
        
        Derivation
        1. Initial program 60.8%

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

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

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

            \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{u \cdot 4}}\right) \]
          4. fp-cancel-sub-sign-invN/A

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

            \[\leadsto s \cdot \log \left(\frac{1}{1 + \color{blue}{4 \cdot \left(\mathsf{neg}\left(u\right)\right)}}\right) \]
          6. fp-cancel-sign-sub-invN/A

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

            \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{\left(\mathsf{neg}\left(u\right)\right) \cdot \left(\mathsf{neg}\left(4\right)\right)}}\right) \]
          8. distribute-lft-neg-inN/A

            \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{\left(\mathsf{neg}\left(u \cdot \left(\mathsf{neg}\left(4\right)\right)\right)\right)}}\right) \]
          9. distribute-rgt-neg-outN/A

            \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{u \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(4\right)\right)\right)\right)}}\right) \]
          10. remove-double-negN/A

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

            \[\leadsto s \cdot \log \left(\frac{1}{1 - u \cdot \color{blue}{\left(3 + 1\right)}}\right) \]
          12. distribute-lft-inN/A

            \[\leadsto s \cdot \log \left(\frac{1}{1 - \color{blue}{\left(u \cdot 3 + u \cdot 1\right)}}\right) \]
          13. *-rgt-identityN/A

            \[\leadsto s \cdot \log \left(\frac{1}{1 - \left(u \cdot 3 + \color{blue}{u}\right)}\right) \]
          14. associate--r+N/A

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

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

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

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

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

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

          \[\leadsto \color{blue}{0} \]
        5. Add Preprocessing

        Reproduce

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