Disney BSSRDF, PDF of scattering profile

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

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.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, 1.1× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{0.125}{r \cdot s} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{\pi}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{8}}{r \cdot s} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)\right), \color{blue}{\mathsf{PI}\left(\right)}\right) \]
  5. Applied egg-rr99.7%

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

    \[\leadsto \frac{\frac{e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}}{\frac{r \cdot s}{0.125}}}{\pi} \]
  7. Add Preprocessing

Alternative 2: 99.5% accurate, 1.1× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{0.125}{r \cdot s} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{\pi}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \frac{\frac{1}{8}}{r \cdot s} \cdot \color{blue}{\frac{e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}}{\mathsf{PI}\left(\right)}} \]
    2. frac-timesN/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{\color{blue}{\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)\right), \color{blue}{\left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)\right), \left(\color{blue}{\left(r \cdot s\right)} \cdot \mathsf{PI}\left(\right)\right)\right) \]
    5. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\left(e^{0 - \frac{r}{s}}\right), \left(e^{\frac{\frac{r}{s}}{-3}}\right)\right)\right), \left(\left(r \cdot \color{blue}{s}\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    6. sub0-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\left(e^{\mathsf{neg}\left(\frac{r}{s}\right)}\right), \left(e^{\frac{\frac{r}{s}}{-3}}\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    7. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{r}{s}\right)\right)\right), \left(e^{\frac{\frac{r}{s}}{-3}}\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    8. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\left(\frac{r}{\mathsf{neg}\left(s\right)}\right)\right), \left(e^{\frac{\frac{r}{s}}{-3}}\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \left(\mathsf{neg}\left(s\right)\right)\right)\right), \left(e^{\frac{\frac{r}{s}}{-3}}\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \left(e^{\frac{\frac{r}{s}}{-3}}\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    11. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\left(\frac{\frac{r}{s}}{-3}\right)\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    12. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\frac{r}{s}\right), -3\right)\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    13. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(r, s\right), -3\right)\right)\right)\right), \left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
    14. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(r, s\right), -3\right)\right)\right)\right), \mathsf{*.f32}\left(\left(r \cdot s\right), \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    15. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(r, s\right), -3\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(r, s\right), \mathsf{PI}\left(\right)\right)\right) \]
    16. PI-lowering-PI.f3299.7%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(r, s\right), -3\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(r, s\right), \mathsf{PI.f32}\left(\right)\right)\right) \]
  5. Applied egg-rr99.7%

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

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

Alternative 3: 99.5% accurate, 1.1× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{0.125}{r \cdot s} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{\pi}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{r \cdot s}\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{r}}{s}\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + e^{\frac{\frac{r}{s}}{-3}}\right)}{r}\right), s\right), \mathsf{PI.f32}\left(\right)\right) \]
  5. Applied egg-rr99.7%

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\left(\frac{r}{-3 \cdot s}\right)\right)\right)\right), r\right), s\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\left(\frac{\frac{r}{-3}}{s}\right)\right)\right)\right), r\right), s\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\frac{r}{-3}\right), s\right)\right)\right)\right), r\right), s\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. /-lowering-/.f3299.7%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, \mathsf{neg.f32}\left(s\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(r, -3\right), s\right)\right)\right)\right), r\right), s\right), \mathsf{PI.f32}\left(\right)\right) \]
  7. Applied egg-rr99.7%

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

      \[\leadsto \frac{\frac{\frac{1}{8} \cdot \left(e^{\frac{r}{\mathsf{neg}\left(s\right)}} + e^{\frac{\frac{r}{-3}}{s}}\right)}{r}}{\color{blue}{\mathsf{PI}\left(\right) \cdot s}} \]
    2. associate-/l*N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{e^{\frac{r}{\mathsf{neg}\left(s\right)}} + e^{\frac{\frac{r}{-3}}{s}}}{r}}{\color{blue}{\mathsf{PI}\left(\right)} \cdot s} \]
    3. associate-/l*N/A

      \[\leadsto \frac{1}{8} \cdot \color{blue}{\frac{\frac{e^{\frac{r}{\mathsf{neg}\left(s\right)}} + e^{\frac{\frac{r}{-3}}{s}}}{r}}{\mathsf{PI}\left(\right) \cdot s}} \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\frac{1}{8}, \color{blue}{\left(\frac{\frac{e^{\frac{r}{\mathsf{neg}\left(s\right)}} + e^{\frac{\frac{r}{-3}}{s}}}{r}}{\mathsf{PI}\left(\right) \cdot s}\right)}\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\frac{1}{8}, \mathsf{/.f32}\left(\left(\frac{e^{\frac{r}{\mathsf{neg}\left(s\right)}} + e^{\frac{\frac{r}{-3}}{s}}}{r}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot s\right)}\right)\right) \]
  9. Applied egg-rr99.6%

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

    \[\leadsto 0.125 \cdot \frac{\frac{e^{0 - \frac{r}{s}} + e^{\frac{r}{s \cdot -3}}}{r}}{s \cdot \pi} \]
  11. Add Preprocessing

