| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 10144 |
\[\frac{0.125}{r \cdot \left(s \cdot \pi\right)} \cdot \left(e^{\frac{r}{s} \cdot -0.3333333333333333} + e^{\frac{-r}{s}}\right)
\]
(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 (/ (+ (pow E (* (/ r s) -0.3333333333333333)) (exp (/ (- r) s))) (* 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 * ((powf(((float) M_E), ((r / s) * -0.3333333333333333f)) + expf((-r / s))) / (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(0.125) * Float32(Float32((Float32(exp(1)) ^ Float32(Float32(r / s) * Float32(-0.3333333333333333))) + exp(Float32(Float32(-r) / s))) / 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(2.71828182845904523536) ^ ((r / s) * single(-0.3333333333333333))) + exp((-r / s))) / (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}
0.125 \cdot \frac{{e}^{\left(\frac{r}{s} \cdot -0.3333333333333333\right)} + e^{\frac{-r}{s}}}{s \cdot \left(r \cdot \pi\right)}
Results
Initial program 0.1
Simplified1.8
[Start]0.1 | \[ \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.7 | \[ \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)}
\] |
Taylor expanded in r around inf 0.2
Applied egg-rr0.2
Simplified0.2
[Start]0.2 | \[ 0.125 \cdot \frac{e^{-1 \cdot \frac{r}{s}} + {\left(e^{1}\right)}^{\left(-0.3333333333333333 \cdot \frac{r}{s}\right)}}{s \cdot \left(r \cdot \pi\right)}
\] |
|---|---|
exp-1-e [=>]0.2 | \[ 0.125 \cdot \frac{e^{-1 \cdot \frac{r}{s}} + {\color{blue}{e}}^{\left(-0.3333333333333333 \cdot \frac{r}{s}\right)}}{s \cdot \left(r \cdot \pi\right)}
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 10144 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 10144 |
| Alternative 3 | |
|---|---|
| Error | 0.2 |
| Cost | 10144 |
| Alternative 4 | |
|---|---|
| Error | 17.7 |
| Cost | 9792 |
| Alternative 5 | |
|---|---|
| Error | 29.0 |
| Cost | 6880 |
| Alternative 6 | |
|---|---|
| Error | 29.0 |
| Cost | 6816 |
| Alternative 7 | |
|---|---|
| Error | 29.1 |
| Cost | 3456 |
| Alternative 8 | |
|---|---|
| Error | 29.1 |
| Cost | 3392 |
| Alternative 9 | |
|---|---|
| Error | 29.1 |
| Cost | 3392 |
herbie shell --seed 2023017
(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))))