Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.5% → 99.5%
Time: 13.6s
Alternatives: 10
Speedup: N/A×

Specification

?
\[\left(0 \leq s \land s \leq 256\right) \land \left(10^{-6} < r \land r < 1000000\right)\]
\[\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
 (+
  (/ (* 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}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.5% accurate, 1.0× speedup?

\[\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
 (+
  (/ (* 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}

Alternative 1: 99.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{0.125}{s \cdot \pi}\\ \mathsf{fma}\left(t_0, \frac{e^{\frac{-r}{s}}}{r}, t_0 \cdot \frac{{\left(e^{-0.6666666666666666}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}{r}\right) \end{array} \end{array} \]
(FPCore (s r)
 :precision binary32
 (let* ((t_0 (/ 0.125 (* s PI))))
   (fma
    t_0
    (/ (exp (/ (- r) s)) r)
    (* t_0 (/ (pow (exp -0.6666666666666666) (/ (/ r s) 2.0)) r)))))
float code(float s, float r) {
	float t_0 = 0.125f / (s * ((float) M_PI));
	return fmaf(t_0, (expf((-r / s)) / r), (t_0 * (powf(expf(-0.6666666666666666f), ((r / s) / 2.0f)) / r)));
}
function code(s, r)
	t_0 = Float32(Float32(0.125) / Float32(s * Float32(pi)))
	return fma(t_0, Float32(exp(Float32(Float32(-r) / s)) / r), Float32(t_0 * Float32((exp(Float32(-0.6666666666666666)) ^ Float32(Float32(r / s) / Float32(2.0))) / r)))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{0.125}{s \cdot \pi}\\
\mathsf{fma}\left(t_0, \frac{e^{\frac{-r}{s}}}{r}, t_0 \cdot \frac{{\left(e^{-0.6666666666666666}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}{r}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Step-by-step derivation
    1. times-frac99.5%

      \[\leadsto \color{blue}{\frac{0.25}{\left(2 \cdot \pi\right) \cdot s} \cdot \frac{e^{\frac{-r}{s}}}{r}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    2. fma-def99.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{0.25}{\left(2 \cdot \pi\right) \cdot s}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}\right)} \]
    3. associate-*l*99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.25}{\color{blue}{2 \cdot \left(\pi \cdot s\right)}}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}\right) \]
    4. associate-/r*99.6%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{0.25}{2}}{\pi \cdot s}}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}\right) \]
    5. *-commutative99.6%

      \[\leadsto \mathsf{fma}\left(\frac{\frac{0.25}{2}}{\color{blue}{s \cdot \pi}}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}\right) \]
    6. metadata-eval99.6%

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{0.125}}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}\right) \]
    7. times-frac99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \color{blue}{\frac{0.75}{\left(6 \cdot \pi\right) \cdot s} \cdot \frac{e^{\frac{-r}{3 \cdot s}}}{r}}\right) \]
    8. associate-*l*99.5%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.75}{\color{blue}{6 \cdot \left(\pi \cdot s\right)}} \cdot \frac{e^{\frac{-r}{3 \cdot s}}}{r}\right) \]
    9. associate-/r*99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \color{blue}{\frac{\frac{0.75}{6}}{\pi \cdot s}} \cdot \frac{e^{\frac{-r}{3 \cdot s}}}{r}\right) \]
    10. metadata-eval99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{\color{blue}{0.125}}{\pi \cdot s} \cdot \frac{e^{\frac{-r}{3 \cdot s}}}{r}\right) \]
    11. *-commutative99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{\color{blue}{s \cdot \pi}} \cdot \frac{e^{\frac{-r}{3 \cdot s}}}{r}\right) \]
  3. Simplified99.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{e^{-0.3333333333333333 \cdot \frac{r}{s}}}{r}\right)} \]
  4. Step-by-step derivation
    1. pow-exp99.3%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{\color{blue}{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}}{r}\right) \]
    2. sqr-pow99.3%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{\color{blue}{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)} \cdot {\left(e^{-0.3333333333333333}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}}{r}\right) \]
    3. pow-prod-down99.3%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{\color{blue}{{\left(e^{-0.3333333333333333} \cdot e^{-0.3333333333333333}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}}{r}\right) \]
    4. prod-exp99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{{\color{blue}{\left(e^{-0.3333333333333333 + -0.3333333333333333}\right)}}^{\left(\frac{\frac{r}{s}}{2}\right)}}{r}\right) \]
    5. metadata-eval99.6%

      \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{{\left(e^{\color{blue}{-0.6666666666666666}}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}{r}\right) \]
  5. Applied egg-rr99.6%

    \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{\color{blue}{{\left(e^{-0.6666666666666666}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}}{r}\right) \]
  6. Final simplification99.6%

    \[\leadsto \mathsf{fma}\left(\frac{0.125}{s \cdot \pi}, \frac{e^{\frac{-r}{s}}}{r}, \frac{0.125}{s \cdot \pi} \cdot \frac{{\left(e^{-0.6666666666666666}\right)}^{\left(\frac{\frac{r}{s}}{2}\right)}}{r}\right) \]

