
(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 12 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 (+ (* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125) (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (PI) 6.0) (* s r)))))
\begin{array}{l}
\\
\frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot \left(s \cdot r\right)}
\end{array}
Initial program 99.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-*.f3299.7
Applied rewrites99.7%
Taylor expanded in s around 0
lift-*.f32N/A
lift-PI.f32N/A
associate-*l*N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.7%
(FPCore (s r) :precision binary32 (+ (* (/ (exp (/ (- r) s)) (* (* s r) (PI))) 0.125) (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (PI) 6.0) (* s r)))))
\begin{array}{l}
\\
\frac{e^{\frac{-r}{s}}}{\left(s \cdot r\right) \cdot \mathsf{PI}\left(\right)} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot \left(s \cdot r\right)}
\end{array}
Initial program 99.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-*.f3299.7
Applied rewrites99.7%
Taylor expanded in s around 0
lift-*.f32N/A
lift-PI.f32N/A
associate-*l*N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.7%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
lift-PI.f3299.7
Applied rewrites99.7%
(FPCore (s r) :precision binary32 (+ (* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125) (/ (* 0.75 (exp (* -0.3333333333333333 (/ r s)))) (* (* (PI) 6.0) (* s r)))))
\begin{array}{l}
\\
\frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot 0.125 + \frac{0.75 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot \left(s \cdot r\right)}
\end{array}
Initial program 99.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-*.f3299.7
Applied rewrites99.7%
Taylor expanded in s around 0
lift-*.f32N/A
lift-PI.f32N/A
associate-*l*N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.7%
Taylor expanded in s around 0
lower-*.f32N/A
lift-/.f3299.6
Applied rewrites99.6%
(FPCore (s r) :precision binary32 (+ (* (/ (exp (/ (- r) s)) (* (* s r) (PI))) 0.125) (/ (* 0.75 (exp (* (/ r s) -0.3333333333333333))) (* (* (PI) 6.0) (* s r)))))
\begin{array}{l}
\\
\frac{e^{\frac{-r}{s}}}{\left(s \cdot r\right) \cdot \mathsf{PI}\left(\right)} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{r}{s} \cdot -0.3333333333333333}}{\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot \left(s \cdot r\right)}
\end{array}
Initial program 99.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-*.f3299.7
Applied rewrites99.7%
Taylor expanded in s around 0
lift-*.f32N/A
lift-PI.f32N/A
associate-*l*N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.7%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
lift-PI.f3299.7
Applied rewrites99.7%
Taylor expanded in s around 0
*-commutativeN/A
lower-*.f32N/A
lift-/.f3299.6
Applied rewrites99.6%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* (* (* (PI) 6.0) s) r)))
(/
(fma
(/ (* (exp (/ (- r) s)) 0.25) (* (* 2.0 s) (PI)))
t_0
(*
(*
(fma (/ (- (* (/ r s) 0.05555555555555555) 0.3333333333333333) s) r 1.0)
0.75)
r))
(* r t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s\right) \cdot r\\
\frac{\mathsf{fma}\left(\frac{e^{\frac{-r}{s}} \cdot 0.25}{\left(2 \cdot s\right) \cdot \mathsf{PI}\left(\right)}, t\_0, \left(\mathsf{fma}\left(\frac{\frac{r}{s} \cdot 0.05555555555555555 - 0.3333333333333333}{s}, r, 1\right) \cdot 0.75\right) \cdot r\right)}{r \cdot t\_0}
\end{array}
\end{array}
Initial program 99.7%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f329.7
Applied rewrites9.7%
Applied rewrites9.7%
lift-*.f32N/A
*-commutativeN/A
lower-*.f329.7
Applied rewrites9.7%
(FPCore (s r)
:precision binary32
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 (PI)) s) r))
(/
(*
0.75
(fma (/ (- (* (/ r s) 0.05555555555555555) 0.3333333333333333) s) r 1.0))
(* (* (* 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 \mathsf{fma}\left(\frac{\frac{r}{s} \cdot 0.05555555555555555 - 0.3333333333333333}{s}, r, 1\right)}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.7%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f329.7
Applied rewrites9.7%
Taylor expanded in s around inf
lower-/.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f329.7
Applied rewrites9.7%
(FPCore (s r)
:precision binary32
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 (PI)) s) r))
(/
(*
0.75
(fma
(/ (fma -0.3333333333333333 s (* 0.05555555555555555 r)) (* s s))
r
1.0))
(* (* (* 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 \mathsf{fma}\left(\frac{\mathsf{fma}\left(-0.3333333333333333, s, 0.05555555555555555 \cdot r\right)}{s \cdot s}, r, 1\right)}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.7%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f329.7
Applied rewrites9.7%
Taylor expanded in s around 0
lower-/.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f329.7
Applied rewrites9.7%
(FPCore (s r)
:precision binary32
(+
(/
(-
(fma 0.0625 (/ (/ (/ r s) s) (PI)) (/ 0.125 (* (PI) r)))
(/ 0.125 (* (PI) s)))
s)
(/
(*
0.75
(fma
(- (* (/ r (* s s)) 0.05555555555555555) (/ 0.3333333333333333 s))
r
1.0))
(* (* (* 6.0 (PI)) s) r))))\begin{array}{l}
\\
\frac{\mathsf{fma}\left(0.0625, \frac{\frac{\frac{r}{s}}{s}}{\mathsf{PI}\left(\right)}, \frac{0.125}{\mathsf{PI}\left(\right) \cdot r}\right) - \frac{0.125}{\mathsf{PI}\left(\right) \cdot s}}{s} + \frac{0.75 \cdot \mathsf{fma}\left(\frac{r}{s \cdot s} \cdot 0.05555555555555555 - \frac{0.3333333333333333}{s}, r, 1\right)}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.7%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f329.7
Applied rewrites9.7%
Taylor expanded in s around inf
lift-*.f32N/A
lift-PI.f32N/A
associate-*l*N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites9.0%
(FPCore (s r) :precision binary32 (/ (* (fma (- (* 0.4166666666666667 (/ (/ r s) s)) (/ 1.0 s)) r 1.5) r) (* r (* (* (* (PI) 6.0) s) r))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(0.4166666666666667 \cdot \frac{\frac{r}{s}}{s} - \frac{1}{s}, r, 1.5\right) \cdot r}{r \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot 6\right) \cdot s\right) \cdot r\right)}
\end{array}
Initial program 99.7%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f329.7
Applied rewrites9.7%
Applied rewrites9.7%
Taylor expanded in r around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
lower-*.f32N/A
pow2N/A
associate-/r*N/A
lift-/.f32N/A
lift-/.f32N/A
lower-/.f329.0
Applied rewrites9.0%
(FPCore (s r) :precision binary32 (/ (/ 0.25 (* (PI) s)) r))
\begin{array}{l}
\\
\frac{\frac{0.25}{\mathsf{PI}\left(\right) \cdot s}}{r}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.2
Applied rewrites8.2%
lift-/.f32N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
associate-/r*N/A
metadata-evalN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f328.2
Applied rewrites8.2%
(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
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.2
Applied rewrites8.2%
(FPCore (s r) :precision binary32 (/ 0.25 (* (* s r) (PI))))
\begin{array}{l}
\\
\frac{0.25}{\left(s \cdot r\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.2
Applied rewrites8.2%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f32N/A
lift-*.f32N/A
lift-PI.f328.2
Applied rewrites8.2%
herbie shell --seed 2025046
(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))))