| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 10144 |
(FPCore (s r) :precision binary32 (+ (/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r)) (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r))))
(FPCore (s r) :precision binary32 (/ (* 0.125 (+ (/ 1.0 (exp (/ r s))) (exp (/ r (* s -3.0))))) (* s (* r PI))))
float code(float s, float r) {
return ((0.25f * expf((-r / s))) / (((2.0f * ((float) M_PI)) * s) * r)) + ((0.75f * expf((-r / (3.0f * s)))) / (((6.0f * ((float) M_PI)) * s) * r));
}
float code(float s, float r) {
return (0.125f * ((1.0f / expf((r / s))) + expf((r / (s * -3.0f))))) / (s * (r * ((float) M_PI)));
}
function code(s, r) return Float32(Float32(Float32(Float32(0.25) * exp(Float32(Float32(-r) / s))) / Float32(Float32(Float32(Float32(2.0) * Float32(pi)) * s) * r)) + Float32(Float32(Float32(0.75) * exp(Float32(Float32(-r) / Float32(Float32(3.0) * s)))) / Float32(Float32(Float32(Float32(6.0) * Float32(pi)) * s) * r))) end
function code(s, r) return Float32(Float32(Float32(0.125) * Float32(Float32(Float32(1.0) / exp(Float32(r / s))) + exp(Float32(r / Float32(s * Float32(-3.0)))))) / Float32(s * Float32(r * Float32(pi)))) end
function tmp = code(s, r) tmp = ((single(0.25) * exp((-r / s))) / (((single(2.0) * single(pi)) * s) * r)) + ((single(0.75) * exp((-r / (single(3.0) * s)))) / (((single(6.0) * single(pi)) * s) * r)); end
function tmp = code(s, r) tmp = (single(0.125) * ((single(1.0) / exp((r / s))) + exp((r / (s * single(-3.0)))))) / (s * (r * single(pi))); end
\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\frac{0.125 \cdot \left(\frac{1}{e^{\frac{r}{s}}} + e^{\frac{r}{s \cdot -3}}\right)}{s \cdot \left(r \cdot \pi\right)}
Results
Initial program 0.2
Simplified1.3
[Start]0.2 | \[ \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
|---|---|
associate-*l/ [<=]0.7 | \[ \color{blue}{\frac{0.25}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} \cdot e^{\frac{-r}{s}}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-*l* [=>]0.7 | \[ \frac{0.25}{\color{blue}{\left(2 \cdot \pi\right) \cdot \left(s \cdot r\right)}} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-*l* [=>]0.7 | \[ \frac{0.25}{\color{blue}{2 \cdot \left(\pi \cdot \left(s \cdot r\right)\right)}} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-/r* [=>]0.7 | \[ \color{blue}{\frac{\frac{0.25}{2}}{\pi \cdot \left(s \cdot r\right)}} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
metadata-eval [=>]0.7 | \[ \frac{\color{blue}{0.125}}{\pi \cdot \left(s \cdot r\right)} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
metadata-eval [<=]0.7 | \[ \frac{\color{blue}{\frac{0.75}{6}}}{\pi \cdot \left(s \cdot r\right)} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-/r* [<=]0.7 | \[ \color{blue}{\frac{0.75}{6 \cdot \left(\pi \cdot \left(s \cdot r\right)\right)}} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-*l* [<=]0.6 | \[ \frac{0.75}{\color{blue}{\left(6 \cdot \pi\right) \cdot \left(s \cdot r\right)}} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-*l* [<=]0.7 | \[ \frac{0.75}{\color{blue}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}} \cdot e^{\frac{-r}{s}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\] |
associate-*l/ [<=]0.7 | \[ \frac{0.75}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \cdot e^{\frac{-r}{s}} + \color{blue}{\frac{0.75}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \cdot e^{\frac{-r}{3 \cdot s}}}
\] |
distribute-lft-out [=>]0.7 | \[ \color{blue}{\frac{0.75}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)}
\] |
associate-/r* [=>]0.7 | \[ \color{blue}{\frac{\frac{0.75}{\left(6 \cdot \pi\right) \cdot s}}{r}} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)
\] |
associate-*l* [=>]0.7 | \[ \frac{\frac{0.75}{\color{blue}{6 \cdot \left(\pi \cdot s\right)}}}{r} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)
\] |
associate-/r* [=>]0.7 | \[ \frac{\color{blue}{\frac{\frac{0.75}{6}}{\pi \cdot s}}}{r} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)
\] |
associate-/l/ [=>]0.7 | \[ \color{blue}{\frac{\frac{0.75}{6}}{r \cdot \left(\pi \cdot s\right)}} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)
\] |
metadata-eval [=>]0.7 | \[ \frac{\color{blue}{0.125}}{r \cdot \left(\pi \cdot s\right)} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)
\] |
*-commutative [=>]0.7 | \[ \frac{0.125}{r \cdot \color{blue}{\left(s \cdot \pi\right)}} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{-r}{3 \cdot s}}\right)
\] |
neg-mul-1 [=>]0.7 | \[ \frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{\color{blue}{-1 \cdot r}}{3 \cdot s}}\right)
\] |
associate-*l/ [<=]0.7 | \[ \frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{-r}{s}} + e^{\color{blue}{\frac{-1}{3 \cdot s} \cdot r}}\right)
\] |
*-commutative [=>]0.7 | \[ \frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{-r}{s}} + e^{\color{blue}{r \cdot \frac{-1}{3 \cdot s}}}\right)
\] |
exp-prod [=>]1.3 | \[ \frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{-r}{s}} + \color{blue}{{\left(e^{r}\right)}^{\left(\frac{-1}{3 \cdot s}\right)}}\right)
\] |
associate-/r* [=>]1.3 | \[ \frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{-r}{s}} + {\left(e^{r}\right)}^{\color{blue}{\left(\frac{\frac{-1}{3}}{s}\right)}}\right)
\] |
metadata-eval [=>]1.3 | \[ \frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{-r}{s}} + {\left(e^{r}\right)}^{\left(\frac{\color{blue}{-0.3333333333333333}}{s}\right)}\right)
\] |
Taylor expanded in r around inf 0.2
Simplified0.2
[Start]0.2 | \[ 0.125 \cdot \frac{e^{-1 \cdot \frac{r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}}{s \cdot \left(r \cdot \pi\right)}
\] |
|---|---|
*-commutative [=>]0.2 | \[ 0.125 \cdot \frac{e^{-1 \cdot \frac{r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\color{blue}{\left(r \cdot \pi\right) \cdot s}}
\] |
associate-*r/ [=>]0.2 | \[ \color{blue}{\frac{0.125 \cdot \left(e^{-1 \cdot \frac{r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}\right)}{\left(r \cdot \pi\right) \cdot s}}
\] |
mul-1-neg [=>]0.2 | \[ \frac{0.125 \cdot \left(e^{\color{blue}{-\frac{r}{s}}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}\right)}{\left(r \cdot \pi\right) \cdot s}
\] |
distribute-neg-frac [=>]0.2 | \[ \frac{0.125 \cdot \left(e^{\color{blue}{\frac{-r}{s}}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}\right)}{\left(r \cdot \pi\right) \cdot s}
\] |
*-commutative [=>]0.2 | \[ \frac{0.125 \cdot \left(e^{\frac{-r}{s}} + e^{\color{blue}{\frac{r}{s} \cdot -0.3333333333333333}}\right)}{\left(r \cdot \pi\right) \cdot s}
\] |
associate-*l/ [=>]0.2 | \[ \frac{0.125 \cdot \left(e^{\frac{-r}{s}} + e^{\color{blue}{\frac{r \cdot -0.3333333333333333}{s}}}\right)}{\left(r \cdot \pi\right) \cdot s}
\] |
associate-/l* [=>]0.2 | \[ \frac{0.125 \cdot \left(e^{\frac{-r}{s}} + e^{\color{blue}{\frac{r}{\frac{s}{-0.3333333333333333}}}}\right)}{\left(r \cdot \pi\right) \cdot s}
\] |
*-commutative [<=]0.2 | \[ \frac{0.125 \cdot \left(e^{\frac{-r}{s}} + e^{\frac{r}{\frac{s}{-0.3333333333333333}}}\right)}{\color{blue}{s \cdot \left(r \cdot \pi\right)}}
\] |
Applied egg-rr0.2
Applied egg-rr0.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 10144 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 10144 |
| Alternative 3 | |
|---|---|
| Error | 0.2 |
| Cost | 10144 |
| Alternative 4 | |
|---|---|
| Error | 0.2 |
| Cost | 10144 |
| Alternative 5 | |
|---|---|
| Error | 18.0 |
| Cost | 9792 |
| Alternative 6 | |
|---|---|
| Error | 28.9 |
| Cost | 6816 |
| Alternative 7 | |
|---|---|
| Error | 29.1 |
| Cost | 3392 |
| Alternative 8 | |
|---|---|
| Error | 29.1 |
| Cost | 3392 |
| Alternative 9 | |
|---|---|
| Error | 29.1 |
| Cost | 3392 |
| Alternative 10 | |
|---|---|
| Error | 29.1 |
| Cost | 3392 |
herbie shell --seed 2022364
(FPCore (s r)
:name "Disney BSSRDF, PDF of scattering profile"
:precision binary32
:pre (and (and (<= 0.0 s) (<= s 256.0)) (and (< 1e-6 r) (< r 1000000.0)))
(+ (/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r)) (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r))))