Alternative 2: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{e^{\frac{-r}{s}} \cdot 0.25}{2 \cdot \left(s \cdot \left(\pi \cdot r\right)\right)} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \end{array} \]
(FPCore (s r)
 :precision binary32
 (+
  (/ (* (exp (/ (- r) s)) 0.25) (* 2.0 (* s (* PI r))))
  (/ (* 0.75 (exp (* r (/ -0.3333333333333333 s)))) (* s (* PI (* r 6.0))))))
float code(float s, float r) {
	return ((expf((-r / s)) * 0.25f) / (2.0f * (s * (((float) M_PI) * r)))) + ((0.75f * expf((r * (-0.3333333333333333f / s)))) / (s * (((float) M_PI) * (r * 6.0f))));
}
function code(s, r)
	return Float32(Float32(Float32(exp(Float32(Float32(-r) / s)) * Float32(0.25)) / Float32(Float32(2.0) * Float32(s * Float32(Float32(pi) * r)))) + Float32(Float32(Float32(0.75) * exp(Float32(r * Float32(Float32(-0.3333333333333333) / s)))) / Float32(s * Float32(Float32(pi) * Float32(r * Float32(6.0))))))
end
function tmp = code(s, r)
	tmp = ((exp((-r / s)) * single(0.25)) / (single(2.0) * (s * (single(pi) * r)))) + ((single(0.75) * exp((r * (single(-0.3333333333333333) / s)))) / (s * (single(pi) * (r * single(6.0)))));
end
\begin{array}{l}

