Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.6% → 99.5%
Time: 15.5s
Alternatives: 23
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 23 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{\left(e^{\frac{r \cdot -0.3333333333333333}{s}} + e^{0 - \frac{r}{s}}\right) \cdot 0.125}{r \cdot \left(s \cdot \pi\right)} \end{array} \]
(FPCore (s r)
 :precision binary32
 (/
  (* (+ (exp (/ (* r -0.3333333333333333) s)) (exp (- 0.0 (/ r s)))) 0.125)
  (* r (* s PI))))
float code(float s, float r) {
	return ((expf(((r * -0.3333333333333333f) / s)) + expf((0.0f - (r / s)))) * 0.125f) / (r * (s * ((float) M_PI)));
}
function code(s, r)
	return Float32(Float32(Float32(exp(Float32(Float32(r * Float32(-0.3333333333333333)) / s)) + exp(Float32(Float32(0.0) - Float32(r / s)))) * Float32(0.125)) / Float32(r * Float32(s * Float32(pi))))
end
function tmp = code(s, r)
	tmp = ((exp(((r * single(-0.3333333333333333)) / s)) + exp((single(0.0) - (r / s)))) * single(0.125)) / (r * (s * single(pi)));
end
\begin{array}{l}

\\
\frac{\left(e^{\frac{r \cdot -0.3333333333333333}{s}} + e^{0 - \frac{r}{s}}\right) \cdot 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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(r \cdot \frac{-1}{3}\right), s\right)\right), \left(\frac{1}{e^{\frac{r}{s}}}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\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(\mathsf{*.f32}\left(r, \frac{-1}{3}\right), s\right)\right), \left(\frac{1}{e^{\frac{r}{s}}}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    10. inv-powN/A

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \frac{-1}{3}\right), s\right)\right), \left(e^{\frac{r}{s} \cdot -1}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    12. 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(\mathsf{*.f32}\left(r, \frac{-1}{3}\right), s\right)\right), \mathsf{exp.f32}\left(\left(\frac{r}{s} \cdot -1\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\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(\mathsf{*.f32}\left(r, \frac{-1}{3}\right), s\right)\right), \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\left(\frac{r}{s}\right), -1\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    14. /-lowering-/.f3299.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 75.4% accurate, 1.6× speedup?

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

\\
\frac{\frac{0.125}{1 + r \cdot \left(\frac{1}{s} + r \cdot \left(0.16666666666666666 \cdot \frac{r}{s \cdot \left(s \cdot s\right)} + \frac{0.5}{s \cdot s}\right)\right)} + 0.125 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}}}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{1}{6}, \mathsf{/.f32}\left(r, \left({s}^{3}\right)\right)\right), \left(\frac{1}{2} \cdot \frac{1}{{s}^{2}}\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\frac{1}{8}, \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    10. cube-multN/A

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{1}{6}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \left(\frac{\frac{1}{2} \cdot 1}{{s}^{2}}\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\frac{1}{8}, \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    16. metadata-evalN/A

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{1}{6}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\frac{1}{8}, \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
  10. Simplified78.2%

    \[\leadsto \frac{\frac{0.125}{\color{blue}{1 + r \cdot \left(\frac{1}{s} + r \cdot \left(0.16666666666666666 \cdot \frac{r}{s \cdot \left(s \cdot s\right)} + \frac{0.5}{s \cdot s}\right)\right)}} + 0.125 \cdot e^{\frac{r}{s} \cdot -0.3333333333333333}}{\left(s \cdot \pi\right) \cdot r} \]
  11. Final simplification78.2%

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

Alternative 3: 73.1% accurate, 1.7× speedup?

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

\\
\frac{0.125 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}} + \frac{0.125}{1 + \frac{r + \frac{0.5 \cdot \left(r \cdot r\right) + \frac{0.16666666666666666 \cdot \left(r \cdot \left(r \cdot r\right)\right)}{s}}{s}}{s}}}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}}{s}\right)}\right), \mathsf{*.f32}\left(\frac{1}{8}, \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
  9. Step-by-step derivation
    1. mul-1-negN/A

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}\right), s\right)\right)\right), \mathsf{*.f32}\left(\frac{1}{8}, \mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, s\right), \frac{-1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
  10. Simplified75.3%

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

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

Alternative 4: 58.9% accurate, 1.8× speedup?

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

\\
\frac{0.125 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}} + \frac{0.125}{1 + r \cdot \left(\frac{1}{s} + 0.5 \cdot \frac{r}{s \cdot s}\right)}}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 57.3% accurate, 1.8× speedup?

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

