Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.6% → 99.5%
Time: 11.2s
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.5% accurate, 0.5× speedup?

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

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

    \[\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.6%

      \[\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. *-commutative99.6%

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(2 \cdot \pi\right)}} \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} \]
    3. distribute-frac-neg99.6%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\color{blue}{-\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} \]
    4. associate-/l*99.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{-\frac{r}{s}}}{r} + 0.75 \cdot \frac{e^{\frac{-r}{s \cdot 3}}}{\color{blue}{s \cdot \left(\pi \cdot \left(r \cdot 6\right)\right)}} \]
  8. Step-by-step derivation
    1. expm1-log1p-u99.7%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{-\frac{r}{s}}}{r} + 0.75 \cdot \frac{e^{\frac{-r}{s \cdot 3}}}{s \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \left(r \cdot 6\right)\right)\right)}} \]
  9. Applied egg-rr99.7%

    \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{-\frac{r}{s}}}{r} + 0.75 \cdot \frac{e^{\frac{-r}{s \cdot 3}}}{s \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \left(r \cdot 6\right)\right)\right)}} \]
  10. Final simplification99.7%

    \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\frac{r}{-s}}}{r} + 0.75 \cdot \frac{e^{\frac{r}{s \cdot \left(-3\right)}}}{s \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \left(r \cdot 6\right)\right)\right)} \]
  11. Add Preprocessing

Alternative 2: 99.6% accurate, 1.0× speedup?

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

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

    \[\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.6%

      \[\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. *-commutative99.6%

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(2 \cdot \pi\right)}} \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} \]
    3. distribute-frac-neg99.6%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\color{blue}{-\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} \]
    4. associate-/l*99.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.6% accurate, 1.0× speedup?

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

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

    \[\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.6%

      \[\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. *-commutative99.6%

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(2 \cdot \pi\right)}} \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} \]
    3. distribute-frac-neg99.6%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\color{blue}{-\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} \]
    4. associate-/l*99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.6% accurate, 1.0× speedup?

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

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

    \[\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.6%

      \[\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. *-commutative99.6%

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(2 \cdot \pi\right)}} \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} \]
    3. distribute-frac-neg99.6%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\color{blue}{-\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} \]
    4. associate-/l*99.6%

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{-\frac{r}{s}}}{r} + 0.75 \cdot \frac{e^{\frac{-r}{s \cdot 3}}}{r \cdot \left(6 \cdot \left(\pi \cdot s\right)\right)}} \]
  4. Add Preprocessing
  5. Final simplification99.7%

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

