| Alternative 1 | |
|---|---|
| Error | 4.2 |
| Cost | 352 |
\[s \cdot \left(8 \cdot \left(u \cdot u\right) + u \cdot 4\right)
\]
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
(FPCore (s u) :precision binary32 (* (log1p (* u -4.0)) (- s)))
float code(float s, float u) {
return s * logf((1.0f / (1.0f - (4.0f * u))));
}
float code(float s, float u) {
return log1pf((u * -4.0f)) * -s;
}
function code(s, u) return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u))))) end
function code(s, u) return Float32(log1p(Float32(u * Float32(-4.0))) * Float32(-s)) end
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\mathsf{log1p}\left(u \cdot -4\right) \cdot \left(-s\right)
Results
Initial program 12.4
Simplified0.2
[Start]12.4 | \[ s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\] |
|---|---|
log-rec [=>]11.6 | \[ s \cdot \color{blue}{\left(-\log \left(1 - 4 \cdot u\right)\right)}
\] |
distribute-rgt-neg-out [=>]11.6 | \[ \color{blue}{-s \cdot \log \left(1 - 4 \cdot u\right)}
\] |
distribute-lft-neg-in [=>]11.6 | \[ \color{blue}{\left(-s\right) \cdot \log \left(1 - 4 \cdot u\right)}
\] |
*-commutative [<=]11.6 | \[ \color{blue}{\log \left(1 - 4 \cdot u\right) \cdot \left(-s\right)}
\] |
sub-neg [=>]11.6 | \[ \log \color{blue}{\left(1 + \left(-4 \cdot u\right)\right)} \cdot \left(-s\right)
\] |
log1p-def [=>]0.2 | \[ \color{blue}{\mathsf{log1p}\left(-4 \cdot u\right)} \cdot \left(-s\right)
\] |
distribute-lft-neg-in [=>]0.2 | \[ \mathsf{log1p}\left(\color{blue}{\left(-4\right) \cdot u}\right) \cdot \left(-s\right)
\] |
*-commutative [=>]0.2 | \[ \mathsf{log1p}\left(\color{blue}{u \cdot \left(-4\right)}\right) \cdot \left(-s\right)
\] |
metadata-eval [=>]0.2 | \[ \mathsf{log1p}\left(u \cdot \color{blue}{-4}\right) \cdot \left(-s\right)
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 4.2 |
| Cost | 352 |
| Alternative 2 | |
|---|---|
| Error | 3.6 |
| Cost | 352 |
| Alternative 3 | |
|---|---|
| Error | 3.6 |
| Cost | 352 |
| Alternative 4 | |
|---|---|
| Error | 4.2 |
| Cost | 288 |
| Alternative 5 | |
|---|---|
| Error | 8.3 |
| Cost | 160 |
| Alternative 6 | |
|---|---|
| Error | 8.3 |
| Cost | 160 |
| Alternative 7 | |
|---|---|
| Error | 26.6 |
| Cost | 32 |
herbie shell --seed 2023027
(FPCore (s u)
:name "Disney BSSRDF, sample scattering profile, lower"
:precision binary32
:pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 2.328306437e-10 u) (<= u 0.25)))
(* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))