\\
\frac{0.125 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}} + \frac{0.125}{1 + \frac{r - \frac{\left(r \cdot r\right) \cdot -0.5}{s}}{s}}}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 15.3% accurate, 1.9× speedup?

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

\\
\frac{0.125 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}} + \frac{0.125}{1 + \frac{r}{s}}}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 10.2% accurate, 3.7× speedup?

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

\\
\frac{\frac{\frac{0.125}{s \cdot \pi}}{1 + \frac{r + \frac{0.5 \cdot \left(r \cdot r\right) + \frac{0.16666666666666666 \cdot \left(r \cdot \left(r \cdot r\right)\right)}{s}}{s}}{s}}}{r} + \frac{\frac{\frac{-0.041666666666666664}{\pi} - \frac{\frac{r}{\pi} \cdot -0.006944444444444444 + \frac{\left(r \cdot r\right) \cdot 0.0007716049382716049}{s \cdot \pi}}{s}}{s} - \frac{-0.125}{r \cdot \pi}}{s}
\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. Add Preprocessing
  3. Step-by-step derivation
    1. times-fracN/A

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{0.125}{s \cdot \pi}}{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} \]
  5. Taylor expanded in s around -inf

    \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(r, s\right)\right)\right), r\right), \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{1}{1296} \cdot \frac{{r}^{2}}{s \cdot \mathsf{PI}\left(\right)}}{s} - \frac{1}{24} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{8} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}\right)}\right) \]
  6. Simplified9.0%

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

    \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right), \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}}{s}\right)}\right), r\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{8}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{24}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, \mathsf{PI.f32}\left(\right)\right), \frac{-1}{144}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(r, r\right), \frac{1}{1296}\right), \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right)\right) \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right), \left(1 + \left(\mathsf{neg}\left(\frac{-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}}{s}\right)\right)\right)\right), r\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{8}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \color{blue}{r}\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{24}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, \mathsf{PI.f32}\left(\right)\right), \frac{-1}{144}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(r, r\right), \frac{1}{1296}\right), \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right)\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right), \left(1 - \frac{-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}}{s}\right)\right), r\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{8}, \color{blue}{\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)}\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{24}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, \mathsf{PI.f32}\left(\right)\right), \frac{-1}{144}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(r, r\right), \frac{1}{1296}\right), \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\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(s, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{\_.f32}\left(1, \left(\frac{-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}}{s}\right)\right)\right), r\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{8}, \color{blue}{\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)}\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{24}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, \mathsf{PI.f32}\left(\right)\right), \frac{-1}{144}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(r, r\right), \frac{1}{1296}\right), \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right)\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{8}, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot r + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{r}^{3}}{s} + \frac{1}{2} \cdot {r}^{2}}{s}\right), s\right)\right)\right), r\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{8}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \color{blue}{r}\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{24}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(r, \mathsf{PI.f32}\left(\right)\right), \frac{-1}{144}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(r, r\right), \frac{1}{1296}\right), \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right)\right) \]
  9. Simplified8.6%

    \[\leadsto \frac{\frac{\frac{0.125}{s \cdot \pi}}{\color{blue}{1 - \frac{\left(-r\right) - \frac{\left(r \cdot r\right) \cdot 0.5 + \frac{0.16666666666666666 \cdot \left(r \cdot \left(r \cdot r\right)\right)}{s}}{s}}{s}}}}{r} + \frac{\frac{-0.125}{\pi \cdot r} - \frac{\frac{-0.041666666666666664}{\pi} - \frac{\frac{r}{\pi} \cdot -0.006944444444444444 + \frac{\left(r \cdot r\right) \cdot 0.0007716049382716049}{s \cdot \pi}}{s}}{s}}{-s} \]
  10. Final simplification8.6%

    \[\leadsto \frac{\frac{\frac{0.125}{s \cdot \pi}}{1 + \frac{r + \frac{0.5 \cdot \left(r \cdot r\right) + \frac{0.16666666666666666 \cdot \left(r \cdot \left(r \cdot r\right)\right)}{s}}{s}}{s}}}{r} + \frac{\frac{\frac{-0.041666666666666664}{\pi} - \frac{\frac{r}{\pi} \cdot -0.006944444444444444 + \frac{\left(r \cdot r\right) \cdot 0.0007716049382716049}{s \cdot \pi}}{s}}{s} - \frac{-0.125}{r \cdot \pi}}{s} \]
  11. Add Preprocessing