\\
\frac{e^{\frac{-r}{s}} \cdot 0.25}{2 \cdot \left(s \cdot \left(\pi \cdot r\right)\right)} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Taylor expanded in s around 0 99.5%

    \[\leadsto \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}}}{\color{blue}{6 \cdot \left(r \cdot \left(s \cdot \pi\right)\right)}} \]
  3. Step-by-step derivation
    1. *-commutative99.5%

      \[\leadsto \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}}}{\color{blue}{\left(r \cdot \left(s \cdot \pi\right)\right) \cdot 6}} \]
    2. associate-*r*99.6%

      \[\leadsto \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}}}{\color{blue}{\left(\left(r \cdot s\right) \cdot \pi\right)} \cdot 6} \]
    3. *-commutative99.6%

      \[\leadsto \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(\color{blue}{\left(s \cdot r\right)} \cdot \pi\right) \cdot 6} \]
    4. associate-*l*99.5%

      \[\leadsto \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}}}{\color{blue}{\left(s \cdot r\right) \cdot \left(\pi \cdot 6\right)}} \]
    5. *-commutative99.5%

      \[\leadsto \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(s \cdot r\right) \cdot \color{blue}{\left(6 \cdot \pi\right)}} \]
    6. rem-log-exp99.5%

      \[\leadsto \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(s \cdot r\right) \cdot \left(6 \cdot \color{blue}{\log \left(e^{\pi}\right)}\right)} \]
    7. log-pow99.5%

      \[\leadsto \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(s \cdot r\right) \cdot \color{blue}{\log \left({\left(e^{\pi}\right)}^{6}\right)}} \]
    8. associate-*l*99.6%

      \[\leadsto \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}}}{\color{blue}{s \cdot \left(r \cdot \log \left({\left(e^{\pi}\right)}^{6}\right)\right)}} \]
    9. log-pow99.6%

      \[\leadsto \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}}}{s \cdot \left(r \cdot \color{blue}{\left(6 \cdot \log \left(e^{\pi}\right)\right)}\right)} \]
    10. rem-log-exp99.6%

      \[\leadsto \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}}}{s \cdot \left(r \cdot \left(6 \cdot \color{blue}{\pi}\right)\right)} \]
    11. *-commutative99.6%

      \[\leadsto \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}}}{s \cdot \left(r \cdot \color{blue}{\left(\pi \cdot 6\right)}\right)} \]
  4. Simplified99.6%

    \[\leadsto \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}}}{\color{blue}{s \cdot \left(r \cdot \left(\pi \cdot 6\right)\right)}} \]
  5. Taylor expanded in s around 0 99.5%

    \[\leadsto \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}}}{\color{blue}{6 \cdot \left(r \cdot \left(s \cdot \pi\right)\right)}} \]
  6. Step-by-step derivation
    1. *-commutative99.5%

      \[\leadsto \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}}}{\color{blue}{\left(r \cdot \left(s \cdot \pi\right)\right) \cdot 6}} \]
    2. associate-*r*99.6%

      \[\leadsto \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}}}{\color{blue}{\left(\left(r \cdot s\right) \cdot \pi\right)} \cdot 6} \]
    3. associate-*l*99.5%

      \[\leadsto \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}}}{\color{blue}{\left(r \cdot s\right) \cdot \left(\pi \cdot 6\right)}} \]
    4. *-commutative99.5%

      \[\leadsto \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}}}{\color{blue}{\left(s \cdot r\right)} \cdot \left(\pi \cdot 6\right)} \]
    5. associate-*r*99.6%

      \[\leadsto \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}}}{\color{blue}{s \cdot \left(r \cdot \left(\pi \cdot 6\right)\right)}} \]
    6. *-commutative99.6%

      \[\leadsto \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}}}{s \cdot \color{blue}{\left(\left(\pi \cdot 6\right) \cdot r\right)}} \]
    7. associate-*l*99.5%

      \[\leadsto \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}}}{s \cdot \color{blue}{\left(\pi \cdot \left(6 \cdot r\right)\right)}} \]
    8. *-commutative99.5%

      \[\leadsto \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}}}{s \cdot \left(\pi \cdot \color{blue}{\left(r \cdot 6\right)}\right)} \]
  7. Simplified99.5%

    \[\leadsto \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}}}{\color{blue}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)}} \]
  8. Taylor expanded in r around 0 99.5%

    \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{-0.3333333333333333 \cdot \frac{r}{s}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
  9. Step-by-step derivation
    1. metadata-eval99.5%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{\frac{-1}{3}} \cdot \frac{r}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    2. times-frac99.5%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{\frac{-1 \cdot r}{3 \cdot s}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    3. neg-mul-199.5%

      \[\leadsto \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{\color{blue}{-r}}{3 \cdot s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    4. *-commutative99.5%

      \[\leadsto \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}{\color{blue}{s \cdot 3}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    5. *-rgt-identity99.5%

      \[\leadsto \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{\color{blue}{\left(-r\right) \cdot 1}}{s \cdot 3}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    6. associate-*r/99.5%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{\left(-r\right) \cdot \frac{1}{s \cdot 3}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    7. distribute-lft-neg-out99.5%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{-r \cdot \frac{1}{s \cdot 3}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    8. distribute-rgt-neg-in99.5%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{r \cdot \left(-\frac{1}{s \cdot 3}\right)}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    9. *-commutative99.5%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{r \cdot \left(-\frac{1}{\color{blue}{3 \cdot s}}\right)}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    10. associate-/r*99.6%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{r \cdot \left(-\color{blue}{\frac{\frac{1}{3}}{s}}\right)}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    11. distribute-neg-frac99.6%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{r \cdot \color{blue}{\frac{-\frac{1}{3}}{s}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    12. metadata-eval99.6%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{r \cdot \frac{-\color{blue}{0.3333333333333333}}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    13. metadata-eval99.6%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{r \cdot \frac{\color{blue}{-0.3333333333333333}}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
  10. Simplified99.6%

    \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\color{blue}{r \cdot \frac{-0.3333333333333333}{s}}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
  11. Taylor expanded in s around 0 99.6%

    \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\color{blue}{2 \cdot \left(r \cdot \left(s \cdot \pi\right)\right)}} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
  12. Step-by-step derivation
    1. *-commutative99.6%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{2 \cdot \color{blue}{\left(\left(s \cdot \pi\right) \cdot r\right)}} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
    2. associate-*l*99.6%

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{2 \cdot \color{blue}{\left(s \cdot \left(\pi \cdot r\right)\right)}} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
  13. Simplified99.6%

    \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\color{blue}{2 \cdot \left(s \cdot \left(\pi \cdot r\right)\right)}} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]
  14. Final simplification99.6%

    \[\leadsto \frac{e^{\frac{-r}{s}} \cdot 0.25}{2 \cdot \left(s \cdot \left(\pi \cdot r\right)\right)} + \frac{0.75 \cdot e^{r \cdot \frac{-0.3333333333333333}{s}}}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)} \]

Alternative 3: 99.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\frac{r \cdot -0.3333333333333333}{s}}}{r}\right) \end{array} \]
(FPCore (s r)
 :precision binary32
 (*
  (/ 0.125 (* s PI))
  (+ (/ (exp (/ r (- s))) r) (/ (exp (/ (* r -0.3333333333333333) s)) r))))
float code(float s, float r) {
	return (0.125f / (s * ((float) M_PI))) * ((expf((r / -s)) / r) + (expf(((r * -0.3333333333333333f) / s)) / r));
}
function code(s, r)
	return Float32(Float32(Float32(0.125) / Float32(s * Float32(pi))) * Float32(Float32(exp(Float32(r / Float32(-s))) / r) + Float32(exp(Float32(Float32(r * Float32(-0.3333333333333333)) / s)) / r)))
end
function tmp = code(s, r)
	tmp = (single(0.125) / (s * single(pi))) * ((exp((r / -s)) / r) + (exp(((r * single(-0.3333333333333333)) / s)) / r));
end
\begin{array}{l}

\\
\frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\frac{r \cdot -0.3333333333333333}{s}}}{r}\right)
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.1%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\color{blue}{\left(\sqrt{e^{-0.3333333333333333}} \cdot \sqrt{e^{-0.3333333333333333}}\right)}}^{\left(\frac{r}{s}\right)}}{r}\right) \]
    2. sqrt-unprod99.3%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\color{blue}{\left(\sqrt{e^{-0.3333333333333333} \cdot e^{-0.3333333333333333}}\right)}}^{\left(\frac{r}{s}\right)}}{r}\right) \]
    3. prod-exp99.4%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(\sqrt{\color{blue}{e^{-0.3333333333333333 + -0.3333333333333333}}}\right)}^{\left(\frac{r}{s}\right)}}{r}\right) \]
    4. metadata-eval99.4%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(\sqrt{e^{\color{blue}{-0.6666666666666666}}}\right)}^{\left(\frac{r}{s}\right)}}{r}\right) \]
  4. Applied egg-rr99.4%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\color{blue}{\left(\sqrt{e^{-0.6666666666666666}}\right)}}^{\left(\frac{r}{s}\right)}}{r}\right) \]
  5. Step-by-step derivation
    1. distribute-lft-in99.4%

      \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \frac{e^{\frac{r}{-s}}}{r} + \frac{\frac{0.125}{\pi}}{s} \cdot \frac{{\left(\sqrt{e^{-0.6666666666666666}}\right)}^{\left(\frac{r}{s}\right)}}{r}} \]
    2. pow1/299.4%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \frac{e^{\frac{r}{-s}}}{r} + \frac{\frac{0.125}{\pi}}{s} \cdot \frac{{\color{blue}{\left({\left(e^{-0.6666666666666666}\right)}^{0.5}\right)}}^{\left(\frac{r}{s}\right)}}{r} \]
    3. pow-exp99.2%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \frac{e^{\frac{r}{-s}}}{r} + \frac{\frac{0.125}{\pi}}{s} \cdot \frac{{\color{blue}{\left(e^{-0.6666666666666666 \cdot 0.5}\right)}}^{\left(\frac{r}{s}\right)}}{r} \]
    4. metadata-eval99.2%

      \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \frac{e^{\frac{r}{-s}}}{r} + \frac{\frac{0.125}{\pi}}{s} \cdot \frac{{\left(e^{\color{blue}{-0.3333333333333333}}\right)}^{\left(\frac{r}{s}\right)}}{r} \]
  6. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \frac{e^{\frac{r}{-s}}}{r} + \frac{\frac{0.125}{\pi}}{s} \cdot \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}} \]
  7. Step-by-step derivation
    1. distribute-lft-in99.3%

      \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
    2. associate-/l/99.3%

      \[\leadsto \color{blue}{\frac{0.125}{s \cdot \pi}} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right) \]
    3. exp-prod99.5%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{e^{-0.3333333333333333 \cdot \frac{r}{s}}}}{r}\right) \]
    4. *-commutative99.5%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\color{blue}{\frac{r}{s} \cdot -0.3333333333333333}}}{r}\right) \]
    5. associate-*l/99.6%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\color{blue}{\frac{r \cdot -0.3333333333333333}{s}}}}{r}\right) \]
  8. Simplified99.6%

    \[\leadsto \color{blue}{\frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\frac{r \cdot -0.3333333333333333}{s}}}{r}\right)} \]
  9. Final simplification99.6%

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\frac{r \cdot -0.3333333333333333}{s}}}{r}\right) \]