Alternative 5: 99.6% accurate, 1.0× speedup?

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

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

    \[\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.6%

      \[\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. *-commutative99.6%

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(2 \cdot \pi\right)}} \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} \]
    3. distribute-frac-neg99.6%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\color{blue}{-\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} \]
    4. associate-/l*99.6%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.5% accurate, 1.0× speedup?

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

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

    \[\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.6%

      \[\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. *-commutative99.6%

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(2 \cdot \pi\right)}} \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} \]
    3. distribute-frac-neg99.6%

      \[\leadsto \frac{0.25}{s \cdot \left(2 \cdot \pi\right)} \cdot \frac{e^{\color{blue}{-\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} \]
    4. associate-/l*99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.75 \cdot \frac{e^{\frac{r}{s \cdot \left(-3\right)}}}{s \cdot \left(6 \cdot \left(\pi \cdot r\right)\right)} + \frac{e^{\frac{r}{-s}}}{r} \cdot \frac{\frac{0.125}{s}}{\pi} \]
  13. Add Preprocessing

Alternative 7: 99.5% accurate, 1.1× speedup?

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

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

    \[\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{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. Add Preprocessing
  4. Taylor expanded in r around inf 99.6%

    \[\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) \]
  5. Final simplification99.6%

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

Alternative 8: 12.0% accurate, 1.1× speedup?

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

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

    \[\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{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. Add Preprocessing
  4. Taylor expanded in r around 0 9.8%

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

    \[\leadsto \color{blue}{\frac{0.25}{r \cdot \left(s \cdot \pi\right)}} \]
  6. Step-by-step derivation
    1. *-commutative9.3%

      \[\leadsto \frac{0.25}{r \cdot \color{blue}{\left(\pi \cdot s\right)}} \]
    2. add-sqr-sqrt9.3%

      \[\leadsto \frac{0.25}{r \cdot \left(\pi \cdot \color{blue}{\left(\sqrt{s} \cdot \sqrt{s}\right)}\right)} \]
    3. sqrt-unprod9.1%

      \[\leadsto \frac{0.25}{r \cdot \left(\pi \cdot \color{blue}{\sqrt{s \cdot s}}\right)} \]
    4. sqr-neg9.1%

      \[\leadsto \frac{0.25}{r \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(-s\right) \cdot \left(-s\right)}}\right)} \]
    5. sqrt-unprod-0.0%

      \[\leadsto \frac{0.25}{r \cdot \left(\pi \cdot \color{blue}{\left(\sqrt{-s} \cdot \sqrt{-s}\right)}\right)} \]
    6. add-sqr-sqrt4.4%

      \[\leadsto \frac{0.25}{r \cdot \left(\pi \cdot \color{blue}{\left(-s\right)}\right)} \]
    7. distribute-rgt-neg-in4.4%

      \[\leadsto \frac{0.25}{r \cdot \color{blue}{\left(-\pi \cdot s\right)}} \]
    8. distribute-rgt-neg-in4.4%

      \[\leadsto \frac{0.25}{\color{blue}{-r \cdot \left(\pi \cdot s\right)}} \]
    9. *-commutative4.4%

      \[\leadsto \frac{0.25}{-r \cdot \color{blue}{\left(s \cdot \pi\right)}} \]
    10. log1p-expm1-u7.5%

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

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

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(-\color{blue}{\left(\pi \cdot s\right)} \cdot r\right)\right)} \]
    13. distribute-lft-neg-in7.5%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(-\pi \cdot s\right) \cdot r}\right)\right)} \]
    14. distribute-rgt-neg-in7.5%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot \left(-s\right)\right)} \cdot r\right)\right)} \]
    15. add-sqr-sqrt-0.0%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(\pi \cdot \color{blue}{\left(\sqrt{-s} \cdot \sqrt{-s}\right)}\right) \cdot r\right)\right)} \]
    16. sqrt-unprod11.9%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(\pi \cdot \color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}\right) \cdot r\right)\right)} \]
    17. sqr-neg11.9%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(\pi \cdot \sqrt{\color{blue}{s \cdot s}}\right) \cdot r\right)\right)} \]
    18. sqrt-unprod12.1%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(\pi \cdot \color{blue}{\left(\sqrt{s} \cdot \sqrt{s}\right)}\right) \cdot r\right)\right)} \]
    19. add-sqr-sqrt12.1%

      \[\leadsto \frac{0.25}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(\pi \cdot \color{blue}{s}\right) \cdot r\right)\right)} \]
    20. associate-*l*12.1%

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

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

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

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

Alternative 9: 10.0% accurate, 11.0× speedup?

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

\\
\frac{\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{0.16666666666666666}{\pi}}{s} + \frac{0.25}{\pi \cdot r}}{s}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\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{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. Add Preprocessing
  4. Taylor expanded in r around inf 99.6%

    \[\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) \]
  5. Step-by-step derivation
    1. *-lft-identity99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.0625 \cdot \frac{r}{s \cdot \pi} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s}} \]
  14. Step-by-step derivation
    1. mul-1-neg10.3%

      \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.0625 \cdot \frac{r}{s \cdot \pi} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s}} \]
    2. mul-1-neg10.3%

      \[\leadsto -\frac{\color{blue}{\left(-\frac{0.0625 \cdot \frac{r}{s \cdot \pi} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s}\right)} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s} \]
    3. *-commutative10.3%

      \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{r}{s \cdot \pi} \cdot 0.0625} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s}\right) - 0.25 \cdot \frac{1}{r \cdot \pi}}{s} \]
    4. associate-*r/10.3%

      \[\leadsto -\frac{\left(-\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \color{blue}{\frac{0.16666666666666666 \cdot 1}{\pi}}}{s}\right) - 0.25 \cdot \frac{1}{r \cdot \pi}}{s} \]
    5. metadata-eval10.3%

      \[\leadsto -\frac{\left(-\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{\color{blue}{0.16666666666666666}}{\pi}}{s}\right) - 0.25 \cdot \frac{1}{r \cdot \pi}}{s} \]
    6. associate-*r/10.3%

      \[\leadsto -\frac{\left(-\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{0.16666666666666666}{\pi}}{s}\right) - \color{blue}{\frac{0.25 \cdot 1}{r \cdot \pi}}}{s} \]
    7. metadata-eval10.3%

      \[\leadsto -\frac{\left(-\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{0.16666666666666666}{\pi}}{s}\right) - \frac{\color{blue}{0.25}}{r \cdot \pi}}{s} \]
    8. *-commutative10.3%

      \[\leadsto -\frac{\left(-\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{0.16666666666666666}{\pi}}{s}\right) - \frac{0.25}{\color{blue}{\pi \cdot r}}}{s} \]
  15. Simplified10.3%

    \[\leadsto \color{blue}{-\frac{\left(-\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{0.16666666666666666}{\pi}}{s}\right) - \frac{0.25}{\pi \cdot r}}{s}} \]
  16. Final simplification10.3%

    \[\leadsto \frac{\frac{\frac{r}{s \cdot \pi} \cdot 0.0625 - \frac{0.16666666666666666}{\pi}}{s} + \frac{0.25}{\pi \cdot r}}{s} \]
  17. Add Preprocessing