Alternative 8: 9.9% accurate, 7.0× speedup?

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

\\
\frac{1}{s} \cdot \left(\frac{\frac{0.25}{\pi}}{r} + \frac{\frac{-0.16666666666666666}{\pi} + \frac{\left(\frac{0.020833333333333332}{\frac{s}{r \cdot r}} + r \cdot -0.06944444444444445\right) \cdot \frac{-1}{\pi}}{s}}{s}\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. Add Preprocessing
  3. Taylor expanded in s around inf

    \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(r\right), s\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), s\right), r\right)\right), \color{blue}{\left(\frac{\left(\frac{1}{144} \cdot \frac{r}{{s}^{2} \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}\right) - \frac{\frac{1}{24}}{s \cdot \mathsf{PI}\left(\right)}}{s}\right)}\right) \]
  4. Simplified8.9%

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \left(\frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{1}{48} \cdot \frac{{r}^{2}}{s \cdot \mathsf{PI}\left(\right)}\right)}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  6. Simplified8.5%

    \[\leadsto \color{blue}{\frac{\frac{-0.25}{\pi \cdot r} - \frac{\frac{-0.16666666666666666}{\pi} - \frac{\frac{\frac{r \cdot r}{s} \cdot 0.020833333333333332}{\pi} + \frac{r \cdot -0.06944444444444445}{\pi}}{s}}{s}}{-s}} \]
  7. Applied egg-rr8.5%

    \[\leadsto \color{blue}{\left(\frac{\frac{0.25}{\pi}}{r} + \frac{\frac{-0.16666666666666666}{\pi} - \frac{\frac{1}{\pi} \cdot \left(\frac{0.020833333333333332}{\frac{s}{r \cdot r}} + r \cdot -0.06944444444444445\right)}{s}}{s}\right) \cdot \frac{1}{s}} \]
  8. Final simplification8.5%

    \[\leadsto \frac{1}{s} \cdot \left(\frac{\frac{0.25}{\pi}}{r} + \frac{\frac{-0.16666666666666666}{\pi} + \frac{\left(\frac{0.020833333333333332}{\frac{s}{r \cdot r}} + r \cdot -0.06944444444444445\right) \cdot \frac{-1}{\pi}}{s}}{s}\right) \]
  9. Add Preprocessing

Alternative 9: 9.9% accurate, 7.5× speedup?

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