Alternative 4: 11.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(s \cdot \pi\right) \cdot r\right)\right)} \end{array} \]
(FPCore (s r) :precision binary32 (/ 0.25 (log1p (expm1 (* (* s PI) r)))))
float code(float s, float r) {
	return 0.25f / log1pf(expm1f(((s * ((float) M_PI)) * r)));
}
function code(s, r)
	return Float32(Float32(0.25) / log1p(expm1(Float32(Float32(s * Float32(pi)) * r))))
end
\begin{array}{l}

\\
\frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(s \cdot \pi\right) \cdot r\right)\right)}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  4. Taylor expanded in s around inf 7.9%

    \[\leadsto \color{blue}{\frac{0.25}{r \cdot \left(s \cdot \pi\right)}} \]
  5. Step-by-step derivation
    1. log1p-expm1-u10.8%

      \[\leadsto \frac{0.25}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(r \cdot \left(s \cdot \pi\right)\right)\right)}} \]
  6. Applied egg-rr10.8%

    \[\leadsto \frac{0.25}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(r \cdot \left(s \cdot \pi\right)\right)\right)}} \]
  7. Final simplification10.8%

    \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(s \cdot \pi\right) \cdot r\right)\right)} \]

Alternative 5: 10.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1 + \frac{r}{s} \cdot -0.3333333333333333}{r}\right) \end{array} \]
(FPCore (s r)
 :precision binary32
 (*
  (/ (/ 0.125 PI) s)
  (+ (/ (exp (/ r (- s))) r) (/ (+ 1.0 (* (/ r s) -0.3333333333333333)) r))))
