Disney BSSRDF, sample scattering profile, upper

Percentage Accurate: 95.9% → 98.3%
Time: 13.8s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\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 9 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: 95.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right) \cdot \left(s \cdot -3\right) \end{array} \]
(FPCore (s u) :precision binary32 (* (log1p (/ (+ u -0.25) -0.75)) (* s -3.0)))
float code(float s, float u) {
	return log1pf(((u + -0.25f) / -0.75f)) * (s * -3.0f);
}
function code(s, u)
	return Float32(log1p(Float32(Float32(u + Float32(-0.25)) / Float32(-0.75))) * Float32(s * Float32(-3.0)))
end
\begin{array}{l}

\\
\mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right) \cdot \left(s \cdot -3\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. log-rec96.5%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]
    2. distribute-rgt-neg-out96.5%

      \[\leadsto \color{blue}{-\left(3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    3. distribute-lft-neg-out96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    4. *-commutative96.5%

      \[\leadsto \left(-\color{blue}{s \cdot 3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    5. distribute-rgt-neg-in96.5%

      \[\leadsto \color{blue}{\left(s \cdot \left(-3\right)\right)} \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    6. metadata-eval96.5%

      \[\leadsto \left(s \cdot \color{blue}{-3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    7. sub-neg96.5%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)} \]
    8. log1p-define98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\mathsf{log1p}\left(-\frac{u - 0.25}{0.75}\right)} \]
    9. distribute-neg-frac298.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{u - 0.25}{-0.75}}\right) \]
    10. sub-neg98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{u + \left(-0.25\right)}}{-0.75}\right) \]
    11. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + \color{blue}{-0.25}}{-0.75}\right) \]
    12. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{\color{blue}{-0.75}}\right) \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right)} \]
  4. Add Preprocessing
  5. Final simplification98.3%

    \[\leadsto \mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right) \cdot \left(s \cdot -3\right) \]
  6. Add Preprocessing

Alternative 2: 96.1% accurate, 1.0× speedup?

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

\\
-3 \cdot \left(s \cdot \log \left(1.3333333333333333 - u \cdot 1.3333333333333333\right)\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. associate-*l*95.6%

      \[\leadsto \color{blue}{3 \cdot \left(s \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)\right)} \]
    2. log-rec96.5%

      \[\leadsto 3 \cdot \left(s \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)}\right) \]
    3. div-sub95.7%

      \[\leadsto 3 \cdot \left(s \cdot \left(-\log \left(1 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right)\right)\right) \]
    4. metadata-eval95.7%

      \[\leadsto 3 \cdot \left(s \cdot \left(-\log \left(1 - \left(\frac{u}{0.75} - \color{blue}{0.3333333333333333}\right)\right)\right)\right) \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{3 \cdot \left(s \cdot \left(-\log \left(1 - \left(\frac{u}{0.75} - 0.3333333333333333\right)\right)\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in s around 0 96.2%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \log \left(1.3333333333333333 - 1.3333333333333333 \cdot u\right)\right)} \]
  6. Final simplification96.2%

    \[\leadsto -3 \cdot \left(s \cdot \log \left(1.3333333333333333 - u \cdot 1.3333333333333333\right)\right) \]
  7. Add Preprocessing

Alternative 3: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ -3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right)\right) \end{array} \]
(FPCore (s u)
 :precision binary32
 (* -3.0 (* s (log1p (* (+ u -0.25) -1.3333333333333333)))))
float code(float s, float u) {
	return -3.0f * (s * log1pf(((u + -0.25f) * -1.3333333333333333f)));
}
function code(s, u)
	return Float32(Float32(-3.0) * Float32(s * log1p(Float32(Float32(u + Float32(-0.25)) * Float32(-1.3333333333333333)))))
end
\begin{array}{l}