Alternative 4: 10.8% accurate, 1.8× speedup?

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \color{blue}{\left(1 + \left(\frac{-1}{3} \cdot \frac{r}{s} + \frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)}\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \left(\frac{-1}{3} \cdot \frac{r}{s} + \frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{-1}{3} \cdot \frac{r}{s}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{r}{s} \cdot \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{r}{s}\right), \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \left(\frac{\frac{1}{18} \cdot {r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(\frac{1}{18} \cdot {r}^{2}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left({r}^{2} \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(\left(r \cdot r\right) \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    10. associate-*l*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(r \cdot \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(r \cdot \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    14. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    15. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left(s \cdot s\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    16. *-lowering-*.f329.5%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \mathsf{*.f32}\left(s, s\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified9.5%

    \[\leadsto \frac{\frac{0.125}{r \cdot s} \cdot \left(e^{0 - \frac{r}{s}} + \color{blue}{\left(1 + \left(\frac{r}{s} \cdot -0.3333333333333333 + \frac{r \cdot \left(r \cdot 0.05555555555555555\right)}{s \cdot s}\right)\right)}\right)}{\pi} \]
  7. Step-by-step derivation
    1. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + \left(1 + \left(\frac{r}{s} \cdot \frac{-1}{3} + \frac{r \cdot \left(r \cdot \frac{1}{18}\right)}{s \cdot s}\right)\right)\right)}{r \cdot s}\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + \left(1 + \left(\frac{r}{s} \cdot \frac{-1}{3} + \frac{r \cdot \left(r \cdot \frac{1}{18}\right)}{s \cdot s}\right)\right)\right)}{s \cdot r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + \left(1 + \left(\frac{r}{s} \cdot \frac{-1}{3} + \frac{r \cdot \left(r \cdot \frac{1}{18}\right)}{s \cdot s}\right)\right)\right)}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{8} \cdot \left(e^{0 - \frac{r}{s}} + \left(1 + \left(\frac{r}{s} \cdot \frac{-1}{3} + \frac{r \cdot \left(r \cdot \frac{1}{18}\right)}{s \cdot s}\right)\right)\right)}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
  8. Applied egg-rr9.6%

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

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

Alternative 5: 10.2% accurate, 13.6× speedup?

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{r \cdot \left(\frac{5}{72} \cdot \frac{r}{{s}^{3}} - \frac{1}{6} \cdot \frac{1}{{s}^{2}}\right) + \frac{1}{4} \cdot \frac{1}{s}}{r}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(r \cdot \left(\frac{5}{72} \cdot \frac{r}{{s}^{3}} - \frac{1}{6} \cdot \frac{1}{{s}^{2}}\right) + \frac{1}{4} \cdot \frac{1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified7.5%

    \[\leadsto \frac{\color{blue}{\frac{\frac{0.25}{s} + r \cdot \left(0.06944444444444445 \cdot \frac{\frac{r}{s \cdot s}}{s} + \frac{-0.16666666666666666}{s \cdot s}\right)}{r}}}{\pi} \]
  7. Taylor expanded in s around inf

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{\left(\frac{5}{72} \cdot \frac{r}{{s}^{2}} + \frac{1}{4} \cdot \frac{1}{r}\right) - \frac{1}{6} \cdot \frac{1}{s}}{s}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  8. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\left(\frac{5}{72} \cdot \frac{r}{{s}^{2}} + \frac{1}{4} \cdot \frac{1}{r}\right) - \frac{1}{6} \cdot \frac{1}{s}\right), s\right), \mathsf{PI.f32}\left(\right)\right) \]
  9. Simplified9.0%

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

Alternative 6: 9.1% accurate, 33.0× speedup?

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{\frac{1}{4}}{r \cdot s}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s \cdot r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{4}}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{4} \cdot 1}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot \frac{1}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{4} \cdot \frac{1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot 1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. /-lowering-/.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified8.4%

    \[\leadsto \frac{\color{blue}{\frac{\frac{0.25}{s}}{r}}}{\pi} \]
  7. Step-by-step derivation
    1. associate-/l/N/A

      \[\leadsto \frac{\frac{\frac{1}{4}}{s}}{\color{blue}{\mathsf{PI}\left(\right) \cdot r}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot r\right)}\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot r\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), \left(r \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), \mathsf{*.f32}\left(r, \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    6. PI-lowering-PI.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right) \]
  8. Applied egg-rr8.4%

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