\\
\frac{\frac{\frac{-0.16666666666666666}{\pi} - \frac{\frac{r \cdot \left(\frac{r}{s} \cdot 0.020833333333333332\right)}{\pi} + \frac{r \cdot -0.06944444444444445}{\pi}}{s}}{s} - \frac{-0.25}{r \cdot \pi}}{s}
\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. Add Preprocessing
  3. Taylor expanded in s around inf

    \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(r\right), s\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), s\right), r\right)\right), \color{blue}{\left(\frac{\left(\frac{1}{144} \cdot \frac{r}{{s}^{2} \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}\right) - \frac{\frac{1}{24}}{s \cdot \mathsf{PI}\left(\right)}}{s}\right)}\right) \]
  4. Simplified8.9%

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \left(\frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{1}{48} \cdot \frac{{r}^{2}}{s \cdot \mathsf{PI}\left(\right)}\right)}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  6. Simplified8.5%

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\left(\left(r \cdot \frac{r}{s}\right) \cdot \frac{1}{48}\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \frac{-5}{72}\right), \mathsf{PI.f32}\left(\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    2. associate-*l*N/A

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{*.f32}\left(\left(\frac{r}{s}\right), \frac{1}{48}\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \frac{-5}{72}\right), \mathsf{PI.f32}\left(\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    5. /-lowering-/.f328.5%

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

    \[\leadsto \frac{\frac{-0.25}{\pi \cdot r} - \frac{\frac{-0.16666666666666666}{\pi} - \frac{\frac{\color{blue}{r \cdot \left(\frac{r}{s} \cdot 0.020833333333333332\right)}}{\pi} + \frac{r \cdot -0.06944444444444445}{\pi}}{s}}{s}}{-s} \]
  9. Final simplification8.5%

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

Alternative 10: 9.9% accurate, 8.0× speedup?

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

\\
\frac{\frac{\frac{-0.16666666666666666}{\pi} - \frac{r \cdot \left(\frac{\frac{r}{s} \cdot 0.020833333333333332}{\pi} + \frac{-0.06944444444444445}{\pi}\right)}{s}}{s} - \frac{-0.25}{r \cdot \pi}}{s}
\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. Add Preprocessing
  3. Taylor expanded in s around inf

    \[\leadsto \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(r\right), s\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), s\right), r\right)\right), \color{blue}{\left(\frac{\left(\frac{1}{144} \cdot \frac{r}{{s}^{2} \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}\right) - \frac{\frac{1}{24}}{s \cdot \mathsf{PI}\left(\right)}}{s}\right)}\right) \]
  4. Simplified8.9%

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \left(\frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{1}{48} \cdot \frac{{r}^{2}}{s \cdot \mathsf{PI}\left(\right)}\right)}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  6. Simplified8.5%

    \[\leadsto \color{blue}{\frac{\frac{-0.25}{\pi \cdot r} - \frac{\frac{-0.16666666666666666}{\pi} - \frac{\frac{\frac{r \cdot r}{s} \cdot 0.020833333333333332}{\pi} + \frac{r \cdot -0.06944444444444445}{\pi}}{s}}{s}}{-s}} \]
  7. Taylor expanded in r around 0

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{1}{48} \cdot \frac{r}{s \cdot \mathsf{PI}\left(\right)} - \frac{5}{72} \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    2. sub-negN/A

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{48}, \mathsf{/.f32}\left(r, s\right)\right), \mathsf{PI.f32}\left(\right)\right), \left(\mathsf{neg}\left(\frac{\frac{5}{72} \cdot 1}{\mathsf{PI}\left(\right)}\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{48}, \mathsf{/.f32}\left(r, s\right)\right), \mathsf{PI.f32}\left(\right)\right), \left(\mathsf{neg}\left(\frac{\frac{5}{72}}{\mathsf{PI}\left(\right)}\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    12. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{48}, \mathsf{/.f32}\left(r, s\right)\right), \mathsf{PI.f32}\left(\right)\right), \left(\frac{\mathsf{neg}\left(\frac{5}{72}\right)}{\mathsf{PI}\left(\right)}\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{48}, \mathsf{/.f32}\left(r, s\right)\right), \mathsf{PI.f32}\left(\right)\right), \left(\frac{\frac{-5}{72}}{\mathsf{PI}\left(\right)}\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    14. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{48}, \mathsf{/.f32}\left(r, s\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\frac{-5}{72}, \mathsf{PI}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
    15. PI-lowering-PI.f328.5%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), r\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{48}, \mathsf{/.f32}\left(r, s\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\frac{-5}{72}, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), \mathsf{neg.f32}\left(s\right)\right) \]
  9. Simplified8.5%

    \[\leadsto \frac{\frac{-0.25}{\pi \cdot r} - \frac{\frac{-0.16666666666666666}{\pi} - \frac{\color{blue}{r \cdot \left(\frac{0.020833333333333332 \cdot \frac{r}{s}}{\pi} + \frac{-0.06944444444444445}{\pi}\right)}}{s}}{s}}{-s} \]
  10. Final simplification8.5%

    \[\leadsto \frac{\frac{\frac{-0.16666666666666666}{\pi} - \frac{r \cdot \left(\frac{\frac{r}{s} \cdot 0.020833333333333332}{\pi} + \frac{-0.06944444444444445}{\pi}\right)}{s}}{s} - \frac{-0.25}{r \cdot \pi}}{s} \]
  11. Add Preprocessing

Alternative 11: 9.8% accurate, 8.0× speedup?

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