\\
-3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right)\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. log-rec96.5%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]
    2. distribute-rgt-neg-out96.5%

      \[\leadsto \color{blue}{-\left(3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    3. distribute-lft-neg-out96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    4. *-commutative96.5%

      \[\leadsto \left(-\color{blue}{s \cdot 3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    5. distribute-rgt-neg-in96.5%

      \[\leadsto \color{blue}{\left(s \cdot \left(-3\right)\right)} \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    6. metadata-eval96.5%

      \[\leadsto \left(s \cdot \color{blue}{-3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    7. sub-neg96.5%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)} \]
    8. log1p-define98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\mathsf{log1p}\left(-\frac{u - 0.25}{0.75}\right)} \]
    9. distribute-neg-frac298.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{u - 0.25}{-0.75}}\right) \]
    10. sub-neg98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{u + \left(-0.25\right)}}{-0.75}\right) \]
    11. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + \color{blue}{-0.25}}{-0.75}\right) \]
    12. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{\color{blue}{-0.75}}\right) \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in s around 0 96.4%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \log \left(1 + -1.3333333333333333 \cdot \left(u - 0.25\right)\right)\right)} \]
  6. Step-by-step derivation
    1. log1p-define97.8%

      \[\leadsto -3 \cdot \left(s \cdot \color{blue}{\mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right)}\right) \]
    2. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \color{blue}{\left(u + \left(-0.25\right)\right)}\right)\right) \]
    3. metadata-eval97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u + \color{blue}{-0.25}\right)\right)\right) \]
    4. distribute-rgt-in96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333 + -0.25 \cdot -1.3333333333333333}\right)\right) \]
    5. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{0.3333333333333333}\right)\right) \]
    6. fma-undefine97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)}\right)\right) \]
  7. Simplified97.8%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)} \]
  8. Step-by-step derivation
    1. fma-undefine96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333 + 0.3333333333333333}\right)\right) \]
    2. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{-0.25 \cdot -1.3333333333333333}\right)\right) \]
    3. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{\left(-0.25\right)} \cdot -1.3333333333333333\right)\right) \]
    4. distribute-rgt-in97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{-1.3333333333333333 \cdot \left(u + \left(-0.25\right)\right)}\right)\right) \]
    5. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \color{blue}{\left(u - 0.25\right)}\right)\right) \]
    6. *-commutative97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\left(u - 0.25\right) \cdot -1.3333333333333333}\right)\right) \]
    7. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\left(u + \left(-0.25\right)\right)} \cdot -1.3333333333333333\right)\right) \]
    8. metadata-eval97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(u + \color{blue}{-0.25}\right) \cdot -1.3333333333333333\right)\right) \]
  9. Applied egg-rr97.8%

    \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\left(u + -0.25\right) \cdot -1.3333333333333333}\right)\right) \]
  10. Final simplification97.8%

    \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right)\right) \]
  11. Add Preprocessing

Alternative 4: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right) \end{array} \]
(FPCore (s u)
 :precision binary32
 (* (* s -3.0) (log1p (* (+ u -0.25) -1.3333333333333333))))
float code(float s, float u) {
	return (s * -3.0f) * log1pf(((u + -0.25f) * -1.3333333333333333f));
}
function code(s, u)
	return Float32(Float32(s * Float32(-3.0)) * log1p(Float32(Float32(u + Float32(-0.25)) * Float32(-1.3333333333333333))))
end
\begin{array}{l}

