Disney BSSRDF, sample scattering profile, upper

Percentage Accurate: 95.9% → 97.8%
Time: 9.6s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 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: 97.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ s \cdot \sqrt{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2} \cdot 9} \end{array} \]
(FPCore (s u)
 :precision binary32
 (*
  s
  (sqrt
   (* (pow (log1p (fma u -1.3333333333333333 0.3333333333333333)) 2.0) 9.0))))
float code(float s, float u) {
	return s * sqrtf((powf(log1pf(fmaf(u, -1.3333333333333333f, 0.3333333333333333f)), 2.0f) * 9.0f));
}
function code(s, u)
	return Float32(s * sqrt(Float32((log1p(fma(u, Float32(-1.3333333333333333), Float32(0.3333333333333333))) ^ Float32(2.0)) * Float32(9.0))))
end
\begin{array}{l}

\\
s \cdot \sqrt{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2} \cdot 9}
\end{array}
Derivation
  1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

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

      \[\leadsto s \cdot \color{blue}{\left(\sqrt{\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3} \cdot \sqrt{\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3}\right)} \]
    2. sqrt-unprod98.0%

      \[\leadsto s \cdot \color{blue}{\sqrt{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right)}} \]
    3. swap-sqr98.1%

      \[\leadsto s \cdot \sqrt{\color{blue}{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot \mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right) \cdot \left(-3 \cdot -3\right)}} \]
    4. pow298.1%

      \[\leadsto s \cdot \sqrt{\color{blue}{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2}} \cdot \left(-3 \cdot -3\right)} \]
    5. metadata-eval98.1%

      \[\leadsto s \cdot \sqrt{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2} \cdot \color{blue}{9}} \]
  6. Applied egg-rr98.1%

    \[\leadsto s \cdot \color{blue}{\sqrt{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2} \cdot 9}} \]
  7. Add Preprocessing

Alternative 2: 97.9% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

    \[\leadsto \color{blue}{s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 3: 96.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

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

    \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{u \cdot \left(0.3333333333333333 \cdot \frac{1}{u} - 1.3333333333333333\right)}\right) \cdot -3\right) \]
  6. Final simplification97.2%

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

Alternative 4: 96.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

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

    \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{u \cdot \left(0.3333333333333333 \cdot \frac{1}{u} - 1.3333333333333333\right)}\right) \cdot -3\right) \]
  6. Step-by-step derivation
    1. sub-neg97.2%

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(u \cdot \color{blue}{\left(-1.3333333333333333 + 0.3333333333333333 \cdot \frac{1}{u}\right)}\right) \cdot -3\right) \]
    4. associate-*r/97.2%

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

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

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

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

Alternative 5: 96.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

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

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

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

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

Alternative 6: 96.2% 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.8%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

    \[\leadsto \color{blue}{s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in s around 0 96.1%

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

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

Alternative 7: 28.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ 3 \cdot \left(s \cdot \log 1.3333333333333333\right) \end{array} \]
(FPCore (s u) :precision binary32 (* 3.0 (* s (log 1.3333333333333333))))
float code(float s, float u) {
	return 3.0f * (s * logf(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))
end function
function code(s, u)
	return Float32(Float32(3.0) * Float32(s * log(Float32(1.3333333333333333))))
end
function tmp = code(s, u)
	tmp = single(3.0) * (s * log(single(1.3333333333333333)));
end
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

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

      \[\leadsto s \cdot \color{blue}{\left(\sqrt{\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3} \cdot \sqrt{\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3}\right)} \]
    2. sqrt-unprod98.0%

      \[\leadsto s \cdot \color{blue}{\sqrt{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right)}} \]
    3. swap-sqr98.1%

      \[\leadsto s \cdot \sqrt{\color{blue}{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot \mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right) \cdot \left(-3 \cdot -3\right)}} \]
    4. pow298.1%

      \[\leadsto s \cdot \sqrt{\color{blue}{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2}} \cdot \left(-3 \cdot -3\right)} \]
    5. metadata-eval98.1%

      \[\leadsto s \cdot \sqrt{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2} \cdot \color{blue}{9}} \]
  6. Applied egg-rr98.1%

    \[\leadsto s \cdot \color{blue}{\sqrt{{\left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)}^{2} \cdot 9}} \]
  7. Taylor expanded in u around 0 27.9%

    \[\leadsto \color{blue}{3 \cdot \left(s \cdot \log 1.3333333333333333\right)} \]
  8. Add Preprocessing

Alternative 8: 7.4% 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.8%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(0 - \color{blue}{\left(\frac{u}{0.75} - \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    11. associate--r-96.6%

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(u, \frac{-1}{0.75}, \frac{0.25}{0.75}\right)}\right) \cdot \left(-3\right)\right) \]
    18. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, \color{blue}{-1.3333333333333333}, \frac{0.25}{0.75}\right)\right) \cdot \left(-3\right)\right) \]
    19. metadata-eval98.0%

      \[\leadsto s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, \color{blue}{0.3333333333333333}\right)\right) \cdot \left(-3\right)\right) \]
    20. metadata-eval98.0%

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

    \[\leadsto \color{blue}{s \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right) \cdot -3\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in s around 0 96.1%

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

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

    \[\leadsto s \cdot \log \color{blue}{0.421875} \]
  8. Add Preprocessing

Reproduce

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