\\
\frac{\frac{0.25}{r \cdot \pi} + \frac{\frac{-0.16666666666666666}{\pi} - \frac{r \cdot \left(\frac{-0.06944444444444445}{\pi} + 0.021604938271604937 \cdot \frac{r}{s \cdot \pi}\right)}{s}}{s}}{s}
\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. Add Preprocessing
  3. Taylor expanded in s around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{48} \cdot \frac{{r}^{2}}{\mathsf{PI}\left(\right)} + \frac{-1}{1296} \cdot \frac{{r}^{2}}{\mathsf{PI}\left(\right)}}{s} + \left(\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)}\right)}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  4. Simplified8.4%

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{7}{324} \cdot \frac{r}{s \cdot \mathsf{PI}\left(\right)} - \frac{5}{72} \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), s\right)\right), s\right)\right), s\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \left(\frac{7}{324} \cdot \frac{r}{s \cdot \mathsf{PI}\left(\right)} + \left(\mathsf{neg}\left(\frac{5}{72} \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    3. +-lowering-+.f32N/A

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(\mathsf{neg}\left(\frac{5}{72} \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    8. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(\mathsf{neg}\left(\frac{\frac{5}{72} \cdot 1}{\mathsf{PI}\left(\right)}\right)\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(\mathsf{neg}\left(\frac{\frac{5}{72}}{\mathsf{PI}\left(\right)}\right)\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    10. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(\frac{\mathsf{neg}\left(\frac{5}{72}\right)}{\mathsf{PI}\left(\right)}\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(\frac{\frac{-5}{72}}{\mathsf{PI}\left(\right)}\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    12. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{/.f32}\left(\frac{-5}{72}, \mathsf{PI}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
    13. PI-lowering-PI.f328.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{7}{324}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{/.f32}\left(\frac{-5}{72}, \mathsf{PI.f32}\left(\right)\right)\right)\right), s\right)\right), s\right)\right), s\right) \]
  7. Simplified8.4%

    \[\leadsto \frac{\frac{0.25}{r \cdot \pi} + \frac{\frac{-0.16666666666666666}{\pi} - \frac{\color{blue}{r \cdot \left(0.021604938271604937 \cdot \frac{r}{s \cdot \pi} + \frac{-0.06944444444444445}{\pi}\right)}}{s}}{s}}{s} \]
  8. Final simplification8.4%

    \[\leadsto \frac{\frac{0.25}{r \cdot \pi} + \frac{\frac{-0.16666666666666666}{\pi} - \frac{r \cdot \left(\frac{-0.06944444444444445}{\pi} + 0.021604938271604937 \cdot \frac{r}{s \cdot \pi}\right)}{s}}{s}}{s} \]
  9. Add Preprocessing

Alternative 12: 10.0% accurate, 9.2× speedup?

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

\\
\frac{\frac{0.25}{s \cdot \pi} + r \cdot \frac{\frac{-0.16666666666666666}{\pi} - -0.06944444444444445 \cdot \frac{\frac{r}{s}}{\pi}}{s \cdot s}}{r}
\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. Add Preprocessing
  3. Taylor expanded in r around 0

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

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

Alternative 13: 10.0% accurate, 11.0× speedup?

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

\\
\frac{\frac{0.25}{r \cdot \pi} - \frac{-0.06944444444444445 \cdot \frac{\frac{r}{s}}{\pi} + \frac{0.16666666666666666}{\pi}}{s}}{s}
\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. Add Preprocessing
  3. Taylor expanded in s around inf

    \[\leadsto \color{blue}{\frac{\left(\frac{1}{144} \cdot \frac{r}{{s}^{2} \cdot \mathsf{PI}\left(\right)} + \left(\frac{1}{16} \cdot \frac{r}{{s}^{2} \cdot \mathsf{PI}\left(\right)} + \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}\right)\right) - \frac{\frac{1}{6}}{s \cdot \mathsf{PI}\left(\right)}}{s}} \]
  4. Simplified8.4%

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

Alternative 14: 10.0% accurate, 11.0× speedup?

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

\\
\frac{\frac{\frac{0.25}{\pi}}{r} + \frac{\frac{-0.16666666666666666}{\pi} + \frac{\frac{r}{\pi} \cdot 0.06944444444444445}{s}}{s}}{s}
\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. Add Preprocessing
  3. Taylor expanded in s around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{48} \cdot \frac{{r}^{2}}{\mathsf{PI}\left(\right)} + \frac{-1}{1296} \cdot \frac{{r}^{2}}{\mathsf{PI}\left(\right)}}{s} + \left(\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)}\right)}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  4. Simplified8.4%

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

    \[\leadsto \color{blue}{\frac{\left(\frac{5}{72} \cdot \frac{r}{{s}^{2} \cdot \mathsf{PI}\left(\right)} + \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}\right) - \frac{\frac{1}{6}}{s \cdot \mathsf{PI}\left(\right)}}{s}} \]
  6. Simplified8.4%

    \[\leadsto \color{blue}{\frac{\frac{\frac{0.25}{\pi}}{r} + \frac{\frac{0.06944444444444445 \cdot \frac{r}{\pi}}{s} + \frac{-0.16666666666666666}{\pi}}{s}}{s}} \]
  7. Final simplification8.4%

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