\\
\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. log-rec96.5%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]
    2. distribute-rgt-neg-out96.5%

      \[\leadsto \color{blue}{-\left(3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    3. distribute-lft-neg-out96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    4. *-commutative96.5%

      \[\leadsto \left(-\color{blue}{s \cdot 3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    5. distribute-rgt-neg-in96.5%

      \[\leadsto \color{blue}{\left(s \cdot \left(-3\right)\right)} \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    6. metadata-eval96.5%

      \[\leadsto \left(s \cdot \color{blue}{-3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    7. sub-neg96.5%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)} \]
    8. log1p-define98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\mathsf{log1p}\left(-\frac{u - 0.25}{0.75}\right)} \]
    9. distribute-neg-frac298.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{u - 0.25}{-0.75}}\right) \]
    10. sub-neg98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{u + \left(-0.25\right)}}{-0.75}\right) \]
    11. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + \color{blue}{-0.25}}{-0.75}\right) \]
    12. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{\color{blue}{-0.75}}\right) \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in s around 0 96.4%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \log \left(1 + -1.3333333333333333 \cdot \left(u - 0.25\right)\right)\right)} \]
  6. Step-by-step derivation
    1. log1p-define97.8%

      \[\leadsto -3 \cdot \left(s \cdot \color{blue}{\mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right)}\right) \]
    2. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \color{blue}{\left(u + \left(-0.25\right)\right)}\right)\right) \]
    3. metadata-eval97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u + \color{blue}{-0.25}\right)\right)\right) \]
    4. distribute-rgt-in96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333 + -0.25 \cdot -1.3333333333333333}\right)\right) \]
    5. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{0.3333333333333333}\right)\right) \]
    6. fma-undefine97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)}\right)\right) \]
  7. Simplified97.8%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)} \]
  8. Step-by-step derivation
    1. fma-undefine96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333 + 0.3333333333333333}\right)\right) \]
    2. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{-0.25 \cdot -1.3333333333333333}\right)\right) \]
    3. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{\left(-0.25\right)} \cdot -1.3333333333333333\right)\right) \]
    4. distribute-rgt-in97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{-1.3333333333333333 \cdot \left(u + \left(-0.25\right)\right)}\right)\right) \]
    5. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \color{blue}{\left(u - 0.25\right)}\right)\right) \]
    6. *-commutative97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\left(u - 0.25\right) \cdot -1.3333333333333333}\right)\right) \]
    7. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\left(u + \left(-0.25\right)\right)} \cdot -1.3333333333333333\right)\right) \]
    8. metadata-eval97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(u + \color{blue}{-0.25}\right) \cdot -1.3333333333333333\right)\right) \]
  9. Applied egg-rr97.8%

    \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\left(u + -0.25\right) \cdot -1.3333333333333333}\right)\right) \]
  10. Taylor expanded in s around 0 96.4%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \log \left(1 + -1.3333333333333333 \cdot \left(u - 0.25\right)\right)\right)} \]
  11. Step-by-step derivation
    1. associate-*r*96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 + -1.3333333333333333 \cdot \left(u - 0.25\right)\right)} \]
    2. log1p-define97.9%

      \[\leadsto \left(-3 \cdot s\right) \cdot \color{blue}{\mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right)} \]
    3. sub-neg97.9%

      \[\leadsto \left(-3 \cdot s\right) \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \color{blue}{\left(u + \left(-0.25\right)\right)}\right) \]
    4. metadata-eval97.9%

      \[\leadsto \left(-3 \cdot s\right) \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u + \color{blue}{-0.25}\right)\right) \]
  12. Simplified97.9%

    \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u + -0.25\right)\right)} \]
  13. Final simplification97.9%

    \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right) \]
  14. Add Preprocessing

Alternative 5: 18.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333\right)\right) \end{array} \]
(FPCore (s u)
 :precision binary32
 (* -3.0 (* s (log1p (* u -1.3333333333333333)))))
float code(float s, float u) {
	return -3.0f * (s * log1pf((u * -1.3333333333333333f)));
}
function code(s, u)
	return Float32(Float32(-3.0) * Float32(s * log1p(Float32(u * Float32(-1.3333333333333333)))))
end
\begin{array}{l}

\\
-3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333\right)\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. log-rec96.5%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]
    2. distribute-rgt-neg-out96.5%

      \[\leadsto \color{blue}{-\left(3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    3. distribute-lft-neg-out96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    4. *-commutative96.5%

      \[\leadsto \left(-\color{blue}{s \cdot 3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    5. distribute-rgt-neg-in96.5%

      \[\leadsto \color{blue}{\left(s \cdot \left(-3\right)\right)} \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    6. metadata-eval96.5%

      \[\leadsto \left(s \cdot \color{blue}{-3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    7. sub-neg96.5%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)} \]
    8. log1p-define98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\mathsf{log1p}\left(-\frac{u - 0.25}{0.75}\right)} \]
    9. distribute-neg-frac298.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{u - 0.25}{-0.75}}\right) \]
    10. sub-neg98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{u + \left(-0.25\right)}}{-0.75}\right) \]
    11. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + \color{blue}{-0.25}}{-0.75}\right) \]
    12. metadata-eval98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{\color{blue}{-0.75}}\right) \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{u + -0.25}{-0.75}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in s around 0 96.4%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \log \left(1 + -1.3333333333333333 \cdot \left(u - 0.25\right)\right)\right)} \]
  6. Step-by-step derivation
    1. log1p-define97.8%

      \[\leadsto -3 \cdot \left(s \cdot \color{blue}{\mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right)}\right) \]
    2. sub-neg97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \color{blue}{\left(u + \left(-0.25\right)\right)}\right)\right) \]
    3. metadata-eval97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u + \color{blue}{-0.25}\right)\right)\right) \]
    4. distribute-rgt-in96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333 + -0.25 \cdot -1.3333333333333333}\right)\right) \]
    5. metadata-eval96.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{0.3333333333333333}\right)\right) \]
    6. fma-undefine97.8%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)}\right)\right) \]
  7. Simplified97.8%

    \[\leadsto \color{blue}{-3 \cdot \left(s \cdot \mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)} \]
  8. Taylor expanded in u around inf 20.4%

    \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{-1.3333333333333333 \cdot u}\right)\right) \]
  9. Step-by-step derivation
    1. *-commutative20.4%

      \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333}\right)\right) \]
  10. Simplified20.4%

    \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333}\right)\right) \]
  11. Final simplification20.4%

    \[\leadsto -3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333\right)\right) \]
  12. Add Preprocessing