float code(float s, float r) {
	return ((0.125f / ((float) M_PI)) / s) * ((expf((r / -s)) / r) + ((1.0f + ((r / s) * -0.3333333333333333f)) / r));
}
function code(s, r)
	return Float32(Float32(Float32(Float32(0.125) / Float32(pi)) / s) * Float32(Float32(exp(Float32(r / Float32(-s))) / r) + Float32(Float32(Float32(1.0) + Float32(Float32(r / s) * Float32(-0.3333333333333333))) / r)))
end
function tmp = code(s, r)
	tmp = ((single(0.125) / single(pi)) / s) * ((exp((r / -s)) / r) + ((single(1.0) + ((r / s) * single(-0.3333333333333333))) / r));
end
\begin{array}{l}

\\
\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1 + \frac{r}{s} \cdot -0.3333333333333333}{r}\right)
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1 + -0.3333333333333333 \cdot \frac{r}{s}}}{r}\right) \]
  4. Final simplification8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1 + \frac{r}{s} \cdot -0.3333333333333333}{r}\right) \]

Alternative 6: 9.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{-0.125}{r} \cdot \frac{-1 - e^{\frac{-r}{s}}}{s \cdot \pi} \end{array} \]
(FPCore (s r)
 :precision binary32
 (* (/ -0.125 r) (/ (- -1.0 (exp (/ (- r) s))) (* s PI))))
