Disney BSSRDF, sample scattering profile, upper

?

Percentage Accurate: 95.8% → 98.2%
Time: 11.0s
Precision: binary32
Cost: 19808

?

\[\left(0 \leq s \land s \leq 256\right) \land \left(0.25 \leq u \land u \leq 1\right)\]
\[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
\[\left(3 \cdot s\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)\right)\right) - \mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right)\right) \]
(FPCore (s u)
 :precision binary32
 (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))
(FPCore (s u)
 :precision binary32
 (*
  (* 3.0 s)
  (-
   (log1p
    (fma
     (pow (+ u -0.25) 2.0)
     1.7777777777777777
     (fma 1.3333333333333333 u -0.3333333333333333)))
   (log1p (* (pow (+ u -0.25) 3.0) -2.3703703703703702)))))
float code(float s, float u) {
	return (3.0f * s) * logf((1.0f / (1.0f - ((u - 0.25f) / 0.75f))));
}
float code(float s, float u) {
	return (3.0f * s) * (log1pf(fmaf(powf((u + -0.25f), 2.0f), 1.7777777777777777f, fmaf(1.3333333333333333f, u, -0.3333333333333333f))) - log1pf((powf((u + -0.25f), 3.0f) * -2.3703703703703702f)));
}
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 code(s, u)
	return Float32(Float32(Float32(3.0) * s) * Float32(log1p(fma((Float32(u + Float32(-0.25)) ^ Float32(2.0)), Float32(1.7777777777777777), fma(Float32(1.3333333333333333), u, Float32(-0.3333333333333333)))) - log1p(Float32((Float32(u + Float32(-0.25)) ^ Float32(3.0)) * Float32(-2.3703703703703702)))))