Alternative 6: 25.8% accurate, 1.1× speedup?

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

\\
3 \cdot \left(s \cdot \left(u + \log 0.75\right)\right)
\end{array}
Derivation
  1. Initial program 95.6%

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

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

    \[\leadsto 3 \cdot \left(s \cdot \color{blue}{\left(u + \log 0.75\right)}\right) \]
  5. Final simplification25.7%

    \[\leadsto 3 \cdot \left(s \cdot \left(u + \log 0.75\right)\right) \]
  6. Add Preprocessing

Alternative 7: 25.8% accurate, 1.1× speedup?

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

\\
s \cdot \left(u \cdot 3 + \log 0.421875\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. log-rec96.5%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]
    2. distribute-rgt-neg-out96.5%

      \[\leadsto \color{blue}{-\left(3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    3. distribute-lft-neg-out96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    4. *-commutative96.5%

      \[\leadsto \left(-\color{blue}{s \cdot 3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    5. distribute-rgt-neg-in96.5%

      \[\leadsto \color{blue}{\left(s \cdot \left(-3\right)\right)} \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    6. metadata-eval96.5%

      \[\leadsto \left(s \cdot \color{blue}{-3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    7. sub-neg96.5%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)} \]
    8. log1p-define98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\mathsf{log1p}\left(-\frac{u - 0.25}{0.75}\right)} \]
    9. div-sub96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(-\color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \]
    10. sub-neg96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(-\color{blue}{\left(\frac{u}{0.75} + \left(-\frac{0.25}{0.75}\right)\right)}\right) \]
    11. distribute-neg-in96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\left(-\frac{u}{0.75}\right) + \left(-\left(-\frac{0.25}{0.75}\right)\right)}\right) \]
    12. distribute-frac-neg96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{-u}{0.75}} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    13. neg-mul-196.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{-1 \cdot u}}{0.75} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    14. *-commutative96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{u \cdot -1}}{0.75} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    15. associate-/l*96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{u \cdot \frac{-1}{0.75}} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    16. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot \color{blue}{-1.3333333333333333} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    17. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \left(-\left(-\color{blue}{0.3333333333333333}\right)\right)\right) \]
    18. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \left(-\color{blue}{-0.3333333333333333}\right)\right) \]
    19. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{0.3333333333333333}\right) \]
  3. Simplified96.9%

    \[\leadsto \color{blue}{\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + 0.3333333333333333\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. log1p-undefine95.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\log \left(1 + \left(u \cdot -1.3333333333333333 + 0.3333333333333333\right)\right)} \]
    2. +-commutative95.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \left(1 + \color{blue}{\left(0.3333333333333333 + u \cdot -1.3333333333333333\right)}\right) \]
    3. associate-+r+96.2%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(\left(1 + 0.3333333333333333\right) + u \cdot -1.3333333333333333\right)} \]
    4. metadata-eval96.2%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \left(\color{blue}{1.3333333333333333} + u \cdot -1.3333333333333333\right) \]
    5. +-commutative96.2%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(u \cdot -1.3333333333333333 + 1.3333333333333333\right)} \]
    6. fma-undefine96.8%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)} \]
    7. add-exp-log90.6%

      \[\leadsto \color{blue}{e^{\log \left(\left(s \cdot -3\right) \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)}} \]
    8. associate-*l*90.6%

      \[\leadsto e^{\log \color{blue}{\left(s \cdot \left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)\right)}} \]
  6. Applied egg-rr90.6%

    \[\leadsto \color{blue}{e^{\log \left(s \cdot \left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)\right)}} \]
  7. Step-by-step derivation
    1. rem-exp-log96.9%

      \[\leadsto \color{blue}{s \cdot \left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)} \]
    2. *-commutative96.9%

      \[\leadsto \color{blue}{\left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right) \cdot s} \]
  8. Applied egg-rr96.9%

    \[\leadsto \color{blue}{\left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right) \cdot s} \]
  9. Step-by-step derivation
    1. add-log-exp96.5%

      \[\leadsto \color{blue}{\log \left(e^{-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)}\right)} \cdot s \]
    2. *-commutative96.5%

      \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right) \cdot -3}}\right) \cdot s \]
    3. fma-define95.9%

      \[\leadsto \log \left(e^{\log \color{blue}{\left(u \cdot -1.3333333333333333 + 1.3333333333333333\right)} \cdot -3}\right) \cdot s \]
    4. exp-to-pow96.0%

      \[\leadsto \log \color{blue}{\left({\left(u \cdot -1.3333333333333333 + 1.3333333333333333\right)}^{-3}\right)} \cdot s \]
    5. fma-define96.5%

      \[\leadsto \log \left({\color{blue}{\left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)}}^{-3}\right) \cdot s \]
  10. Applied egg-rr96.5%

    \[\leadsto \color{blue}{\log \left({\left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)}^{-3}\right)} \cdot s \]
  11. Taylor expanded in u around 0 25.7%

    \[\leadsto \color{blue}{\left(\log 0.421875 + 3 \cdot u\right)} \cdot s \]
  12. Step-by-step derivation
    1. +-commutative25.7%

      \[\leadsto \color{blue}{\left(3 \cdot u + \log 0.421875\right)} \cdot s \]
  13. Simplified25.7%

    \[\leadsto \color{blue}{\left(3 \cdot u + \log 0.421875\right)} \cdot s \]
  14. Final simplification25.7%

    \[\leadsto s \cdot \left(u \cdot 3 + \log 0.421875\right) \]
  15. Add Preprocessing