Alternative 7: 9.1% accurate, 33.0× speedup?

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{\frac{1}{4}}{r \cdot s}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s \cdot r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{4}}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{4} \cdot 1}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot \frac{1}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{4} \cdot \frac{1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot 1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. /-lowering-/.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified8.4%

    \[\leadsto \frac{\color{blue}{\frac{\frac{0.25}{s}}{r}}}{\pi} \]
  7. Step-by-step derivation
    1. div-invN/A

      \[\leadsto \frac{\frac{\frac{1}{4}}{s}}{r} \cdot \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}} \]
    2. associate-/l/N/A

      \[\leadsto \frac{\frac{1}{4}}{r \cdot s} \cdot \frac{\color{blue}{1}}{\mathsf{PI}\left(\right)} \]
    3. frac-timesN/A

      \[\leadsto \frac{\frac{1}{4} \cdot 1}{\color{blue}{\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)}} \]
    4. metadata-evalN/A

      \[\leadsto \frac{\frac{1}{4}}{\color{blue}{\left(r \cdot s\right)} \cdot \mathsf{PI}\left(\right)} \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \color{blue}{\left(\left(r \cdot s\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    6. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\left(r \cdot s\right), \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\left(s \cdot r\right), \mathsf{PI}\left(\right)\right)\right) \]
    8. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, r\right), \mathsf{PI}\left(\right)\right)\right) \]
    9. PI-lowering-PI.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, r\right), \mathsf{PI.f32}\left(\right)\right)\right) \]
  8. Applied egg-rr8.4%

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

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{\frac{1}{4}}{r \cdot s}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s \cdot r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{4}}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{\frac{1}{4} \cdot 1}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot \frac{1}{s}}{r}\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{4} \cdot \frac{1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot 1}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{s}\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. /-lowering-/.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, s\right), r\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified8.4%

    \[\leadsto \frac{\color{blue}{\frac{\frac{0.25}{s}}{r}}}{\pi} \]
  7. Step-by-step derivation
    1. associate-/l/N/A

      \[\leadsto \frac{\frac{\frac{1}{4}}{s}}{\color{blue}{\mathsf{PI}\left(\right) \cdot r}} \]
    2. associate-/l/N/A

      \[\leadsto \frac{\frac{1}{4}}{\color{blue}{\left(\mathsf{PI}\left(\right) \cdot r\right) \cdot s}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \color{blue}{\left(\left(\mathsf{PI}\left(\right) \cdot r\right) \cdot s\right)}\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\left(\mathsf{PI}\left(\right) \cdot r\right), \color{blue}{s}\right)\right) \]
    5. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\left(r \cdot \mathsf{PI}\left(\right)\right), s\right)\right) \]
    6. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(r, \mathsf{PI}\left(\right)\right), s\right)\right) \]
    7. PI-lowering-PI.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right), s\right)\right) \]
  8. Applied egg-rr8.4%

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

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