Alternative 10: 9.2% accurate, 17.8× speedup?

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

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

    \[\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{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. Add Preprocessing
  4. Taylor expanded in r around inf 99.6%

    \[\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) \]
  5. Step-by-step derivation
    1. *-lft-identity99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.25 \cdot \frac{1}{r \cdot \pi} - 0.16666666666666666 \cdot \frac{1}{s \cdot \pi}}{s}} \]
  14. Step-by-step derivation
    1. associate-*r/9.6%

      \[\leadsto \frac{0.25 \cdot \frac{1}{r \cdot \pi} - \color{blue}{\frac{0.16666666666666666 \cdot 1}{s \cdot \pi}}}{s} \]
    2. metadata-eval9.6%

      \[\leadsto \frac{0.25 \cdot \frac{1}{r \cdot \pi} - \frac{\color{blue}{0.16666666666666666}}{s \cdot \pi}}{s} \]
    3. associate-*r/9.6%

      \[\leadsto \frac{\color{blue}{\frac{0.25 \cdot 1}{r \cdot \pi}} - \frac{0.16666666666666666}{s \cdot \pi}}{s} \]
    4. metadata-eval9.6%

      \[\leadsto \frac{\frac{\color{blue}{0.25}}{r \cdot \pi} - \frac{0.16666666666666666}{s \cdot \pi}}{s} \]
    5. *-commutative9.6%

      \[\leadsto \frac{\frac{0.25}{\color{blue}{\pi \cdot r}} - \frac{0.16666666666666666}{s \cdot \pi}}{s} \]
    6. associate-/r*9.6%

      \[\leadsto \frac{\frac{0.25}{\pi \cdot r} - \color{blue}{\frac{\frac{0.16666666666666666}{s}}{\pi}}}{s} \]
  15. Simplified9.6%

    \[\leadsto \color{blue}{\frac{\frac{0.25}{\pi \cdot r} - \frac{\frac{0.16666666666666666}{s}}{\pi}}{s}} \]
  16. Add Preprocessing

Alternative 11: 9.1% accurate, 33.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.6%

    \[\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{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. Add Preprocessing
  4. Taylor expanded in r around 0 9.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.125}{r} \cdot \frac{1 + e^{-1 \cdot \frac{r}{s}}}{\pi \cdot s}} \]
    4. mul-1-neg9.8%

      \[\leadsto \frac{0.125}{r} \cdot \frac{1 + e^{\color{blue}{-\frac{r}{s}}}}{\pi \cdot s} \]
    5. distribute-neg-frac29.8%

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

    \[\leadsto \color{blue}{\frac{0.125}{r} \cdot \frac{1 + e^{\frac{r}{-s}}}{\pi \cdot s}} \]
  8. Taylor expanded in r around 0 9.3%

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

      \[\leadsto \color{blue}{\frac{\frac{0.25}{r}}{s \cdot \pi}} \]
    2. *-commutative9.4%

      \[\leadsto \frac{\frac{0.25}{r}}{\color{blue}{\pi \cdot s}} \]
  10. Simplified9.4%

    \[\leadsto \color{blue}{\frac{\frac{0.25}{r}}{\pi \cdot s}} \]
  11. Final simplification9.4%

    \[\leadsto \frac{\frac{0.25}{r}}{s \cdot \pi} \]
  12. Add Preprocessing

Alternative 12: 9.1% accurate, 33.0× speedup?

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

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

    \[\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{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. Add Preprocessing
  4. Taylor expanded in r around 0 9.8%

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

    \[\leadsto \color{blue}{\frac{0.25}{r \cdot \left(s \cdot \pi\right)}} \]
  6. Add Preprocessing

Reproduce

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