Alternative 8: 7.5% accurate, 1.1× speedup?

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

\\
s \cdot \log 0.421875
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. log-rec96.5%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]
    2. distribute-rgt-neg-out96.5%

      \[\leadsto \color{blue}{-\left(3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    3. distribute-lft-neg-out96.5%

      \[\leadsto \color{blue}{\left(-3 \cdot s\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)} \]
    4. *-commutative96.5%

      \[\leadsto \left(-\color{blue}{s \cdot 3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    5. distribute-rgt-neg-in96.5%

      \[\leadsto \color{blue}{\left(s \cdot \left(-3\right)\right)} \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    6. metadata-eval96.5%

      \[\leadsto \left(s \cdot \color{blue}{-3}\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right) \]
    7. sub-neg96.5%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)} \]
    8. log1p-define98.3%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\mathsf{log1p}\left(-\frac{u - 0.25}{0.75}\right)} \]
    9. div-sub96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(-\color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \]
    10. sub-neg96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(-\color{blue}{\left(\frac{u}{0.75} + \left(-\frac{0.25}{0.75}\right)\right)}\right) \]
    11. distribute-neg-in96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\left(-\frac{u}{0.75}\right) + \left(-\left(-\frac{0.25}{0.75}\right)\right)}\right) \]
    12. distribute-frac-neg96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{-u}{0.75}} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    13. neg-mul-196.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{-1 \cdot u}}{0.75} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    14. *-commutative96.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\frac{\color{blue}{u \cdot -1}}{0.75} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    15. associate-/l*96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(\color{blue}{u \cdot \frac{-1}{0.75}} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    16. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot \color{blue}{-1.3333333333333333} + \left(-\left(-\frac{0.25}{0.75}\right)\right)\right) \]
    17. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \left(-\left(-\color{blue}{0.3333333333333333}\right)\right)\right) \]
    18. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \left(-\color{blue}{-0.3333333333333333}\right)\right) \]
    19. metadata-eval96.9%

      \[\leadsto \left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + \color{blue}{0.3333333333333333}\right) \]
  3. Simplified96.9%

    \[\leadsto \color{blue}{\left(s \cdot -3\right) \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333 + 0.3333333333333333\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. log1p-undefine95.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \color{blue}{\log \left(1 + \left(u \cdot -1.3333333333333333 + 0.3333333333333333\right)\right)} \]
    2. +-commutative95.6%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \left(1 + \color{blue}{\left(0.3333333333333333 + u \cdot -1.3333333333333333\right)}\right) \]
    3. associate-+r+96.2%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(\left(1 + 0.3333333333333333\right) + u \cdot -1.3333333333333333\right)} \]
    4. metadata-eval96.2%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \left(\color{blue}{1.3333333333333333} + u \cdot -1.3333333333333333\right) \]
    5. +-commutative96.2%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(u \cdot -1.3333333333333333 + 1.3333333333333333\right)} \]
    6. fma-undefine96.8%

      \[\leadsto \left(s \cdot -3\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)} \]
    7. add-exp-log90.6%

      \[\leadsto \color{blue}{e^{\log \left(\left(s \cdot -3\right) \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)}} \]
    8. associate-*l*90.6%

      \[\leadsto e^{\log \color{blue}{\left(s \cdot \left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)\right)}} \]
  6. Applied egg-rr90.6%

    \[\leadsto \color{blue}{e^{\log \left(s \cdot \left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)\right)}} \]
  7. Step-by-step derivation
    1. rem-exp-log96.9%

      \[\leadsto \color{blue}{s \cdot \left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right)} \]
    2. *-commutative96.9%

      \[\leadsto \color{blue}{\left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right) \cdot s} \]
  8. Applied egg-rr96.9%

    \[\leadsto \color{blue}{\left(-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)\right) \cdot s} \]
  9. Step-by-step derivation
    1. add-log-exp96.5%

      \[\leadsto \color{blue}{\log \left(e^{-3 \cdot \log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)}\right)} \cdot s \]
    2. *-commutative96.5%

      \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right) \cdot -3}}\right) \cdot s \]
    3. fma-define95.9%

      \[\leadsto \log \left(e^{\log \color{blue}{\left(u \cdot -1.3333333333333333 + 1.3333333333333333\right)} \cdot -3}\right) \cdot s \]
    4. exp-to-pow96.0%

      \[\leadsto \log \color{blue}{\left({\left(u \cdot -1.3333333333333333 + 1.3333333333333333\right)}^{-3}\right)} \cdot s \]
    5. fma-define96.5%

      \[\leadsto \log \left({\color{blue}{\left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)}}^{-3}\right) \cdot s \]
  10. Applied egg-rr96.5%

    \[\leadsto \color{blue}{\log \left({\left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right)}^{-3}\right)} \cdot s \]
  11. Taylor expanded in u around 0 7.5%

    \[\leadsto \log \color{blue}{0.421875} \cdot s \]
  12. Final simplification7.5%

    \[\leadsto s \cdot \log 0.421875 \]
  13. Add Preprocessing

