
(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))))
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));
}
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 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
\begin{array}{l}
\\
\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}
\end{array}
Herbie found 14 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))))
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));
}
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 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
\begin{array}{l}
\\
\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}
\end{array}
(FPCore (s r) :precision binary32 (fma (/ (exp (* (/ r s) -0.3333333333333333)) (* (* (* PI 6.0) s) r)) 0.75 (* (/ (exp (/ (- r) s)) (* (* PI r) s)) 0.125)))
float code(float s, float r) {
return fmaf((expf(((r / s) * -0.3333333333333333f)) / (((((float) M_PI) * 6.0f) * s) * r)), 0.75f, ((expf((-r / s)) / ((((float) M_PI) * r) * s)) * 0.125f));
}
function code(s, r) return fma(Float32(exp(Float32(Float32(r / s) * Float32(-0.3333333333333333))) / Float32(Float32(Float32(Float32(pi) * Float32(6.0)) * s) * r)), Float32(0.75), Float32(Float32(exp(Float32(Float32(-r) / s)) / Float32(Float32(Float32(pi) * r) * s)) * Float32(0.125))) end
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{e^{\frac{r}{s} \cdot -0.3333333333333333}}{\left(\left(\pi \cdot 6\right) \cdot s\right) \cdot r}, 0.75, \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot r\right) \cdot s} \cdot 0.125\right)
\end{array}
Initial program 99.6%
Taylor expanded in s around 0
lower-*.f32N/A
lower-/.f3299.6
Applied rewrites99.6%
Taylor expanded in s around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
distribute-frac-negN/A
lower-/.f32N/A
lift-neg.f32N/A
lift-/.f32N/A
lift-exp.f32N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f3299.6
Applied rewrites99.6%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f3299.6
Applied rewrites99.6%
(FPCore (s r)
:precision binary32
(let* ((t_0 (* (* PI s) r)))
(fma
(/ (* 0.16666666666666666 (exp (* (/ r s) -0.3333333333333333))) t_0)
0.75
(* (/ (exp (/ (- r) s)) t_0) 0.125))))
float code(float s, float r) {
float t_0 = (((float) M_PI) * s) * r;
return fmaf(((0.16666666666666666f * expf(((r / s) * -0.3333333333333333f))) / t_0), 0.75f, ((expf((-r / s)) / t_0) * 0.125f));
}
function code(s, r) t_0 = Float32(Float32(Float32(pi) * s) * r) return fma(Float32(Float32(Float32(0.16666666666666666) * exp(Float32(Float32(r / s) * Float32(-0.3333333333333333)))) / t_0), Float32(0.75), Float32(Float32(exp(Float32(Float32(-r) / s)) / t_0) * Float32(0.125))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\pi \cdot s\right) \cdot r\\
\mathsf{fma}\left(\frac{0.16666666666666666 \cdot e^{\frac{r}{s} \cdot -0.3333333333333333}}{t\_0}, 0.75, \frac{e^{\frac{-r}{s}}}{t\_0} \cdot 0.125\right)
\end{array}
\end{array}
Initial program 99.6%
Taylor expanded in s around 0
lower-*.f32N/A
lower-/.f3299.6
Applied rewrites99.6%
Taylor expanded in s around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
distribute-frac-negN/A
lower-/.f32N/A
lift-neg.f32N/A
lift-/.f32N/A
lift-exp.f32N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f3299.6
Applied rewrites99.6%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites99.6%
Taylor expanded in s around 0
associate-*r/N/A
lower-/.f32N/A
lower-*.f32N/A
lower-exp.f32N/A
*-commutativeN/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f3299.5
Applied rewrites99.5%
(FPCore (s r)
:precision binary32
(/
(*
0.125
(+
(/ (exp (/ (- r) s)) (* PI r))
(/ (exp (* -0.3333333333333333 (/ r s))) (* PI r))))
s))
float code(float s, float r) {
return (0.125f * ((expf((-r / s)) / (((float) M_PI) * r)) + (expf((-0.3333333333333333f * (r / s))) / (((float) M_PI) * r)))) / s;
}
function code(s, r) return Float32(Float32(Float32(0.125) * Float32(Float32(exp(Float32(Float32(-r) / s)) / Float32(Float32(pi) * r)) + Float32(exp(Float32(Float32(-0.3333333333333333) * Float32(r / s))) / Float32(Float32(pi) * r)))) / s) end
function tmp = code(s, r) tmp = (single(0.125) * ((exp((-r / s)) / (single(pi) * r)) + (exp((single(-0.3333333333333333) * (r / s))) / (single(pi) * r)))) / s; end
\begin{array}{l}
\\
\frac{0.125 \cdot \left(\frac{e^{\frac{-r}{s}}}{\pi \cdot r} + \frac{e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s}
\end{array}
Initial program 99.6%
Taylor expanded in s around 0
lower-/.f32N/A
Applied rewrites99.5%
(FPCore (s r) :precision binary32 (/ (* 0.125 (/ (+ (exp (/ (- r) s)) (exp (* (/ r s) -0.3333333333333333))) PI)) (* s r)))
float code(float s, float r) {
return (0.125f * ((expf((-r / s)) + expf(((r / s) * -0.3333333333333333f))) / ((float) M_PI))) / (s * r);
}
function code(s, r) return Float32(Float32(Float32(0.125) * Float32(Float32(exp(Float32(Float32(-r) / s)) + exp(Float32(Float32(r / s) * Float32(-0.3333333333333333)))) / Float32(pi))) / Float32(s * r)) end
function tmp = code(s, r) tmp = (single(0.125) * ((exp((-r / s)) + exp(((r / s) * single(-0.3333333333333333)))) / single(pi))) / (s * r); end
\begin{array}{l}
\\
\frac{0.125 \cdot \frac{e^{\frac{-r}{s}} + e^{\frac{r}{s} \cdot -0.3333333333333333}}{\pi}}{s \cdot r}
\end{array}
Initial program 99.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3299.6
Applied rewrites99.6%
Taylor expanded in s around 0
lift-neg.f32N/A
associate-/r*N/A
lift-neg.f32N/A
lower-/.f32N/A
Applied rewrites99.5%
Applied rewrites99.5%
(FPCore (s r)
:precision binary32
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r)))
2.0000000233721948e-7)
(/ 0.25 (* s (log (pow (exp PI) r))))
(/
(-
(fma (/ (* (/ r PI) 0.5555555555555556) (* s s)) 0.125 (/ 0.25 (* PI r)))
(/ 0.16666666666666666 (* PI s)))
s)))
float code(float s, float r) {
float tmp;
if ((((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))) <= 2.0000000233721948e-7f) {
tmp = 0.25f / (s * logf(powf(expf(((float) M_PI)), r)));
} else {
tmp = (fmaf((((r / ((float) M_PI)) * 0.5555555555555556f) / (s * s)), 0.125f, (0.25f / (((float) M_PI) * r))) - (0.16666666666666666f / (((float) M_PI) * s))) / s;
}
return tmp;
}
function code(s, r) tmp = Float32(0.0) if (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))) <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / Float32(s * log((exp(Float32(pi)) ^ r)))); else tmp = Float32(Float32(fma(Float32(Float32(Float32(r / Float32(pi)) * Float32(0.5555555555555556)) / Float32(s * s)), Float32(0.125), Float32(Float32(0.25) / Float32(Float32(pi) * r))) - Float32(Float32(0.16666666666666666) / Float32(Float32(pi) * s))) / s); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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} \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s \cdot \log \left({\left(e^{\pi}\right)}^{r}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\frac{r}{\pi} \cdot 0.5555555555555556}{s \cdot s}, 0.125, \frac{0.25}{\pi \cdot r}\right) - \frac{0.16666666666666666}{\pi \cdot s}}{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))) < 2.00000002e-7Initial program 99.8%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f324.7
Applied rewrites4.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.f324.7
Applied rewrites4.7%
lift-PI.f32N/A
lift-*.f32N/A
add-log-expN/A
lift-exp.f32N/A
lift-PI.f32N/A
log-powN/A
lift-*.f32N/A
pow-unpowN/A
log-powN/A
log-pow-revN/A
lift-PI.f32N/A
lift-exp.f32N/A
add-log-expN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f324.7
Applied rewrites4.7%
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
add-log-expN/A
log-pow-revN/A
lower-log.f32N/A
lower-pow.f32N/A
lower-exp.f32N/A
lift-PI.f3244.4
Applied rewrites44.4%
if 2.00000002e-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 97.8%
lift-*.f32N/A
lift-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3297.8
Applied rewrites97.8%
Taylor expanded in s around 0
lift-neg.f32N/A
associate-/r*N/A
lift-neg.f32N/A
lower-/.f32N/A
Applied rewrites97.4%
Taylor expanded in s around inf
metadata-evalN/A
associate-*r/N/A
lower--.f32N/A
Applied rewrites64.8%
(FPCore (s r)
:precision binary32
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r)))
4.999999858590343e-10)
(/ 0.25 (log (pow (exp (* PI r)) s)))
(/
(-
(fma (/ (* (/ r PI) 0.5555555555555556) (* s s)) 0.125 (/ 0.25 (* PI r)))
(/ 0.16666666666666666 (* PI s)))
s)))
float code(float s, float r) {
float tmp;
if ((((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))) <= 4.999999858590343e-10f) {
tmp = 0.25f / logf(powf(expf((((float) M_PI) * r)), s));
} else {
tmp = (fmaf((((r / ((float) M_PI)) * 0.5555555555555556f) / (s * s)), 0.125f, (0.25f / (((float) M_PI) * r))) - (0.16666666666666666f / (((float) M_PI) * s))) / s;
}
return tmp;
}
function code(s, r) tmp = Float32(0.0) if (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))) <= Float32(4.999999858590343e-10)) tmp = Float32(Float32(0.25) / log((exp(Float32(Float32(pi) * r)) ^ s))); else tmp = Float32(Float32(fma(Float32(Float32(Float32(r / Float32(pi)) * Float32(0.5555555555555556)) / Float32(s * s)), Float32(0.125), Float32(Float32(0.25) / Float32(Float32(pi) * r))) - Float32(Float32(0.16666666666666666) / Float32(Float32(pi) * s))) / s); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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} \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;\frac{0.25}{\log \left({\left(e^{\pi \cdot r}\right)}^{s}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\frac{r}{\pi} \cdot 0.5555555555555556}{s \cdot s}, 0.125, \frac{0.25}{\pi \cdot r}\right) - \frac{0.16666666666666666}{\pi \cdot s}}{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.99999986e-10Initial program 99.8%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f324.6
Applied rewrites4.6%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
add-log-expN/A
log-pow-revN/A
lower-log.f32N/A
lower-pow.f32N/A
lower-exp.f32N/A
lift-PI.f32N/A
lower-*.f327.1
Applied rewrites7.1%
lift-pow.f32N/A
lift-*.f32N/A
pow-unpowN/A
lower-pow.f32N/A
pow-to-expN/A
lift-PI.f32N/A
lift-exp.f32N/A
add-log-expN/A
*-commutativeN/A
lower-exp.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f3243.9
Applied rewrites43.9%
if 4.99999986e-10 < (+.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.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3297.7
Applied rewrites97.7%
Taylor expanded in s around 0
lift-neg.f32N/A
associate-/r*N/A
lift-neg.f32N/A
lower-/.f32N/A
Applied rewrites97.3%
Taylor expanded in s around inf
metadata-evalN/A
associate-*r/N/A
lower--.f32N/A
Applied rewrites63.3%
(FPCore (s r)
:precision binary32
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r)))
2.0000000233721948e-7)
(/ 0.25 (* (* PI s) (log (exp r))))
(/
(-
(fma (/ (* (/ r PI) 0.5555555555555556) (* s s)) 0.125 (/ 0.25 (* PI r)))
(/ 0.16666666666666666 (* PI s)))
s)))
float code(float s, float r) {
float tmp;
if ((((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))) <= 2.0000000233721948e-7f) {
tmp = 0.25f / ((((float) M_PI) * s) * logf(expf(r)));
} else {
tmp = (fmaf((((r / ((float) M_PI)) * 0.5555555555555556f) / (s * s)), 0.125f, (0.25f / (((float) M_PI) * r))) - (0.16666666666666666f / (((float) M_PI) * s))) / s;
}
return tmp;
}
function code(s, r) tmp = Float32(0.0) if (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))) <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / Float32(Float32(Float32(pi) * s) * log(exp(r)))); else tmp = Float32(Float32(fma(Float32(Float32(Float32(r / Float32(pi)) * Float32(0.5555555555555556)) / Float32(s * s)), Float32(0.125), Float32(Float32(0.25) / Float32(Float32(pi) * r))) - Float32(Float32(0.16666666666666666) / Float32(Float32(pi) * s))) / s); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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} \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{\left(\pi \cdot s\right) \cdot \log \left(e^{r}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\frac{r}{\pi} \cdot 0.5555555555555556}{s \cdot s}, 0.125, \frac{0.25}{\pi \cdot r}\right) - \frac{0.16666666666666666}{\pi \cdot s}}{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))) < 2.00000002e-7Initial program 99.8%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f324.7
Applied rewrites4.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.f324.7
Applied rewrites4.7%
lift-PI.f32N/A
lift-*.f32N/A
add-log-expN/A
lift-exp.f32N/A
lift-PI.f32N/A
log-powN/A
lift-PI.f32N/A
lift-exp.f32N/A
pow-expN/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
exp-prodN/A
log-powN/A
lower-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
lower-log.f32N/A
lower-exp.f3239.9
Applied rewrites39.9%
if 2.00000002e-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 97.8%
lift-*.f32N/A
lift-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3297.8
Applied rewrites97.8%
Taylor expanded in s around 0
lift-neg.f32N/A
associate-/r*N/A
lift-neg.f32N/A
lower-/.f32N/A
Applied rewrites97.4%
Taylor expanded in s around inf
metadata-evalN/A
associate-*r/N/A
lower--.f32N/A
Applied rewrites64.8%
(FPCore (s r)
:precision binary32
(if (<=
(+
(/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
(/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r)))
2.0000000233721948e-7)
(/ 0.25 (* (* PI s) (log (exp r))))
(-
(/
(-
(-
(/
(-
(- (/ (* (/ r PI) -0.06944444444444445) s))
(/ 0.16666666666666666 PI))
s))
(/ 0.25 (* PI r)))
s))))
float code(float s, float r) {
float tmp;
if ((((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))) <= 2.0000000233721948e-7f) {
tmp = 0.25f / ((((float) M_PI) * s) * logf(expf(r)));
} else {
tmp = -((-((-(((r / ((float) M_PI)) * -0.06944444444444445f) / s) - (0.16666666666666666f / ((float) M_PI))) / s) - (0.25f / (((float) M_PI) * r))) / s);
}
return tmp;
}
function code(s, r) tmp = Float32(0.0) if (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))) <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / Float32(Float32(Float32(pi) * s) * log(exp(r)))); else tmp = Float32(-Float32(Float32(Float32(-Float32(Float32(Float32(-Float32(Float32(Float32(r / Float32(pi)) * Float32(-0.06944444444444445)) / s)) - Float32(Float32(0.16666666666666666) / Float32(pi))) / s)) - Float32(Float32(0.25) / Float32(Float32(pi) * r))) / s)); end return tmp end
function tmp_2 = code(s, r) tmp = single(0.0); if ((((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))) <= single(2.0000000233721948e-7)) tmp = single(0.25) / ((single(pi) * s) * log(exp(r))); else tmp = -((-((-(((r / single(pi)) * single(-0.06944444444444445)) / s) - (single(0.16666666666666666) / single(pi))) / s) - (single(0.25) / (single(pi) * r))) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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} \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{\left(\pi \cdot s\right) \cdot \log \left(e^{r}\right)}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\left(-\frac{\left(-\frac{\frac{r}{\pi} \cdot -0.06944444444444445}{s}\right) - \frac{0.16666666666666666}{\pi}}{s}\right) - \frac{0.25}{\pi \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))) < 2.00000002e-7Initial program 99.8%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f324.7
Applied rewrites4.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.f324.7
Applied rewrites4.7%
lift-PI.f32N/A
lift-*.f32N/A
add-log-expN/A
lift-exp.f32N/A
lift-PI.f32N/A
log-powN/A
lift-PI.f32N/A
lift-exp.f32N/A
pow-expN/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
exp-prodN/A
log-powN/A
lower-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
lower-log.f32N/A
lower-exp.f3239.9
Applied rewrites39.9%
if 2.00000002e-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 97.8%
Taylor expanded in s around -inf
mul-1-negN/A
lower-neg.f32N/A
lower-/.f32N/A
Applied rewrites64.8%
(FPCore (s r) :precision binary32 (/ 0.25 (* (* PI s) (log (exp r)))))
float code(float s, float r) {
return 0.25f / ((((float) M_PI) * s) * logf(expf(r)));
}
function code(s, r) return Float32(Float32(0.25) / Float32(Float32(Float32(pi) * s) * log(exp(r)))) end
function tmp = code(s, r) tmp = single(0.25) / ((single(pi) * s) * log(exp(r))); end
\begin{array}{l}
\\
\frac{0.25}{\left(\pi \cdot s\right) \cdot \log \left(e^{r}\right)}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
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.f328.8
Applied rewrites8.8%
lift-PI.f32N/A
lift-*.f32N/A
add-log-expN/A
lift-exp.f32N/A
lift-PI.f32N/A
log-powN/A
lift-PI.f32N/A
lift-exp.f32N/A
pow-expN/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
exp-prodN/A
log-powN/A
lower-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
lower-log.f32N/A
lower-exp.f3239.9
Applied rewrites39.9%
(FPCore (s r) :precision binary32 (/ (/ (fma (/ r (* PI s)) -0.16666666666666666 (/ 0.25 PI)) r) s))
float code(float s, float r) {
return (fmaf((r / (((float) M_PI) * s)), -0.16666666666666666f, (0.25f / ((float) M_PI))) / r) / s;
}
function code(s, r) return Float32(Float32(fma(Float32(r / Float32(Float32(pi) * s)), Float32(-0.16666666666666666), Float32(Float32(0.25) / Float32(pi))) / r) / s) end
\begin{array}{l}
\\
\frac{\frac{\mathsf{fma}\left(\frac{r}{\pi \cdot s}, -0.16666666666666666, \frac{0.25}{\pi}\right)}{r}}{s}
\end{array}
Initial program 99.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3299.6
Applied rewrites99.6%
Taylor expanded in s around 0
lift-neg.f32N/A
associate-/r*N/A
lift-neg.f32N/A
lower-/.f32N/A
Applied rewrites99.5%
Taylor expanded in r around 0
lower-/.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-/.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
(FPCore (s r) :precision binary32 (/ (- (/ 0.25 (* PI r)) (/ 0.16666666666666666 (* PI s))) s))
float code(float s, float r) {
return ((0.25f / (((float) M_PI) * r)) - (0.16666666666666666f / (((float) M_PI) * s))) / s;
}
function code(s, r) return Float32(Float32(Float32(Float32(0.25) / Float32(Float32(pi) * r)) - Float32(Float32(0.16666666666666666) / Float32(Float32(pi) * s))) / s) end
function tmp = code(s, r) tmp = ((single(0.25) / (single(pi) * r)) - (single(0.16666666666666666) / (single(pi) * s))) / s; end
\begin{array}{l}
\\
\frac{\frac{0.25}{\pi \cdot r} - \frac{0.16666666666666666}{\pi \cdot s}}{s}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
lower-/.f32N/A
Applied rewrites8.8%
(FPCore (s r) :precision binary32 (/ (/ 0.25 r) (* PI s)))
float code(float s, float r) {
return (0.25f / r) / (((float) M_PI) * s);
}
function code(s, r) return Float32(Float32(Float32(0.25) / r) / Float32(Float32(pi) * s)) end
function tmp = code(s, r) tmp = (single(0.25) / r) / (single(pi) * s); end
\begin{array}{l}
\\
\frac{\frac{0.25}{r}}{\pi \cdot s}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
*-commutativeN/A
*-commutativeN/A
lower-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
(FPCore (s r) :precision binary32 (/ (/ 0.25 (* PI r)) s))
float code(float s, float r) {
return (0.25f / (((float) M_PI) * r)) / s;
}
function code(s, r) return Float32(Float32(Float32(0.25) / Float32(Float32(pi) * r)) / s) end
function tmp = code(s, r) tmp = (single(0.25) / (single(pi) * r)) / s; end
\begin{array}{l}
\\
\frac{\frac{0.25}{\pi \cdot r}}{s}
\end{array}
Initial program 99.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3299.6
Applied rewrites99.6%
Taylor expanded in s around 0
lift-neg.f32N/A
associate-/r*N/A
lift-neg.f32N/A
lower-/.f32N/A
Applied rewrites99.5%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
(FPCore (s r) :precision binary32 (/ 0.25 (* s (* PI r))))
float code(float s, float r) {
return 0.25f / (s * (((float) M_PI) * r));
}
function code(s, r) return Float32(Float32(0.25) / Float32(s * Float32(Float32(pi) * r))) end
function tmp = code(s, r) tmp = single(0.25) / (s * (single(pi) * r)); end
\begin{array}{l}
\\
\frac{0.25}{s \cdot \left(\pi \cdot r\right)}
\end{array}
Initial program 99.6%
Taylor expanded in s around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
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.f328.8
Applied rewrites8.8%
lift-PI.f32N/A
lift-*.f32N/A
add-log-expN/A
lift-exp.f32N/A
lift-PI.f32N/A
log-powN/A
lift-*.f32N/A
pow-unpowN/A
log-powN/A
log-pow-revN/A
lift-PI.f32N/A
lift-exp.f32N/A
add-log-expN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f328.8
Applied rewrites8.8%
herbie shell --seed 2025106
(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))))