float code(float s, float r) {
	return (-0.125f / r) * ((-1.0f - expf((-r / s))) / (s * ((float) M_PI)));
}
function code(s, r)
	return Float32(Float32(Float32(-0.125) / r) * Float32(Float32(Float32(-1.0) - exp(Float32(Float32(-r) / s))) / Float32(s * Float32(pi))))
end
function tmp = code(s, r)
	tmp = (single(-0.125) / r) * ((single(-1.0) - exp((-r / s))) / (s * single(pi)));
end
\begin{array}{l}

\\
\frac{-0.125}{r} \cdot \frac{-1 - e^{\frac{-r}{s}}}{s \cdot \pi}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  4. Step-by-step derivation
    1. associate-/l/8.3%

      \[\leadsto \color{blue}{\frac{0.125}{s \cdot \pi}} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    2. metadata-eval8.3%

      \[\leadsto \frac{\color{blue}{\frac{0.75}{6}}}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    3. *-commutative8.3%

      \[\leadsto \frac{\frac{0.75}{6}}{\color{blue}{\pi \cdot s}} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    4. associate-/r*8.3%

      \[\leadsto \color{blue}{\frac{0.75}{6 \cdot \left(\pi \cdot s\right)}} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    5. div-inv8.3%

      \[\leadsto \color{blue}{\left(0.75 \cdot \frac{1}{6 \cdot \left(\pi \cdot s\right)}\right)} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
  5. Applied egg-rr8.3%

    \[\leadsto \color{blue}{\left(0.75 \cdot \frac{1}{6 \cdot \left(\pi \cdot s\right)}\right)} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
  6. Taylor expanded in r around -inf 8.3%

    \[\leadsto \color{blue}{-0.125 \cdot \frac{-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1}{r \cdot \left(s \cdot \pi\right)}} \]
  7. Step-by-step derivation
    1. associate-*r/8.3%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1\right)}{r \cdot \left(s \cdot \pi\right)}} \]
    2. times-frac8.3%

      \[\leadsto \color{blue}{\frac{-0.125}{r} \cdot \frac{-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1}{s \cdot \pi}} \]
    3. sub-neg8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{\color{blue}{-1 \cdot e^{-1 \cdot \frac{r}{s}} + \left(-1\right)}}{s \cdot \pi} \]
    4. metadata-eval8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{-1 \cdot e^{-1 \cdot \frac{r}{s}} + \color{blue}{-1}}{s \cdot \pi} \]
    5. +-commutative8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{\color{blue}{-1 + -1 \cdot e^{-1 \cdot \frac{r}{s}}}}{s \cdot \pi} \]
    6. mul-1-neg8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{-1 + \color{blue}{\left(-e^{-1 \cdot \frac{r}{s}}\right)}}{s \cdot \pi} \]
    7. unsub-neg8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{\color{blue}{-1 - e^{-1 \cdot \frac{r}{s}}}}{s \cdot \pi} \]
    8. associate-*r/8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{-1 - e^{\color{blue}{\frac{-1 \cdot r}{s}}}}{s \cdot \pi} \]
    9. mul-1-neg8.3%

      \[\leadsto \frac{-0.125}{r} \cdot \frac{-1 - e^{\frac{\color{blue}{-r}}{s}}}{s \cdot \pi} \]
  8. Simplified8.3%

    \[\leadsto \color{blue}{\frac{-0.125}{r} \cdot \frac{-1 - e^{\frac{-r}{s}}}{s \cdot \pi}} \]
  9. Final simplification8.3%

    \[\leadsto \frac{-0.125}{r} \cdot \frac{-1 - e^{\frac{-r}{s}}}{s \cdot \pi} \]

