
(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 (fma 0.75 (/ (exp (/ (/ (- r) 3.0) 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^{\frac{\frac{-r}{3}}{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.2%
Applied rewrites99.3%
(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^{\frac{-0.3333333333333333 \cdot 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.2%
Applied rewrites99.3%
Taylor expanded in r around 0
lower-*.f3299.3
Applied rewrites99.3%
(FPCore (s r) :precision binary32 (+ (* (/ (exp (/ (- r) s)) (* (* (PI) s) r)) 0.125) (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) 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(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.2%
Taylor expanded in s around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
distribute-frac-negN/A
lower-/.f32N/A
lift-/.f32N/A
lift-neg.f32N/A
lift-exp.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f3299.2
Applied rewrites99.2%
(FPCore (s r)
:precision binary32
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 (PI)) s) r))
(/
(*
0.75
(/
1.0
(fma
(fma (/ r (* s 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 \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{r}{s \cdot s}, 0.05555555555555555, \frac{0.3333333333333333}{s}\right), r, 1\right)}}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.2%
lift-exp.f32N/A
lift-neg.f32N/A
lift-*.f32N/A
lift-/.f32N/A
distribute-frac-negN/A
exp-negN/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f32N/A
lift-*.f3299.2
Applied rewrites99.2%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-/.f32N/A
pow2N/A
lift-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3257.1
Applied rewrites57.1%
(FPCore (s r) :precision binary32 (+ (/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 (PI)) s) r)) (/ (* 0.75 (/ 1.0 (fma 0.3333333333333333 (/ r s) 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 \frac{1}{\mathsf{fma}\left(0.3333333333333333, \frac{r}{s}, 1\right)}}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.2%
lift-exp.f32N/A
lift-neg.f32N/A
lift-*.f32N/A
lift-/.f32N/A
distribute-frac-negN/A
exp-negN/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f32N/A
lift-*.f3299.2
Applied rewrites99.2%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f3217.6
Applied rewrites17.6%
(FPCore (s r)
:precision binary32
(/
(-
(/
(+ (/ (* (/ r (PI)) -0.06944444444444445) s) (/ 0.16666666666666666 (PI)))
s)
(/ 0.25 (* (PI) r)))
(- s)))\begin{array}{l}
\\
\frac{\frac{\frac{\frac{r}{\mathsf{PI}\left(\right)} \cdot -0.06944444444444445}{s} + \frac{0.16666666666666666}{\mathsf{PI}\left(\right)}}{s} - \frac{0.25}{\mathsf{PI}\left(\right) \cdot r}}{-s}
\end{array}
Initial program 99.2%
Taylor expanded in s around -inf
mul-1-negN/A
lower-neg.f32N/A
lower-/.f32N/A
Applied rewrites11.0%
Final simplification11.0%
(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.2%
Taylor expanded in s around inf
lower-/.f32N/A
Applied rewrites9.8%
(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.2%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
lift-/.f32N/A
lift-*.f32N/A
associate-/r*N/A
metadata-evalN/A
lift-PI.f32N/A
lift-*.f32N/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.f329.7
Applied rewrites9.7%
(FPCore (s r) :precision binary32 (/ (/ 0.25 (* r s)) (PI)))
\begin{array}{l}
\\
\frac{\frac{0.25}{r \cdot s}}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 99.2%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
lift-/.f32N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
lift-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
(FPCore (s r) :precision binary32 (/ (/ 0.25 r) (* (PI) s)))
\begin{array}{l}
\\
\frac{\frac{0.25}{r}}{\mathsf{PI}\left(\right) \cdot s}
\end{array}
Initial program 99.2%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
lift-/.f32N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
(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.2%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
(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.2%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f329.7
Applied rewrites9.7%
herbie shell --seed 2025037
(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))))