Alternative 15: 10.0% accurate, 11.0× speedup?

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

\\
\frac{0.25 + r \cdot \left(\frac{r}{s \cdot s} \cdot 0.06944444444444445 + \frac{-0.16666666666666666}{s}\right)}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \left(\frac{5}{72} \cdot \frac{r}{{s}^{2}} - \frac{1}{6} \cdot \frac{1}{s}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), r\right)\right) \]
    3. sub-negN/A

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{5}{72}, \mathsf{/.f32}\left(r, \left({s}^{2}\right)\right)\right), \left(\mathsf{neg}\left(\frac{1}{6} \cdot \frac{1}{s}\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    7. unpow2N/A

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{5}{72}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, s\right)\right)\right), \left(\mathsf{neg}\left(\frac{\frac{1}{6} \cdot 1}{s}\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{5}{72}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, s\right)\right)\right), \left(\mathsf{neg}\left(\frac{\frac{1}{6}}{s}\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    11. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{5}{72}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, s\right)\right)\right), \left(\frac{\mathsf{neg}\left(\frac{1}{6}\right)}{s}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\frac{5}{72}, \mathsf{/.f32}\left(r, \mathsf{*.f32}\left(s, s\right)\right)\right), \left(\frac{\frac{-1}{6}}{s}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right), r\right)\right) \]
    13. /-lowering-/.f328.3%

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

    \[\leadsto \frac{\color{blue}{0.25 + r \cdot \left(0.06944444444444445 \cdot \frac{r}{s \cdot s} + \frac{-0.16666666666666666}{s}\right)}}{\left(s \cdot \pi\right) \cdot r} \]
  11. Final simplification8.3%

    \[\leadsto \frac{0.25 + r \cdot \left(\frac{r}{s \cdot s} \cdot 0.06944444444444445 + \frac{-0.16666666666666666}{s}\right)}{r \cdot \left(s \cdot \pi\right)} \]
  12. Add Preprocessing

Alternative 16: 9.0% accurate, 15.4× speedup?

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

\\
\frac{\frac{\frac{-0.16666666666666666}{\pi} + \frac{0.25 \cdot \frac{s}{r}}{\pi}}{s}}{s}
\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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{0.25}{\pi}}{r} + \frac{-0.16666666666666666}{s \cdot \pi}}{s}} \]
  8. Taylor expanded in s around 0

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{4}, \mathsf{/.f32}\left(s, r\right)\right), \mathsf{PI.f32}\left(\right)\right), \left(\mathsf{neg}\left(\frac{\frac{1}{6}}{\mathsf{PI}\left(\right)}\right)\right)\right), s\right), s\right) \]
    12. distribute-neg-fracN/A

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\frac{0.25 \cdot \frac{s}{r}}{\pi} + \frac{-0.16666666666666666}{\pi}}{s}}}{s} \]
  11. Final simplification7.7%

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

Alternative 17: 9.0% accurate, 15.4× speedup?

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