Alternative 9: 10.6% accurate, 22.6× speedup?

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

\\
3 \cdot \left(s \cdot 0\right)
\end{array}
Derivation
  1. Initial program 95.6%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Step-by-step derivation
    1. associate-*l*95.6%

      \[\leadsto \color{blue}{3 \cdot \left(s \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)\right)} \]
    2. log-rec96.5%

      \[\leadsto 3 \cdot \left(s \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)}\right) \]
    3. div-sub95.7%

      \[\leadsto 3 \cdot \left(s \cdot \left(-\log \left(1 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right)\right)\right) \]
    4. metadata-eval95.7%

      \[\leadsto 3 \cdot \left(s \cdot \left(-\log \left(1 - \left(\frac{u}{0.75} - \color{blue}{0.3333333333333333}\right)\right)\right)\right) \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{3 \cdot \left(s \cdot \left(-\log \left(1 - \left(\frac{u}{0.75} - 0.3333333333333333\right)\right)\right)\right)} \]
  4. Add Preprocessing
  5. Applied egg-rr5.7%

    \[\leadsto 3 \cdot \left(s \cdot \left(-\log \color{blue}{\left(\frac{\sqrt{1 + \mathsf{fma}\left(u, -1.3333333333333333, -0.3333333333333333\right)}}{\sqrt{1 + \mathsf{fma}\left(u, -1.3333333333333333, -0.3333333333333333\right)}}\right)}\right)\right) \]
  6. Step-by-step derivation
    1. *-inverses10.6%

      \[\leadsto 3 \cdot \left(s \cdot \left(-\log \color{blue}{1}\right)\right) \]
  7. Simplified10.6%

    \[\leadsto 3 \cdot \left(s \cdot \left(-\log \color{blue}{1}\right)\right) \]
  8. Final simplification10.6%

    \[\leadsto 3 \cdot \left(s \cdot 0\right) \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024079 
(FPCore (s u)
  :name "Disney BSSRDF, sample scattering profile, upper"
  :precision binary32
  :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0)))
  (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))