Alternative 7: 9.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{-0.125}{s \cdot \pi} \cdot \frac{-1 - e^{\frac{-r}{s}}}{r} \end{array} \]
(FPCore (s r)
 :precision binary32
 (* (/ -0.125 (* s PI)) (/ (- -1.0 (exp (/ (- r) s))) r)))
float code(float s, float r) {
	return (-0.125f / (s * ((float) M_PI))) * ((-1.0f - expf((-r / s))) / r);
}
function code(s, r)
	return Float32(Float32(Float32(-0.125) / Float32(s * Float32(pi))) * Float32(Float32(Float32(-1.0) - exp(Float32(Float32(-r) / s))) / r))
end
function tmp = code(s, r)
	tmp = (single(-0.125) / (s * single(pi))) * ((single(-1.0) - exp((-r / s))) / r);
end
\begin{array}{l}

\\
\frac{-0.125}{s \cdot \pi} \cdot \frac{-1 - e^{\frac{-r}{s}}}{r}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  4. Taylor expanded in r around -inf 8.3%

    \[\leadsto \color{blue}{-0.125 \cdot \frac{-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1}{r \cdot \left(s \cdot \pi\right)}} \]
  5. Step-by-step derivation
    1. associate-*r/8.3%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1\right)}{r \cdot \left(s \cdot \pi\right)}} \]
    2. *-commutative8.3%

      \[\leadsto \frac{-0.125 \cdot \left(-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1\right)}{\color{blue}{\left(s \cdot \pi\right) \cdot r}} \]
    3. times-frac8.3%

      \[\leadsto \color{blue}{\frac{-0.125}{s \cdot \pi} \cdot \frac{-1 \cdot e^{-1 \cdot \frac{r}{s}} - 1}{r}} \]
    4. sub-neg8.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{\color{blue}{-1 \cdot e^{-1 \cdot \frac{r}{s}} + \left(-1\right)}}{r} \]
    5. metadata-eval8.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{-1 \cdot e^{-1 \cdot \frac{r}{s}} + \color{blue}{-1}}{r} \]
    6. +-commutative8.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{\color{blue}{-1 + -1 \cdot e^{-1 \cdot \frac{r}{s}}}}{r} \]
    7. mul-1-neg8.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{-1 + \color{blue}{\left(-e^{-1 \cdot \frac{r}{s}}\right)}}{r} \]
    8. unsub-neg8.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{\color{blue}{-1 - e^{-1 \cdot \frac{r}{s}}}}{r} \]
    9. associate-*r/8.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{-1 - e^{\color{blue}{\frac{-1 \cdot r}{s}}}}{r} \]
    10. neg-mul-18.3%

      \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{-1 - e^{\frac{\color{blue}{-r}}{s}}}{r} \]
  6. Simplified8.3%

    \[\leadsto \color{blue}{\frac{-0.125}{s \cdot \pi} \cdot \frac{-1 - e^{\frac{-r}{s}}}{r}} \]
  7. Final simplification8.3%

    \[\leadsto \frac{-0.125}{s \cdot \pi} \cdot \frac{-1 - e^{\frac{-r}{s}}}{r} \]