Alternative 9: 7.1% accurate, 33.0× speedup?

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \color{blue}{\left(1 + \left(\frac{-1}{3} \cdot \frac{r}{s} + \frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)}\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \left(\frac{-1}{3} \cdot \frac{r}{s} + \frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{-1}{3} \cdot \frac{r}{s}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{r}{s} \cdot \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{r}{s}\right), \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \left(\frac{\frac{1}{18} \cdot {r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(\frac{1}{18} \cdot {r}^{2}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left({r}^{2} \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(\left(r \cdot r\right) \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    10. associate-*l*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(r \cdot \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(r \cdot \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    14. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    15. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left(s \cdot s\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    16. *-lowering-*.f329.5%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \mathsf{*.f32}\left(s, s\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified9.5%

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \color{blue}{\left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)}\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  8. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \left(\frac{\frac{1}{18} \cdot {r}^{2}}{{s}^{2}}\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(\frac{1}{18} \cdot {r}^{2}\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left({r}^{2} \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(\left(r \cdot r\right) \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. associate-*l*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(r \cdot \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(r \cdot \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    10. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left(s \cdot s\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    11. *-lowering-*.f325.6%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  9. Simplified5.6%

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

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{\frac{1}{8}}{r \cdot s}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  11. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \left(r \cdot s\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \left(s \cdot r\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-lowering-*.f326.6%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, r\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  12. Simplified6.6%

    \[\leadsto \frac{\color{blue}{\frac{0.125}{s \cdot r}}}{\pi} \]
  13. Step-by-step derivation
    1. associate-/l/N/A

      \[\leadsto \frac{\frac{1}{8}}{\color{blue}{\mathsf{PI}\left(\right) \cdot \left(s \cdot r\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(s \cdot r\right)\right)}\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \left(\left(s \cdot r\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(\left(s \cdot r\right), \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, r\right), \mathsf{PI}\left(\right)\right)\right) \]
    6. PI-lowering-PI.f326.6%

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, r\right), \mathsf{PI.f32}\left(\right)\right)\right) \]
  14. Applied egg-rr6.6%

    \[\leadsto \color{blue}{\frac{0.125}{\left(s \cdot r\right) \cdot \pi}} \]
  15. Final simplification6.6%

    \[\leadsto \frac{0.125}{\left(r \cdot s\right) \cdot \pi} \]
  16. Add Preprocessing

Alternative 10: 7.1% accurate, 33.0× speedup?

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \color{blue}{\left(1 + \left(\frac{-1}{3} \cdot \frac{r}{s} + \frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)}\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  5. Step-by-step derivation
    1. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \left(\frac{-1}{3} \cdot \frac{r}{s} + \frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{-1}{3} \cdot \frac{r}{s}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{r}{s} \cdot \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{r}{s}\right), \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \left(\frac{\frac{1}{18} \cdot {r}^{2}}{{s}^{2}}\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(\frac{1}{18} \cdot {r}^{2}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left({r}^{2} \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(\left(r \cdot r\right) \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    10. associate-*l*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(r \cdot \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\left(r \cdot \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    14. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    15. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left(s \cdot s\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    16. *-lowering-*.f329.5%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \mathsf{*.f32}\left(s, s\right)\right)\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified9.5%

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \color{blue}{\left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}}\right)}\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  8. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \left(\frac{\frac{1}{18} \cdot {r}^{2}}{{s}^{2}}\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(\frac{1}{18} \cdot {r}^{2}\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left({r}^{2} \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(\left(r \cdot r\right) \cdot \frac{1}{18}\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    5. associate-*l*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(r \cdot \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\left(r \cdot \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{1}{18} \cdot r\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(r \cdot \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left({s}^{2}\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    10. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \left(s \cdot s\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    11. *-lowering-*.f325.6%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, s\right)\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(r, s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(r, \frac{1}{18}\right)\right), \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  9. Simplified5.6%

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

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left(\frac{\frac{1}{8}}{r \cdot s}\right)}, \mathsf{PI.f32}\left(\right)\right) \]
  11. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \left(r \cdot s\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \left(s \cdot r\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
    3. *-lowering-*.f326.6%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, r\right)\right), \mathsf{PI.f32}\left(\right)\right) \]
  12. Simplified6.6%

    \[\leadsto \frac{\color{blue}{\frac{0.125}{s \cdot r}}}{\pi} \]
  13. Taylor expanded in s around 0

    \[\leadsto \color{blue}{\frac{\frac{1}{8}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)}} \]
  14. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \color{blue}{\left(r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, \color{blue}{\left(s \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
    4. PI-lowering-PI.f326.6%

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
  15. Simplified6.6%

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

Reproduce

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