
(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))))
\begin{array}{l}
\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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))))
\begin{array}{l}
\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
(FPCore (s r) :precision binary32 (fma (/ 0.75 (* (* (PI) 6.0) s)) (/ (exp (/ (* -0.3333333333333333 r) s)) r) (* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125)))
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.75}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s}, \frac{e^{\frac{-0.3333333333333333 \cdot r}{s}}}{r}, \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot 0.125\right)
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in r around 0
Applied rewrites99.8%
Taylor expanded in s around 0
Applied rewrites99.8%
(FPCore (s r) :precision binary32 (fma 0.75 (/ (exp (* -0.3333333333333333 (/ r s))) (* (* (* (PI) 6.0) s) r)) (* 0.25 (/ (exp (/ (- r) s)) (* (* (* (PI) 2.0) s) r)))))
\begin{array}{l}
\\
\mathsf{fma}\left(0.75, \frac{e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\left(\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s\right) \cdot r}, 0.25 \cdot \frac{e^{\frac{-r}{s}}}{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot s\right) \cdot r}\right)
\end{array}
Initial program 99.7%
Applied rewrites99.7%
Taylor expanded in s around 0
Applied rewrites99.7%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* (PI) s)))
(fma
(/ 0.125 t_0)
(/ (exp (/ (* -0.3333333333333333 r) s)) r)
(* (/ (exp (/ (- r) s)) (* t_0 r)) 0.125))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot s\\
\mathsf{fma}\left(\frac{0.125}{t\_0}, \frac{e^{\frac{-0.3333333333333333 \cdot r}{s}}}{r}, \frac{e^{\frac{-r}{s}}}{t\_0 \cdot r} \cdot 0.125\right)
\end{array}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in r around 0
Applied rewrites99.8%
Taylor expanded in s around 0
Applied rewrites99.8%
Taylor expanded in s around 0
Applied rewrites99.7%
(FPCore (s r)
:precision binary32
(fma
0.75
(/
(+
(/
(-
(*
(fma
-0.00102880658436214
(/ r (* (* s s) (PI)))
(/ 0.009259259259259259 (* (PI) s)))
r)
(/ 0.05555555555555555 (PI)))
s)
(/ 0.16666666666666666 (* (PI) r)))
s)
(* 0.25 (/ (exp (/ (- r) s)) (* (* (+ (PI) (PI)) s) r)))))\begin{array}{l}
\\
\mathsf{fma}\left(0.75, \frac{\frac{\mathsf{fma}\left(-0.00102880658436214, \frac{r}{\left(s \cdot s\right) \cdot \mathsf{PI}\left(\right)}, \frac{0.009259259259259259}{\mathsf{PI}\left(\right) \cdot s}\right) \cdot r - \frac{0.05555555555555555}{\mathsf{PI}\left(\right)}}{s} + \frac{0.16666666666666666}{\mathsf{PI}\left(\right) \cdot r}}{s}, 0.25 \cdot \frac{e^{\frac{-r}{s}}}{\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}\right)
\end{array}
Initial program 99.7%
Applied rewrites99.7%
Taylor expanded in s around -inf
Applied rewrites13.2%
Taylor expanded in r around 0
Applied rewrites13.2%
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f32N/A
lift-PI.f32N/A
lift-PI.f3213.2
Applied rewrites13.2%
Final simplification13.2%
(FPCore (s r)
:precision binary32
(fma
(/ 0.75 (* (* (PI) 6.0) s))
(fma
(/
(fma
(/ (fma (/ (* r r) s) -0.006172839506172839 (* 0.05555555555555555 r)) s)
-1.0
0.3333333333333333)
s)
-1.0
(/ 1.0 r))
(* 0.25 (/ (exp (/ (- r) s)) (* (* (* (PI) 2.0) s) r)))))\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.75}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s}, \mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{r \cdot r}{s}, -0.006172839506172839, 0.05555555555555555 \cdot r\right)}{s}, -1, 0.3333333333333333\right)}{s}, -1, \frac{1}{r}\right), 0.25 \cdot \frac{e^{\frac{-r}{s}}}{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot s\right) \cdot r}\right)
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in s around -inf
Applied rewrites13.2%
(FPCore (s r)
:precision binary32
(fma
(/ 0.75 (* (* (PI) 6.0) s))
(fma
(/
(fma
(/ (fma (* r (/ r s)) -0.006172839506172839 (* 0.05555555555555555 r)) s)
-1.0
0.3333333333333333)
s)
-1.0
(/ 1.0 r))
(* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125)))\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.75}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s}, \mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(r \cdot \frac{r}{s}, -0.006172839506172839, 0.05555555555555555 \cdot r\right)}{s}, -1, 0.3333333333333333\right)}{s}, -1, \frac{1}{r}\right), \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot 0.125\right)
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in r around 0
Applied rewrites99.8%
Taylor expanded in s around 0
Applied rewrites99.8%
Taylor expanded in s around -inf
Applied rewrites13.2%
(FPCore (s r)
:precision binary32
(fma
0.75
(/
(fma
(- (* (/ r (* s s)) 0.05555555555555555) (/ 0.3333333333333333 s))
r
1.0)
(* (* (* (PI) 6.0) s) r))
(* 0.25 (/ (exp (/ (- r) s)) (* (* (* (PI) 2.0) s) r)))))\begin{array}{l}
\\
\mathsf{fma}\left(0.75, \frac{\mathsf{fma}\left(\frac{r}{s \cdot s} \cdot 0.05555555555555555 - \frac{0.3333333333333333}{s}, r, 1\right)}{\left(\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s\right) \cdot r}, 0.25 \cdot \frac{e^{\frac{-r}{s}}}{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot s\right) \cdot r}\right)
\end{array}
Initial program 99.7%
Applied rewrites99.7%
Taylor expanded in r around 0
Applied rewrites13.1%
(FPCore (s r) :precision binary32 (fma (/ 0.75 (* (* (PI) 6.0) s)) (- (fma (/ r (* s s)) 0.05555555555555555 (/ 1.0 r)) (/ 0.3333333333333333 s)) (* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125)))
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.75}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s}, \mathsf{fma}\left(\frac{r}{s \cdot s}, 0.05555555555555555, \frac{1}{r}\right) - \frac{0.3333333333333333}{s}, \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot 0.125\right)
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in r around 0
Applied rewrites99.8%
Taylor expanded in s around 0
Applied rewrites99.8%
Taylor expanded in s around inf
Applied rewrites13.1%
(FPCore (s r) :precision binary32 (fma (/ 0.75 (* (* (PI) 6.0) s)) (fma (/ (fma -0.05555555555555555 (/ r s) 0.3333333333333333) s) -1.0 (/ 1.0 r)) (* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125)))
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.75}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s}, \mathsf{fma}\left(\frac{\mathsf{fma}\left(-0.05555555555555555, \frac{r}{s}, 0.3333333333333333\right)}{s}, -1, \frac{1}{r}\right), \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot 0.125\right)
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in r around 0
Applied rewrites99.8%
Taylor expanded in s around 0
Applied rewrites99.8%
Taylor expanded in s around -inf
Applied rewrites13.1%
(FPCore (s r)
:precision binary32
(/
(-
(fma
(/ r (* (* s s) (PI)))
-0.06944444444444445
(/ 0.16666666666666666 (* (PI) s)))
(/ 0.25 (* (PI) r)))
(- s)))\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\frac{r}{\left(s \cdot s\right) \cdot \mathsf{PI}\left(\right)}, -0.06944444444444445, \frac{0.16666666666666666}{\mathsf{PI}\left(\right) \cdot s}\right) - \frac{0.25}{\mathsf{PI}\left(\right) \cdot r}}{-s}
\end{array}
Initial program 99.7%
Taylor expanded in s around -inf
Applied rewrites12.4%
Taylor expanded in r around 0
Applied rewrites12.4%
Final simplification12.4%
(FPCore (s r) :precision binary32 (/ (- (/ (/ 0.25 r) (PI)) (/ 0.16666666666666666 (* (PI) s))) s))
\begin{array}{l}
\\
\frac{\frac{\frac{0.25}{r}}{\mathsf{PI}\left(\right)} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right) \cdot s}}{s}
\end{array}
Initial program 99.7%
Taylor expanded in s around -inf
Applied rewrites12.4%
Taylor expanded in s around inf
Applied rewrites10.8%
(FPCore (s r) :precision binary32 (/ (- (/ 0.25 (* (PI) r)) (/ 0.16666666666666666 (* (PI) s))) s))
\begin{array}{l}
\\
\frac{\frac{0.25}{\mathsf{PI}\left(\right) \cdot r} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right) \cdot s}}{s}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
Applied rewrites10.8%
(FPCore (s r) :precision binary32 (/ (/ -0.25 (* (PI) r)) (- s)))
\begin{array}{l}
\\
\frac{\frac{-0.25}{\mathsf{PI}\left(\right) \cdot r}}{-s}
\end{array}
Initial program 99.7%
Taylor expanded in s around -inf
Applied rewrites12.4%
Taylor expanded in s around inf
Applied rewrites10.0%
Final simplification10.0%
(FPCore (s r) :precision binary32 (/ 0.25 (* (* (PI) s) r)))
\begin{array}{l}
\\
\frac{0.25}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
Applied rewrites10.0%
(FPCore (s r) :precision binary32 (/ 0.25 (* (* r s) (PI))))
\begin{array}{l}
\\
\frac{0.25}{\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
Applied rewrites10.0%
Applied rewrites10.0%
herbie shell --seed 2025026
(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))))