Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.6% → 99.6%
Time: 15.1s
Alternatives: 12
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 12 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.6% 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.6% accurate, 1.0× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot e^{\frac{-r}{s \cdot 3}}}{6 \cdot \left(\pi \cdot \left(r \cdot s\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(s \cdot \left(r \cdot \pi\right)\right)}} \]
  3. Step-by-step derivation
    1. 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^{\frac{-r}{3 \cdot s}}}{\color{blue}{\left(6 \cdot s\right) \cdot \left(r \cdot \pi\right)}} \]
  4. 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}{\left(6 \cdot s\right) \cdot \left(r \cdot \pi\right)}} \]
  5. Step-by-step derivation
    1. pow199.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(\left(6 \cdot s\right) \cdot \left(r \cdot \pi\right)\right)}^{1}}} \]
    2. 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(6 \cdot \left(s \cdot \left(r \cdot \pi\right)\right)\right)}}^{1}} \]
    3. 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}}}{{\left(6 \cdot \color{blue}{\left(\left(s \cdot r\right) \cdot \pi\right)}\right)}^{1}} \]
  6. Applied egg-rr99.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(6 \cdot \left(\left(s \cdot r\right) \cdot \pi\right)\right)}^{1}}} \]
  7. Final simplification99.6%

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

Alternative 2: 99.6% accurate, 1.0× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot e^{\frac{-r}{s \cdot 3}}}{\left(s \cdot 6\right) \cdot \left(r \cdot \pi\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(s \cdot \left(r \cdot \pi\right)\right)}} \]
  3. Step-by-step derivation
    1. 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^{\frac{-r}{3 \cdot s}}}{\color{blue}{\left(6 \cdot s\right) \cdot \left(r \cdot \pi\right)}} \]
  4. 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}{\left(6 \cdot s\right) \cdot \left(r \cdot \pi\right)}} \]
  5. Final simplification99.5%

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

Alternative 3: 99.6% accurate, 1.0× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \left(\pi \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 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}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. Final simplification99.5%

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

Alternative 4: 97.5% accurate, 1.4× speedup?

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

\\
\frac{\frac{0.125}{r \cdot \pi}}{s} \cdot \left(e^{\frac{-r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.5% accurate, 1.4× speedup?

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

\\
\frac{\frac{0.125}{r \cdot \pi}}{s} \cdot \left(e^{\frac{-r}{s}} + e^{\frac{r \cdot -0.3333333333333333}{s}}\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.5% accurate, 1.4× speedup?

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

\\
0.125 \cdot \frac{e^{\frac{-r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}}{s \cdot \left(r \cdot \pi\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 43.8% accurate, 1.4× speedup?

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

\\
\frac{0.25}{s \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(r \cdot \pi\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{0.25}{s \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(r \cdot \pi\right)\right)}} \]
    2. *-commutative36.4%

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

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

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

Alternative 8: 10.4% accurate, 1.9× speedup?

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

\\
\frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\left(r \cdot r\right) \cdot 0.05555555555555555}{s \cdot s} + \left(1 + \frac{-0.3333333333333333}{\frac{s}{r}}\right)}{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. 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. times-frac99.4%

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

      \[\leadsto \frac{0.25}{\left(2 \cdot \pi\right) \cdot s} \cdot \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} \]
    4. associate-/r*99.4%

      \[\leadsto \frac{0.25}{\left(2 \cdot \pi\right) \cdot s} \cdot \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} \]
    5. metadata-eval99.4%

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

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

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

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

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

    \[\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)} \]
  4. Taylor expanded in r around 0 9.7%

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\color{blue}{1 + \left(0.05555555555555555 \cdot \frac{{r}^{2}}{{s}^{2}} + -0.3333333333333333 \cdot \frac{r}{s}\right)}}{r}\right) \]
  5. Step-by-step derivation
    1. +-commutative9.7%

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

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\color{blue}{0.05555555555555555 \cdot \frac{{r}^{2}}{{s}^{2}} + \left(\frac{-0.3333333333333333 \cdot r}{s} + 1\right)}}{r}\right) \]
    4. *-commutative9.7%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\color{blue}{\frac{{r}^{2} \cdot 0.05555555555555555}{{s}^{2}}} + \left(\frac{-0.3333333333333333 \cdot r}{s} + 1\right)}{r}\right) \]
    6. unpow29.7%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\color{blue}{\left(r \cdot r\right)} \cdot 0.05555555555555555}{{s}^{2}} + \left(\frac{-0.3333333333333333 \cdot r}{s} + 1\right)}{r}\right) \]
    7. unpow29.7%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\left(r \cdot r\right) \cdot 0.05555555555555555}{s \cdot s} + \left(\color{blue}{-0.3333333333333333 \cdot \frac{r}{s}} + 1\right)}{r}\right) \]
    9. fma-def9.7%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\left(r \cdot r\right) \cdot 0.05555555555555555}{s \cdot s} + \color{blue}{\mathsf{fma}\left(-0.3333333333333333, \frac{r}{s}, 1\right)}}{r}\right) \]
  6. Simplified9.7%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\left(r \cdot r\right) \cdot 0.05555555555555555}{s \cdot s} + \color{blue}{\left(-0.3333333333333333 \cdot \frac{r}{s} + 1\right)}}{r}\right) \]
    2. clear-num9.7%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\left(r \cdot r\right) \cdot 0.05555555555555555}{s \cdot s} + \left(-0.3333333333333333 \cdot \color{blue}{\frac{1}{\frac{s}{r}}} + 1\right)}{r}\right) \]
    3. un-div-inv9.7%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{-r}{s}}}{r} + \frac{\frac{\left(r \cdot r\right) \cdot 0.05555555555555555}{s \cdot s} + \left(\color{blue}{\frac{-0.3333333333333333}{\frac{s}{r}}} + 1\right)}{r}\right) \]
  8. Applied egg-rr9.7%

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

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

Alternative 9: 9.6% accurate, 2.0× speedup?

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

\\
\left(e^{\frac{-r}{s}} + \left(1 + -0.3333333333333333 \cdot \frac{r}{s}\right)\right) \cdot \frac{0.125}{s \cdot \left(r \cdot \pi\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 9.6% accurate, 2.0× speedup?

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

\\
\frac{\frac{0.125}{s}}{r \cdot \pi} \cdot \left(e^{\frac{-r}{s}} + \left(1 + -0.3333333333333333 \cdot \frac{r}{s}\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 9.3% accurate, 2.0× speedup?

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

\\
\frac{\frac{0.125}{r \cdot \pi}}{s} \cdot \left(e^{\frac{-r}{s}} + 1\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 8.9% accurate, 4.0× speedup?

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

\\
\frac{0.25}{s \cdot \left(r \cdot \pi\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. Step-by-step derivation
    1. associate-*l/98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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