\\
\frac{1}{\frac{s}{\frac{\frac{0.25}{\pi}}{r} + \frac{-0.16666666666666666}{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. Add Preprocessing
  3. Taylor expanded in r around inf

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{-1 \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)} + \frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{s \cdot \mathsf{PI}\left(\right)}}{r}} \]
  4. Simplified99.8%

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{0.25}{\pi}}{r} + \frac{-0.16666666666666666}{s \cdot \pi}}{s}} \]
  8. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(s, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{PI.f32}\left(\right)\right), r\right), \mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(s, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right)\right) \]
  9. Applied egg-rr7.7%

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

Alternative 18: 9.0% accurate, 17.8× speedup?

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

\\
\frac{\frac{0.25}{r \cdot \pi} + \frac{-0.16666666666666666}{s \cdot \pi}}{s}
\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. Add Preprocessing
  3. Taylor expanded in s around inf

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \left(\mathsf{neg}\left(\frac{\frac{1}{6}}{s \cdot \mathsf{PI}\left(\right)}\right)\right)\right), s\right) \]
    11. distribute-neg-fracN/A

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

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

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

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

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

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

Alternative 19: 9.0% accurate, 25.7× speedup?

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

\\
\frac{-0.25}{r} \cdot \frac{\frac{-1}{\pi}}{s}
\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. Add Preprocessing
  3. Taylor expanded in r around 0

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

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \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}{4}, \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}{4}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
    4. PI-lowering-PI.f327.6%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{0.25}{\color{blue}{\left(\pi \cdot r\right) \cdot s}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

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

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

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

      \[\leadsto \frac{\frac{-1}{4}}{\mathsf{neg}\left(s \cdot \left(r \cdot \mathsf{PI}\left(\right)\right)\right)} \]
    5. distribute-lft-neg-inN/A

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

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

      \[\leadsto \frac{\frac{\frac{\frac{-1}{4}}{r}}{\mathsf{PI}\left(\right)}}{\mathsf{neg}\left(\color{blue}{s}\right)} \]
    8. div-invN/A

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{-0.25}{r} \cdot \frac{\frac{-1}{\pi}}{s} \]
  11. Add Preprocessing

Alternative 20: 9.0% accurate, 25.7× speedup?

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

\\
\frac{\frac{-0.25}{r}}{\pi} \cdot \frac{-1}{s}
\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. Add Preprocessing
  3. Taylor expanded in r around 0

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

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \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}{4}, \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}{4}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
    4. PI-lowering-PI.f327.6%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{0.25}{\color{blue}{\left(\pi \cdot r\right) \cdot s}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

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

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

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

      \[\leadsto \frac{\frac{-1}{4}}{\mathsf{neg}\left(s \cdot \left(r \cdot \mathsf{PI}\left(\right)\right)\right)} \]
    5. distribute-lft-neg-inN/A

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

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

      \[\leadsto \frac{\frac{\frac{\frac{-1}{4}}{r}}{\mathsf{PI}\left(\right)}}{\mathsf{neg}\left(\color{blue}{s}\right)} \]
    8. div-invN/A

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

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

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

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

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

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

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

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

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

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

Alternative 21: 9.0% accurate, 25.7× speedup?

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

\\
\frac{-0.25}{r \cdot \pi} \cdot \frac{-1}{s}
\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. Add Preprocessing
  3. Taylor expanded in r around 0

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

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \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}{4}, \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}{4}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
    4. PI-lowering-PI.f327.6%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{0.25}{\color{blue}{\left(r \cdot s\right) \cdot \pi}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

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

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

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

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

      \[\leadsto \frac{\frac{-1}{4}}{\mathsf{neg}\left(s \cdot \left(\mathsf{PI}\left(\right) \cdot r\right)\right)} \]
    6. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(\frac{-1}{4}, \mathsf{*.f32}\left(r, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(s\right)\right)}\right)}\right)\right) \]
    16. remove-double-negN/A

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

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

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

Alternative 22: 9.0% 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.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. Add Preprocessing
  3. Taylor expanded in r around 0

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

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \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}{4}, \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}{4}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
    4. PI-lowering-PI.f327.6%

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

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

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

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

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

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

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

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

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

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

Alternative 23: 9.0% 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.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. Add Preprocessing
  3. Taylor expanded in r around 0

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

      \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \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}{4}, \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}{4}, \mathsf{*.f32}\left(r, \mathsf{*.f32}\left(s, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
    4. PI-lowering-PI.f327.6%

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

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

Reproduce

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