Disney BSSRDF, sample scattering profile, upper

Percentage Accurate: 95.8% → 95.8%
Time: 8.1s
Alternatives: 7
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 7 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.8% 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: 95.8% accurate, 1.0× speedup?

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

\\
\log \left(\frac{1}{1 - \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. Add Preprocessing
  3. Final simplification95.6%

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

Alternative 2: 95.7% accurate, 1.0× speedup?

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

\\
\log \left(\frac{1}{1 + -1.3333333333333333 \cdot \left(u - 0.25\right)}\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. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f32N/A

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

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

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

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

      \[\leadsto \left(3 \cdot s\right) \cdot \log \left(\frac{1}{\left(\mathsf{neg}\left(\color{blue}{\frac{u - \frac{1}{4}}{\frac{3}{4}}}\right)\right) + 1}\right) \]
    6. distribute-neg-frac2N/A

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

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

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

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

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

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

    \[\leadsto \left(3 \cdot s\right) \cdot \log \left(\frac{1}{\color{blue}{-1.3333333333333333 \cdot \left(u - 0.25\right) + 1}}\right) \]
  5. Final simplification95.4%

    \[\leadsto \log \left(\frac{1}{1 + -1.3333333333333333 \cdot \left(u - 0.25\right)}\right) \cdot \left(s \cdot 3\right) \]
  6. Add Preprocessing

Alternative 3: 36.6% accurate, 1.1× speedup?

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

\\
\left(\left(\left(1.5 + u\right) \cdot u\right) \cdot u + \left(\log 0.75 + u\right) \cdot 3\right) \cdot s
\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 u around 0

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

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

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

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

      \[\leadsto \color{blue}{\left(\log \frac{3}{4} \cdot s\right)} \cdot 3 \]
    5. lower-log.f327.3

      \[\leadsto \left(\color{blue}{\log 0.75} \cdot s\right) \cdot 3 \]
  5. Applied rewrites7.3%

    \[\leadsto \color{blue}{\left(\log 0.75 \cdot s\right) \cdot 3} \]
  6. Taylor expanded in u around 0

    \[\leadsto \color{blue}{3 \cdot \left(s \cdot \log \frac{3}{4}\right) + u \cdot \left(3 \cdot s + u \cdot \left(\frac{3}{2} \cdot s + s \cdot u\right)\right)} \]
  7. Applied rewrites14.1%

    \[\leadsto \color{blue}{s \cdot \mathsf{fma}\left(\log 0.75 + u, 3, \left(1.5 + u\right) \cdot \left(u \cdot u\right)\right)} \]
  8. Step-by-step derivation
    1. Applied rewrites36.6%

      \[\leadsto s \cdot \left(\left(\log 0.75 + u\right) \cdot 3 + \color{blue}{\left(\left(1.5 + u\right) \cdot u\right) \cdot u}\right) \]
    2. Final simplification36.6%

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

    Alternative 4: 11.9% accurate, 1.2× speedup?

    \[\begin{array}{l} \\ -3 \cdot \left(\mathsf{log1p}\left(0.3333333333333333 + -1.3333333333333333 \cdot u\right) \cdot s\right) \end{array} \]
    (FPCore (s u)
     :precision binary32
     (* -3.0 (* (log1p (+ 0.3333333333333333 (* -1.3333333333333333 u))) s)))
    float code(float s, float u) {
    	return -3.0f * (log1pf((0.3333333333333333f + (-1.3333333333333333f * u))) * s);
    }
    
    function code(s, u)
    	return Float32(Float32(-3.0) * Float32(log1p(Float32(Float32(0.3333333333333333) + Float32(Float32(-1.3333333333333333) * u))) * s))
    end
    
    \begin{array}{l}
    
    \\
    -3 \cdot \left(\mathsf{log1p}\left(0.3333333333333333 + -1.3333333333333333 \cdot u\right) \cdot s\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. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log 1, 3 \cdot s, \left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - \frac{1}{4}}{\frac{3}{4}}}\right)\right)} \]
      8. metadata-eval7.5

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

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

        \[\leadsto \mathsf{fma}\left(0, \color{blue}{s \cdot 3}, \left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - \frac{1}{4}}{\frac{3}{4}}}\right)\right) \]
      11. lower-*.f327.5

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0, s \cdot 3, \color{blue}{\left(3 \cdot \log \left(\frac{1}{1 - \frac{u - \frac{1}{4}}{\frac{3}{4}}}\right)\right) \cdot s}\right) \]
    4. Applied rewrites34.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0, s \cdot 3, \left(-3 \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right)\right) \cdot s\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f32N/A

        \[\leadsto \color{blue}{0 \cdot \left(s \cdot 3\right) + \left(-3 \cdot \mathsf{log1p}\left(\frac{-4}{3} \cdot \left(u - \frac{1}{4}\right)\right)\right) \cdot s} \]
      2. mul0-lftN/A

        \[\leadsto \color{blue}{0} + \left(-3 \cdot \mathsf{log1p}\left(\frac{-4}{3} \cdot \left(u - \frac{1}{4}\right)\right)\right) \cdot s \]
      3. +-lft-identity9.3

        \[\leadsto \color{blue}{\left(-3 \cdot \mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right)\right) \cdot s} \]
      4. lift-*.f32N/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(\frac{-4}{3} \cdot \left(u - \frac{1}{4}\right)\right) \cdot s\right) \cdot -3} \]
      9. lower-*.f3234.7

        \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(-1.3333333333333333 \cdot \left(u - 0.25\right)\right) \cdot s\right)} \cdot -3 \]
      10. lift-*.f32N/A

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

        \[\leadsto \left(\mathsf{log1p}\left(\frac{-4}{3} \cdot \color{blue}{\left(u - \frac{1}{4}\right)}\right) \cdot s\right) \cdot -3 \]
      12. sub-negN/A

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

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{\frac{-4}{3} \cdot u + \frac{-4}{3} \cdot \left(\mathsf{neg}\left(\frac{1}{4}\right)\right)}\right) \cdot s\right) \cdot -3 \]
      14. metadata-evalN/A

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

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

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

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(\frac{-4}{3}, u, \frac{\frac{1}{4}}{\frac{3}{4}}\right)}\right) \cdot s\right) \cdot -3 \]
      18. metadata-eval7.4

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

      \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(\mathsf{fma}\left(-1.3333333333333333, u, 0.3333333333333333\right)\right) \cdot s\right) \cdot -3} \]
    7. Step-by-step derivation
      1. lift-fma.f32N/A

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

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

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{u \cdot \frac{-4}{3}} + \frac{1}{3}\right) \cdot s\right) \cdot -3 \]
      4. lift-+.f3234.7

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{u \cdot -1.3333333333333333 + 0.3333333333333333}\right) \cdot s\right) \cdot -3 \]
      5. *-lft-identityN/A

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

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

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

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

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{1 \cdot \left(u \cdot \frac{-4}{3}\right) + \frac{1}{3}}\right) \cdot s\right) \cdot -3 \]
      10. lower-*.f3234.7

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{1 \cdot \left(u \cdot -1.3333333333333333\right)} + 0.3333333333333333\right) \cdot s\right) \cdot -3 \]
      11. lift-*.f32N/A

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

        \[\leadsto \left(\mathsf{log1p}\left(1 \cdot \color{blue}{\left(\frac{-4}{3} \cdot u\right)} + \frac{1}{3}\right) \cdot s\right) \cdot -3 \]
      13. lower-*.f3234.7

        \[\leadsto \left(\mathsf{log1p}\left(1 \cdot \color{blue}{\left(-1.3333333333333333 \cdot u\right)} + 0.3333333333333333\right) \cdot s\right) \cdot -3 \]
    8. Applied rewrites34.7%

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

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

    Alternative 5: 26.4% accurate, 6.6× speedup?

    \[\begin{array}{l} \\ \left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot s\right) \cdot 3 \end{array} \]
    (FPCore (s u) :precision binary32 (* (* (* (* u u) 0.5) s) 3.0))
    float code(float s, float u) {
    	return (((u * u) * 0.5f) * s) * 3.0f;
    }
    
    real(4) function code(s, u)
        real(4), intent (in) :: s
        real(4), intent (in) :: u
        code = (((u * u) * 0.5e0) * s) * 3.0e0
    end function
    
    function code(s, u)
    	return Float32(Float32(Float32(Float32(u * u) * Float32(0.5)) * s) * Float32(3.0))
    end
    
    function tmp = code(s, u)
    	tmp = (((u * u) * single(0.5)) * s) * single(3.0);
    end
    
    \begin{array}{l}
    
    \\
    \left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot s\right) \cdot 3
    \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 u around 0

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

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

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

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

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

        \[\leadsto \left(3 \cdot s\right) \cdot \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{2}, u, 1\right)}, u, \log \frac{3}{4}\right) \]
      6. lower-log.f3210.8

        \[\leadsto \left(3 \cdot s\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, u, 1\right), u, \color{blue}{\log 0.75}\right) \]
    5. Applied rewrites10.8%

      \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, u, 1\right), u, \log 0.75\right)} \]
    6. Taylor expanded in u around inf

      \[\leadsto \left(3 \cdot s\right) \cdot \left(\frac{1}{2} \cdot \color{blue}{{u}^{2}}\right) \]
    7. Step-by-step derivation
      1. Applied rewrites26.5%

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

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

          \[\leadsto \color{blue}{\left(3 \cdot s\right)} \cdot \left(\left(u \cdot u\right) \cdot \frac{1}{2}\right) \]
        3. associate-*l*N/A

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

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

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

          \[\leadsto \color{blue}{\left(\left(\left(u \cdot u\right) \cdot \frac{1}{2}\right) \cdot s\right)} \cdot 3 \]
        7. lower-*.f3226.5

          \[\leadsto \color{blue}{\left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot s\right)} \cdot 3 \]
      3. Applied rewrites26.5%

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

      Alternative 6: 26.4% accurate, 6.6× speedup?

      \[\begin{array}{l} \\ \left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot 3\right) \cdot s \end{array} \]
      (FPCore (s u) :precision binary32 (* (* (* (* u u) 0.5) 3.0) s))
      float code(float s, float u) {
      	return (((u * u) * 0.5f) * 3.0f) * s;
      }
      
      real(4) function code(s, u)
          real(4), intent (in) :: s
          real(4), intent (in) :: u
          code = (((u * u) * 0.5e0) * 3.0e0) * s
      end function
      
      function code(s, u)
      	return Float32(Float32(Float32(Float32(u * u) * Float32(0.5)) * Float32(3.0)) * s)
      end
      
      function tmp = code(s, u)
      	tmp = (((u * u) * single(0.5)) * single(3.0)) * s;
      end
      
      \begin{array}{l}
      
      \\
      \left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot 3\right) \cdot s
      \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 u around 0

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

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

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

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

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

          \[\leadsto \left(3 \cdot s\right) \cdot \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{2}, u, 1\right)}, u, \log \frac{3}{4}\right) \]
        6. lower-log.f3210.8

          \[\leadsto \left(3 \cdot s\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, u, 1\right), u, \color{blue}{\log 0.75}\right) \]
      5. Applied rewrites10.8%

        \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, u, 1\right), u, \log 0.75\right)} \]
      6. Taylor expanded in u around inf

        \[\leadsto \left(3 \cdot s\right) \cdot \left(\frac{1}{2} \cdot \color{blue}{{u}^{2}}\right) \]
      7. Step-by-step derivation
        1. Applied rewrites26.5%

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

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

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

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

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

            \[\leadsto \color{blue}{\left(\left(\left(u \cdot u\right) \cdot \frac{1}{2}\right) \cdot 3\right) \cdot s} \]
          6. lower-*.f3226.5

            \[\leadsto \color{blue}{\left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot 3\right)} \cdot s \]
        3. Applied rewrites26.5%

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

        Alternative 7: 26.4% accurate, 6.6× speedup?

        \[\begin{array}{l} \\ \left(\left(u \cdot u\right) \cdot 0.5\right) \cdot \left(s \cdot 3\right) \end{array} \]
        (FPCore (s u) :precision binary32 (* (* (* u u) 0.5) (* s 3.0)))
        float code(float s, float u) {
        	return ((u * u) * 0.5f) * (s * 3.0f);
        }
        
        real(4) function code(s, u)
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = ((u * u) * 0.5e0) * (s * 3.0e0)
        end function
        
        function code(s, u)
        	return Float32(Float32(Float32(u * u) * Float32(0.5)) * Float32(s * Float32(3.0)))
        end
        
        function tmp = code(s, u)
        	tmp = ((u * u) * single(0.5)) * (s * single(3.0));
        end
        
        \begin{array}{l}
        
        \\
        \left(\left(u \cdot u\right) \cdot 0.5\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. Add Preprocessing
        3. Taylor expanded in u around 0

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

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

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

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

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

            \[\leadsto \left(3 \cdot s\right) \cdot \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{2}, u, 1\right)}, u, \log \frac{3}{4}\right) \]
          6. lower-log.f3210.8

            \[\leadsto \left(3 \cdot s\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, u, 1\right), u, \color{blue}{\log 0.75}\right) \]
        5. Applied rewrites10.8%

          \[\leadsto \left(3 \cdot s\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, u, 1\right), u, \log 0.75\right)} \]
        6. Taylor expanded in u around inf

          \[\leadsto \left(3 \cdot s\right) \cdot \left(\frac{1}{2} \cdot \color{blue}{{u}^{2}}\right) \]
        7. Step-by-step derivation
          1. Applied rewrites26.5%

            \[\leadsto \left(3 \cdot s\right) \cdot \left(\left(u \cdot u\right) \cdot \color{blue}{0.5}\right) \]
          2. Final simplification26.5%

            \[\leadsto \left(\left(u \cdot u\right) \cdot 0.5\right) \cdot \left(s \cdot 3\right) \]
          3. Add Preprocessing

          Reproduce

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