
(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 (+ (/ (* 0.125 (exp (/ (- r) s))) (* (* (PI) s) r)) (/ (* (/ (exp (/ (/ r s) -3.0)) r) 0.75) (* (* 6.0 (PI)) s))))
\begin{array}{l}
\\
\frac{0.125 \cdot e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} + \frac{\frac{e^{\frac{\frac{r}{s}}{-3}}}{r} \cdot 0.75}{\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s}
\end{array}
Initial program 99.6%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
times-fracN/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites99.7%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
times-fracN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift-*.f32N/A
associate-/r*N/A
metadata-evalN/A
times-fracN/A
lift-*.f32N/A
lower-/.f32N/A
lower-*.f3299.7
Applied rewrites99.7%
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.7
lift-/.f32N/A
lift-/.f32N/A
associate-/l/N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f32N/A
lift-/.f3299.7
Applied rewrites99.7%
(FPCore (s r)
:precision binary32
(let* ((t_0 (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) s) r)))
(t_1 (exp (/ (- r) s)))
(t_2 (* (* (* 2.0 (PI)) s) r)))
(if (<= (+ (/ (* 0.25 t_1) t_2) t_0) 3.99999992980668e-13)
(/
(fma (/ t_1 (PI)) 0.125 (* (/ (exp (/ (/ r -3.0) s)) (PI)) 0.125))
(* s r))
(+
(/
(* (* (- (/ (- (/ 0.25 s) (/ 0.25 r)) (- r)) (/ -0.125 (* s s))) r) r)
t_2)
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}\\
t_1 := e^{\frac{-r}{s}}\\
t_2 := \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r\\
\mathbf{if}\;\frac{0.25 \cdot t\_1}{t\_2} + t\_0 \leq 3.99999992980668 \cdot 10^{-13}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{t\_1}{\mathsf{PI}\left(\right)}, 0.125, \frac{e^{\frac{\frac{r}{-3}}{s}}}{\mathsf{PI}\left(\right)} \cdot 0.125\right)}{s \cdot r}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(\frac{\frac{0.25}{s} - \frac{0.25}{r}}{-r} - \frac{-0.125}{s \cdot s}\right) \cdot r\right) \cdot r}{t\_2} + t\_0\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 3.99999993e-13Initial program 99.8%
lift-+.f32N/A
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/r*N/A
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/r*N/A
Applied rewrites99.8%
if 3.99999993e-13 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 98.0%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-add-revN/A
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
lower-*.f3232.3
Applied rewrites26.3%
Taylor expanded in r around -inf
Applied rewrites59.1%
(FPCore (s r)
:precision binary32
(let* ((t_0 (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) s) r)))
(t_1 (* (PI) s))
(t_2 (* (* (* 2.0 (PI)) s) r)))
(if (<= (+ (/ (* 0.25 (exp (/ (- r) s))) t_2) t_0) 4.999999987376214e-7)
(fma
1.0
(/ (fma -0.25 (/ r s) 0.25) (* 2.0 (* t_1 r)))
(/ (* (* (/ 0.125 t_1) r) (exp (/ (/ r s) -3.0))) (* r r)))
(+
(/
(* (* (- (/ (- (/ 0.25 s) (/ 0.25 r)) (- r)) (/ -0.125 (* s s))) r) r)
t_2)
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}\\
t_1 := \mathsf{PI}\left(\right) \cdot s\\
t_2 := \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r\\
\mathbf{if}\;\frac{0.25 \cdot e^{\frac{-r}{s}}}{t\_2} + t\_0 \leq 4.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{\mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)}{2 \cdot \left(t\_1 \cdot r\right)}, \frac{\left(\frac{0.125}{t\_1} \cdot r\right) \cdot e^{\frac{\frac{r}{s}}{-3}}}{r \cdot r}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(\frac{\frac{0.25}{s} - \frac{0.25}{r}}{-r} - \frac{-0.125}{s \cdot s}\right) \cdot r\right) \cdot r}{t\_2} + t\_0\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 4.99999999e-7Initial program 99.8%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f324.9
Applied rewrites4.9%
Applied rewrites4.9%
Applied rewrites96.0%
if 4.99999999e-7 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 98.0%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-add-revN/A
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
lower-*.f3229.3
Applied rewrites25.1%
Taylor expanded in r around -inf
Applied rewrites64.8%
Final simplification93.5%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) s)))
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* t_0 r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) s) r)))
4.999999987376214e-7)
(fma
r
(/ (/ (fma -0.25 (/ r s) 0.25) t_0) (* r r))
(/ (* (* (/ 0.125 (* (PI) s)) r) (exp (/ (/ r s) -3.0))) (* r r)))
(/
(+
(/
(-
(/ (* 0.06944444444444445 (/ r (PI))) s)
(/ 0.16666666666666666 (PI)))
s)
(/ 0.25 (* (PI) r)))
s))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\\
\mathbf{if}\;\frac{0.25 \cdot e^{\frac{-r}{s}}}{t\_0 \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} \leq 4.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(r, \frac{\frac{\mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)}{t\_0}}{r \cdot r}, \frac{\left(\frac{0.125}{\mathsf{PI}\left(\right) \cdot s} \cdot r\right) \cdot e^{\frac{\frac{r}{s}}{-3}}}{r \cdot r}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.06944444444444445 \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right)}}{s} + \frac{0.25}{\mathsf{PI}\left(\right) \cdot r}}{s}\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 4.99999999e-7Initial program 99.8%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f324.9
Applied rewrites4.9%
Applied rewrites4.9%
Applied rewrites96.0%
if 4.99999999e-7 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 98.0%
Taylor expanded in s around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites64.5%
Final simplification93.4%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* 6.0 (PI))) (t_1 (* (PI) r)) (t_2 (* (* 2.0 (PI)) s)))
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* t_2 r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* t_0 s) r)))
4.999999987376214e-7)
(/
(fma
(/ (fma -0.25 (/ r s) 0.25) t_2)
t_0
(* r (/ (* (exp (/ (/ r s) -3.0)) (/ 0.75 s)) r)))
(* t_1 6.0))
(/
(+
(/
(-
(/ (* 0.06944444444444445 (/ r (PI))) s)
(/ 0.16666666666666666 (PI)))
s)
(/ 0.25 t_1))
s))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \mathsf{PI}\left(\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot r\\
t_2 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\\
\mathbf{if}\;\frac{0.25 \cdot e^{\frac{-r}{s}}}{t\_2 \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(t\_0 \cdot s\right) \cdot r} \leq 4.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)}{t\_2}, t\_0, r \cdot \frac{e^{\frac{\frac{r}{s}}{-3}} \cdot \frac{0.75}{s}}{r}\right)}{t\_1 \cdot 6}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.06944444444444445 \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right)}}{s} + \frac{0.25}{t\_1}}{s}\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 4.99999999e-7Initial program 99.8%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f324.9
Applied rewrites4.9%
Applied rewrites4.9%
Applied rewrites4.9%
Applied rewrites98.6%
if 4.99999999e-7 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 98.0%
Taylor expanded in s around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites64.5%
Final simplification95.8%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* (PI) s)))
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 (PI)) s) r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) s) r)))
4.999999987376214e-7)
(fma
1.0
(/ (fma -0.25 (/ r s) 0.25) (* 2.0 (* t_0 r)))
(/ (* (* (/ 0.125 t_0) r) (exp (/ (/ r s) -3.0))) (* r r)))
(/
(+
(/
(-
(/ (* 0.06944444444444445 (/ r (PI))) s)
(/ 0.16666666666666666 (PI)))
s)
(/ 0.25 (* (PI) r)))
s))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot s\\
\mathbf{if}\;\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} \leq 4.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{\mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)}{2 \cdot \left(t\_0 \cdot r\right)}, \frac{\left(\frac{0.125}{t\_0} \cdot r\right) \cdot e^{\frac{\frac{r}{s}}{-3}}}{r \cdot r}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.06944444444444445 \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right)}}{s} + \frac{0.25}{\mathsf{PI}\left(\right) \cdot r}}{s}\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 4.99999999e-7Initial program 99.8%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f324.9
Applied rewrites4.9%
Applied rewrites4.9%
Applied rewrites96.0%
if 4.99999999e-7 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 98.0%
Taylor expanded in s around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites64.5%
Final simplification93.4%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) s)))
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* t_0 r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) s) r)))
9.99994610111476e-41)
(/
(fma
r
(/ (fma -0.25 (/ r s) 0.25) t_0)
(* (* (/ 0.125 (* (PI) s)) r) (exp (/ (/ r s) -3.0))))
(* r r))
(/
(+
(/
(-
(/ (* 0.06944444444444445 (/ r (PI))) s)
(/ 0.16666666666666666 (PI)))
s)
(/ 0.25 (* (PI) r)))
s))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\\
\mathbf{if}\;\frac{0.25 \cdot e^{\frac{-r}{s}}}{t\_0 \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} \leq 9.99994610111476 \cdot 10^{-41}:\\
\;\;\;\;\frac{\mathsf{fma}\left(r, \frac{\mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)}{t\_0}, \left(\frac{0.125}{\mathsf{PI}\left(\right) \cdot s} \cdot r\right) \cdot e^{\frac{\frac{r}{s}}{-3}}\right)}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.06944444444444445 \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right)}}{s} + \frac{0.25}{\mathsf{PI}\left(\right) \cdot r}}{s}\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 9.99995e-41Initial program 99.9%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f324.7
Applied rewrites4.7%
Applied rewrites8.9%
lift-fma.f32N/A
+-commutativeN/A
lift-*.f32N/A
lower-fma.f32N/A
Applied rewrites97.3%
if 9.99995e-41 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 97.2%
Taylor expanded in s around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites53.2%
Final simplification92.7%
(FPCore (s r)
:precision binary32
(let* ((t_0 (exp (/ (- r) s))))
(if (<=
(+
(/ (* 0.25 t_0) (* (* (* 2.0 (PI)) s) r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 (PI)) s) r)))
3.99999992980668e-13)
(fma
(/ (/ (fma (/ r s) -0.05555555555555555 0.16666666666666666) (PI)) s)
(/ 0.75 r)
(/ (* t_0 0.25) (* (* (* (PI) 2.0) s) r)))
(/
(+
(/
(-
(/ (* 0.06944444444444445 (/ r (PI))) s)
(/ 0.16666666666666666 (PI)))
s)
(/ 0.25 (* (PI) r)))
s))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-r}{s}}\\
\mathbf{if}\;\frac{0.25 \cdot t\_0}{\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} \leq 3.99999992980668 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\mathsf{fma}\left(\frac{r}{s}, -0.05555555555555555, 0.16666666666666666\right)}{\mathsf{PI}\left(\right)}}{s}, \frac{0.75}{r}, \frac{t\_0 \cdot 0.25}{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot s\right) \cdot r}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.06944444444444445 \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{0.16666666666666666}{\mathsf{PI}\left(\right)}}{s} + \frac{0.25}{\mathsf{PI}\left(\right) \cdot r}}{s}\\
\end{array}
\end{array}
if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 3.99999993e-13Initial program 99.8%
Taylor expanded in r around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-add-revN/A
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
lower-*.f324.7
Applied rewrites4.7%
Applied rewrites8.9%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
associate-/r*N/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
div-add-revN/A
lower-/.f32N/A
lower-fma.f32N/A
lower-/.f32N/A
lower-PI.f324.7
Applied rewrites4.7%
Taylor expanded in s around 0
*-commutativeN/A
lower-*.f32N/A
lower-exp.f32N/A
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f32N/A
lower-neg.f3298.6
Applied rewrites98.6%
if 3.99999993e-13 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) Initial program 98.0%
Taylor expanded in s around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites58.8%
Final simplification91.3%
(FPCore (s r) :precision binary32 (+ (/ (* 0.125 (exp (/ (- r) s))) (* (* (PI) s) r)) (/ (* 0.75 (/ (exp (/ (/ r -3.0) s)) r)) (* (* 6.0 (PI)) s))))
\begin{array}{l}
\\
\frac{0.125 \cdot e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot \frac{e^{\frac{\frac{r}{-3}}{s}}}{r}}{\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s}
\end{array}
Initial program 99.6%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
times-fracN/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites99.7%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
times-fracN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift-*.f32N/A
associate-/r*N/A
metadata-evalN/A
times-fracN/A
lift-*.f32N/A
lower-/.f32N/A
lower-*.f3299.7
Applied rewrites99.7%
(FPCore (s r) :precision binary32 (+ (* 0.125 (/ (exp (/ (- r) s)) (* (* (PI) s) r))) (/ (* 0.75 (exp (/ r (* -3.0 s)))) (* (* (* 6.0 (PI)) s) r))))
\begin{array}{l}
\\
0.125 \cdot \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\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}
Initial program 99.6%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
times-fracN/A
lower-*.f32N/A
metadata-evalN/A
lower-/.f32N/A
lower-*.f32N/A
lower-*.f3299.6
Applied rewrites99.6%
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
remove-double-negN/A
lower-/.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f3299.6
Applied rewrites99.6%
(FPCore (s r)
:precision binary32
(let* ((t_0 (fma -0.25 (/ r s) 0.25)) (t_1 (/ 0.75 (* (* (* 6.0 (PI)) s) r))))
(if (<= s 1.2000000101235744e-33)
(fma (exp (/ (/ r s) -3.0)) t_1 (/ t_0 (* 2.0 (* (* (PI) s) r))))
(+ (/ t_0 (* (* (* 2.0 (PI)) s) r)) t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)\\
t_1 := \frac{0.75}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}\\
\mathbf{if}\;s \leq 1.2000000101235744 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(e^{\frac{\frac{r}{s}}{-3}}, t\_1, \frac{t\_0}{2 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r} + t\_1\\
\end{array}
\end{array}
if s < 1.20000001e-33Initial program 100.0%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f323.4
Applied rewrites3.4%
Applied rewrites3.5%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites29.7%
if 1.20000001e-33 < s Initial program 99.6%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f329.6
Applied rewrites9.6%
Taylor expanded in s around inf
Applied rewrites9.1%
(FPCore (s r) :precision binary32 (+ (/ (fma -0.25 (/ r s) 0.25) (* (* (* 2.0 (PI)) s) r)) (/ 0.75 (* (* (* 6.0 (PI)) s) r))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(-0.25, \frac{r}{s}, 0.25\right)}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r} + \frac{0.75}{\left(\left(6 \cdot \mathsf{PI}\left(\right)\right) \cdot s\right) \cdot r}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
+-commutativeN/A
lower-fma.f32N/A
lower-/.f328.7
Applied rewrites8.7%
Taylor expanded in s around inf
Applied rewrites8.3%
(FPCore (s r) :precision binary32 (let* ((t_0 (sqrt (PI)))) (/ (/ 0.25 (* (* s t_0) t_0)) r)))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\frac{\frac{0.25}{\left(s \cdot t\_0\right) \cdot t\_0}}{r}
\end{array}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f328.4
Applied rewrites8.4%
Applied rewrites8.4%
(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.6%
Taylor expanded in s around inf
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f328.4
Applied rewrites8.4%
(FPCore (s r) :precision binary32 (/ 0.25 (* (* r (PI)) s)))
\begin{array}{l}
\\
\frac{0.25}{\left(r \cdot \mathsf{PI}\left(\right)\right) \cdot s}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f328.4
Applied rewrites8.4%
Applied rewrites8.3%
Applied rewrites8.3%
herbie shell --seed 2024332
(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))))