Alternative 8: 9.3% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \frac{0.25}{r} \cdot \frac{1}{s \cdot \pi} \end{array} \]
(FPCore (s r) :precision binary32 (* (/ 0.25 r) (/ 1.0 (* s PI))))
float code(float s, float r) {
	return (0.25f / r) * (1.0f / (s * ((float) M_PI)));
}
function code(s, r)
	return Float32(Float32(Float32(0.25) / r) * Float32(Float32(1.0) / Float32(s * Float32(pi))))
end
function tmp = code(s, r)
	tmp = (single(0.25) / r) * (single(1.0) / (s * single(pi)));
end
\begin{array}{l}

\\
\frac{0.25}{r} \cdot \frac{1}{s \cdot \pi}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  4. Taylor expanded in s around inf 7.9%

    \[\leadsto \color{blue}{\frac{0.25}{r \cdot \left(s \cdot \pi\right)}} \]
  5. Step-by-step derivation
    1. associate-/r*7.9%

      \[\leadsto \color{blue}{\frac{\frac{0.25}{r}}{s \cdot \pi}} \]
  6. Simplified7.9%

    \[\leadsto \color{blue}{\frac{\frac{0.25}{r}}{s \cdot \pi}} \]
  7. Step-by-step derivation
    1. div-inv7.9%

      \[\leadsto \color{blue}{\frac{0.25}{r} \cdot \frac{1}{s \cdot \pi}} \]
  8. Applied egg-rr7.9%

    \[\leadsto \color{blue}{\frac{0.25}{r} \cdot \frac{1}{s \cdot \pi}} \]
  9. Final simplification7.9%

    \[\leadsto \frac{0.25}{r} \cdot \frac{1}{s \cdot \pi} \]

Alternative 9: 9.3% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \frac{0.25}{\left(s \cdot \pi\right) \cdot r} \end{array} \]
(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(Float32(s * Float32(pi)) * r))
end
function tmp = code(s, r)
	tmp = single(0.25) / ((s * single(pi)) * r);
end
\begin{array}{l}

\\
\frac{0.25}{\left(s \cdot \pi\right) \cdot r}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  4. Taylor expanded in s around inf 7.9%

    \[\leadsto \color{blue}{\frac{0.25}{r \cdot \left(s \cdot \pi\right)}} \]
  5. Final simplification7.9%

    \[\leadsto \frac{0.25}{\left(s \cdot \pi\right) \cdot r} \]

Alternative 10: 9.3% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{0.25}{r}}{s \cdot \pi} \end{array} \]
(FPCore (s r) :precision binary32 (/ (/ 0.25 r) (* s PI)))
float code(float s, float r) {
	return (0.25f / r) / (s * ((float) M_PI));
}
function code(s, r)
	return Float32(Float32(Float32(0.25) / r) / Float32(s * Float32(pi)))
end
function tmp = code(s, r)
	tmp = (single(0.25) / r) / (s * single(pi));
end
\begin{array}{l}

\\
\frac{\frac{0.25}{r}}{s \cdot \pi}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\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} \]
  2. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{{\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}}{r}\right)} \]
  3. Taylor expanded in r around 0 8.3%

    \[\leadsto \frac{\frac{0.125}{\pi}}{s} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  4. Taylor expanded in s around inf 7.9%

    \[\leadsto \color{blue}{\frac{0.25}{r \cdot \left(s \cdot \pi\right)}} \]
  5. Step-by-step derivation
    1. associate-/r*7.9%

      \[\leadsto \color{blue}{\frac{\frac{0.25}{r}}{s \cdot \pi}} \]
  6. Simplified7.9%

    \[\leadsto \color{blue}{\frac{\frac{0.25}{r}}{s \cdot \pi}} \]
  7. Final simplification7.9%

    \[\leadsto \frac{\frac{0.25}{r}}{s \cdot \pi} \]

Reproduce

?
herbie shell --seed 2023293 
(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))))