end
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
\left(3 \cdot s\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)\right)\right) - \mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right)\right)

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 6 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Derivation?

  1. Initial program 95.9%

    \[\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \]
  2. Simplified98.2%

    \[\leadsto \color{blue}{\left(3 \cdot s\right) \cdot \left(-\mathsf{log1p}\left(\frac{-\left(u + -0.25\right)}{0.75}\right)\right)} \]
    Step-by-step derivation

    [Start]95.9%

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

    log-rec [=>]96.5%

    \[ \left(3 \cdot s\right) \cdot \color{blue}{\left(-\log \left(1 - \frac{u - 0.25}{0.75}\right)\right)} \]

    sub-neg [=>]96.5%

    \[ \left(3 \cdot s\right) \cdot \left(-\log \color{blue}{\left(1 + \left(-\frac{u - 0.25}{0.75}\right)\right)}\right) \]

    log1p-def [=>]98.2%

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

    distribute-neg-frac [=>]98.2%

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

    sub-neg [=>]98.2%

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

    metadata-eval [=>]98.2%

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

    \[\leadsto \left(3 \cdot s\right) \cdot \left(-\color{blue}{\left(\log \left(1 - {\left(u + -0.25\right)}^{3} \cdot 2.3703703703703702\right) - \log \left(1 + \left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)\right)\right)}\right) \]
    Step-by-step derivation

    [Start]98.2%

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

    log1p-udef [=>]96.5%

    \[ \left(3 \cdot s\right) \cdot \left(-\color{blue}{\log \left(1 + \frac{-\left(u + -0.25\right)}{0.75}\right)}\right) \]

    metadata-eval [<=]96.5%

    \[ \left(3 \cdot s\right) \cdot \left(-\log \left(1 + \frac{-\left(u + \color{blue}{\left(-0.25\right)}\right)}{0.75}\right)\right) \]

    sub-neg [<=]96.5%

    \[ \left(3 \cdot s\right) \cdot \left(-\log \left(1 + \frac{-\color{blue}{\left(u - 0.25\right)}}{0.75}\right)\right) \]

    distribute-frac-neg [=>]96.5%

    \[ \left(3 \cdot s\right) \cdot \left(-\log \left(1 + \color{blue}{\left(-\frac{u - 0.25}{0.75}\right)}\right)\right) \]

    sub-neg [<=]96.5%

    \[ \left(3 \cdot s\right) \cdot \left(-\log \color{blue}{\left(1 - \frac{u - 0.25}{0.75}\right)}\right) \]

    flip3-- [=>]95.6%

    \[ \left(3 \cdot s\right) \cdot \left(-\log \color{blue}{\left(\frac{{1}^{3} - {\left(\frac{u - 0.25}{0.75}\right)}^{3}}{1 \cdot 1 + \left(\frac{u - 0.25}{0.75} \cdot \frac{u - 0.25}{0.75} + 1 \cdot \frac{u - 0.25}{0.75}\right)}\right)}\right) \]

    log-div [=>]95.8%

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

    \[\leadsto \left(3 \cdot s\right) \cdot \left(-\color{blue}{\left(\mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right) - \mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)\right)\right)\right)}\right) \]
    Step-by-step derivation

    [Start]96.1%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\log \left(1 - {\left(u + -0.25\right)}^{3} \cdot 2.3703703703703702\right) - \log \left(1 + \left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)\right)\right)\right) \]

    sub-neg [=>]96.1%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\log \color{blue}{\left(1 + \left(-{\left(u + -0.25\right)}^{3} \cdot 2.3703703703703702\right)\right)} - \log \left(1 + \left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)\right)\right)\right) \]

    log1p-def [=>]96.2%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\color{blue}{\mathsf{log1p}\left(-{\left(u + -0.25\right)}^{3} \cdot 2.3703703703703702\right)} - \log \left(1 + \left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)\right)\right)\right) \]

    distribute-rgt-neg-in [=>]96.2%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\mathsf{log1p}\left(\color{blue}{{\left(u + -0.25\right)}^{3} \cdot \left(-2.3703703703703702\right)}\right) - \log \left(1 + \left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)\right)\right)\right) \]

    metadata-eval [=>]96.2%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot \color{blue}{-2.3703703703703702}\right) - \log \left(1 + \left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)\right)\right)\right) \]

    log1p-def [=>]97.8%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right) - \color{blue}{\mathsf{log1p}\left({\left(u + -0.25\right)}^{2} \cdot 1.7777777777777777 + \left(u \cdot 1.3333333333333333 + -0.3333333333333333\right)\right)}\right)\right) \]

    fma-def [=>]97.7%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right) - \mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, u \cdot 1.3333333333333333 + -0.3333333333333333\right)}\right)\right)\right) \]

    *-commutative [=>]97.7%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right) - \mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \color{blue}{1.3333333333333333 \cdot u} + -0.3333333333333333\right)\right)\right)\right) \]

    fma-def [=>]98.3%

    \[ \left(3 \cdot s\right) \cdot \left(-\left(\mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right) - \mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \color{blue}{\mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)}\right)\right)\right)\right) \]
  5. Final simplification98.3%

    \[\leadsto \left(3 \cdot s\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)\right)\right) - \mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right)\right) \]

Alternatives

Alternative 1
Accuracy98.2%
Cost19808
\[\left(3 \cdot s\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left({\left(u + -0.25\right)}^{2}, 1.7777777777777777, \mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)\right)\right) - \mathsf{log1p}\left({\left(u + -0.25\right)}^{3} \cdot -2.3703703703703702\right)\right) \]
Alternative 2
Accuracy98.3%
Cost3552
\[\mathsf{log1p}\left(\frac{\left(-u\right) - -0.25}{0.75}\right) \cdot \left(3 \cdot \left(-s\right)\right) \]
Alternative 3
Accuracy96.1%
Cost3488
\[-3 \cdot \left(s \cdot \log \left(1.3333333333333333 + u \cdot -1.3333333333333333\right)\right) \]
Alternative 4
Accuracy97.9%
Cost3488
\[-3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(u + -0.25\right) \cdot -1.3333333333333333\right)\right) \]
Alternative 5
Accuracy98.3%
Cost3488
\[s \cdot \left(\mathsf{log1p}\left(\frac{0.25 - u}{0.75}\right) \cdot -3\right) \]
Alternative 6
Accuracy29.9%
Cost160
\[3 \cdot \left(s \cdot u\right) \]

Reproduce?

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