Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.6% → 99.6%
Time: 6.0s
Alternatives: 16
Speedup: 1.1×

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}

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 16 alternatives:

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

Initial Program: 99.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{-1 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    5. mul-1-negN/A

      \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{r}{s}\right)}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    6. distribute-frac-negN/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(r\right)}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    7. lift-neg.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    8. lift-/.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    9. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    10. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    11. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    12. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    13. lift-PI.f3299.6

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

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

Alternative 2: 99.6% accurate, 1.1× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{-1 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    5. mul-1-negN/A

      \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{r}{s}\right)}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    6. distribute-frac-negN/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(r\right)}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    7. lift-neg.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    8. lift-/.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    9. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    10. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    11. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    12. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    13. lift-PI.f3299.6

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

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

      \[\leadsto \color{blue}{\frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}} \]
    2. lift-/.f32N/A

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

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\color{blue}{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    4. lift-exp.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot \color{blue}{e^{\frac{-r}{3 \cdot s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    5. lift-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{\color{blue}{3 \cdot s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    6. lift-/.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\color{blue}{\frac{-r}{3 \cdot s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    7. lift-neg.f32N/A

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

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

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

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

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

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

Alternative 3: 99.6% accurate, 1.1× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{-1 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    5. mul-1-negN/A

      \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{r}{s}\right)}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    6. distribute-frac-negN/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(r\right)}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    7. lift-neg.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    8. lift-/.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    9. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    10. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    11. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    12. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    13. lift-PI.f3299.6

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot s\right)} \cdot 6\right) \cdot r} \]
    10. lift-PI.f3299.5

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(\pi \cdot s\right) \cdot 6\right) \cdot r}} \]
    2. lift-/.f32N/A

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

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\color{blue}{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}}{\left(\left(\pi \cdot s\right) \cdot 6\right) \cdot r} \]
    4. lift-exp.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot \color{blue}{e^{\frac{-r}{3 \cdot s}}}}{\left(\left(\pi \cdot s\right) \cdot 6\right) \cdot r} \]
    5. lift-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{\color{blue}{3 \cdot s}}}}{\left(\left(\pi \cdot s\right) \cdot 6\right) \cdot r} \]
    6. lift-/.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\color{blue}{\frac{-r}{3 \cdot s}}}}{\left(\left(\pi \cdot s\right) \cdot 6\right) \cdot r} \]
    7. lift-neg.f32N/A

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\pi \cdot s\right) \cdot r\\
\frac{e^{\frac{-r}{s}}}{t\_0} \cdot 0.125 + \frac{0.125 \cdot e^{\frac{r}{s} \cdot -0.3333333333333333}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

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

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

      \[\leadsto \frac{e^{-1 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    5. mul-1-negN/A

      \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{r}{s}\right)}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    6. distribute-frac-negN/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(r\right)}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    7. lift-neg.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    8. lift-/.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    9. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    10. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(s \cdot \mathsf{PI}\left(\right)\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    11. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    12. lower-*.f32N/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    13. lift-PI.f3299.6

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot 0.125 + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot 0.125} + \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 0

    \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \color{blue}{\frac{1}{8} \cdot \frac{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{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{1}{8} \cdot e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\color{blue}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)}} \]
    2. lower-/.f32N/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{1}{8} \cdot e^{\frac{r}{s} \cdot \frac{-1}{3}}}{r \cdot \left(\pi \cdot s\right)} \]
    11. *-commutativeN/A

      \[\leadsto \frac{e^{\frac{-r}{s}}}{\left(\pi \cdot s\right) \cdot r} \cdot \frac{1}{8} + \frac{\frac{1}{8} \cdot e^{\frac{r}{s} \cdot \frac{-1}{3}}}{\left(\pi \cdot s\right) \cdot \color{blue}{r}} \]
    12. lift-*.f3299.5

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

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

Alternative 5: 99.5% accurate, 1.4× speedup?

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{e^{\frac{-r}{s}}}{\pi \cdot r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    2. lift-+.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{e^{\frac{-r}{s}}}{\pi \cdot r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    3. lift-/.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{e^{\frac{-r}{s}}}{\pi \cdot r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    4. lift-exp.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{e^{\frac{-r}{s}}}{\pi \cdot r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    5. lift-/.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{e^{\frac{-r}{s}}}{\pi \cdot r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    6. lift-neg.f32N/A

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

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

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

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{\frac{e^{\frac{\mathsf{neg}\left(r\right)}{s}}}{\mathsf{PI}\left(\right)}}{r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    10. distribute-frac-negN/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{\frac{e^{\mathsf{neg}\left(\frac{r}{s}\right)}}{\mathsf{PI}\left(\right)}}{r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    11. mul-1-negN/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{\frac{e^{-1 \cdot \frac{r}{s}}}{\mathsf{PI}\left(\right)}}{r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
    12. lift-/.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \left(\frac{\frac{e^{-1 \cdot \frac{r}{s}}}{\mathsf{PI}\left(\right)}}{r} + \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi \cdot r}\right)}{s} \]
  6. Applied rewrites99.5%

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

Alternative 6: 99.5% accurate, 1.4× speedup?

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

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

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

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

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

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

    \[\leadsto \frac{0.125 \cdot \frac{e^{\frac{-r}{s}} + e^{\frac{r}{s} \cdot -0.3333333333333333}}{\pi}}{\color{blue}{s \cdot r}} \]
  6. Add Preprocessing

Alternative 7: 99.5% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\frac{1}{4}}{\mathsf{PI}\left(\right) \cdot r}}{s} \]
    4. lift-PI.f329.2

      \[\leadsto \frac{\frac{0.25}{\pi \cdot r}}{s} \]
  7. Applied rewrites9.2%

    \[\leadsto \frac{\frac{0.25}{\pi \cdot r}}{s} \]
  8. Taylor expanded in s around 0

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

    \[\leadsto \frac{0.125}{s} \cdot \color{blue}{\frac{e^{\frac{r}{s} \cdot -0.3333333333333333} + e^{\frac{-r}{s}}}{\pi \cdot r}} \]
  10. Add Preprocessing

Alternative 8: 99.5% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{-1 \cdot \frac{r}{s}} + e^{\frac{-1}{3} \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{1}{8} \]
  8. Applied rewrites99.5%

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

Alternative 9: 46.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\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} \leq 9.999999682655225 \cdot 10^{-21}:\\ \;\;\;\;\frac{\frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right)}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.125 \cdot \frac{\mathsf{fma}\left(-1.3333333333333333, \frac{r}{s}, \frac{r \cdot r}{s \cdot s} \cdot 0.5555555555555556\right) + 2}{\pi}}{s \cdot r}\\ \end{array} \end{array} \]
(FPCore (s r)
 :precision binary32
 (if (<=
      (+
       (/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
       (/ (* 0.75 (exp (/ (- r) (* 3.0 s)))) (* (* (* 6.0 PI) s) r)))
      9.999999682655225e-21)
   (/ (/ 0.25 (log (pow (exp PI) r))) s)
   (/
    (*
     0.125
     (/
      (+
       (fma
        -1.3333333333333333
        (/ r s)
        (* (/ (* r r) (* s s)) 0.5555555555555556))
       2.0)
      PI))
    (* s r))))
float code(float s, float r) {
	float tmp;
	if ((((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))) <= 9.999999682655225e-21f) {
		tmp = (0.25f / logf(powf(expf(((float) M_PI)), r))) / s;
	} else {
		tmp = (0.125f * ((fmaf(-1.3333333333333333f, (r / s), (((r * r) / (s * s)) * 0.5555555555555556f)) + 2.0f) / ((float) M_PI))) / (s * r);
	}
	return tmp;
}
function code(s, r)
	tmp = Float32(0.0)
	if (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))) <= Float32(9.999999682655225e-21))
		tmp = Float32(Float32(Float32(0.25) / log((exp(Float32(pi)) ^ r))) / s);
	else
		tmp = Float32(Float32(Float32(0.125) * Float32(Float32(fma(Float32(-1.3333333333333333), Float32(r / s), Float32(Float32(Float32(r * r) / Float32(s * s)) * Float32(0.5555555555555556))) + Float32(2.0)) / Float32(pi))) / Float32(s * r));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\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} \leq 9.999999682655225 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right)}}{s}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.125 \cdot \frac{\mathsf{fma}\left(-1.3333333333333333, \frac{r}{s}, \frac{r \cdot r}{s \cdot s} \cdot 0.5555555555555556\right) + 2}{\pi}}{s \cdot r}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r))) < 9.99999968e-21

    1. Initial program 99.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{1}{4}}{\mathsf{PI}\left(\right) \cdot r}}{s} \]
      4. lift-PI.f329.2

        \[\leadsto \frac{\frac{0.25}{\pi \cdot r}}{s} \]
    7. Applied rewrites9.2%

      \[\leadsto \frac{\frac{0.25}{\pi \cdot r}}{s} \]
    8. Step-by-step derivation
      1. lift-PI.f32N/A

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

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

        \[\leadsto \frac{\frac{\frac{1}{4}}{r \cdot \mathsf{PI}\left(\right)}}{s} \]
      4. add-log-expN/A

        \[\leadsto \frac{\frac{\frac{1}{4}}{r \cdot \log \left(e^{\mathsf{PI}\left(\right)}\right)}}{s} \]
      5. log-pow-revN/A

        \[\leadsto \frac{\frac{\frac{1}{4}}{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{r}\right)}}{s} \]
      6. lower-log.f32N/A

        \[\leadsto \frac{\frac{\frac{1}{4}}{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{r}\right)}}{s} \]
      7. lower-pow.f32N/A

        \[\leadsto \frac{\frac{\frac{1}{4}}{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{r}\right)}}{s} \]
      8. lower-exp.f32N/A

        \[\leadsto \frac{\frac{\frac{1}{4}}{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{r}\right)}}{s} \]
      9. lift-PI.f3243.5

        \[\leadsto \frac{\frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right)}}{s} \]
    9. Applied rewrites43.5%

      \[\leadsto \frac{\frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right)}}{s} \]

    if 9.99999968e-21 < (+.f32 (/.f32 (*.f32 #s(literal 1/4 binary32) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) s) r)) (/.f32 (*.f32 #s(literal 3/4 binary32) (exp.f32 (/.f32 (neg.f32 r) (*.f32 #s(literal 3 binary32) s)))) (*.f32 (*.f32 (*.f32 #s(literal 6 binary32) (PI.f32)) s) r)))

    1. Initial program 99.6%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{2 + \left(-1 \cdot \frac{r}{s} + \left(\frac{-1}{3} \cdot \frac{r}{s} + \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}} + \frac{1}{2} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right)}{\pi}}{s \cdot r} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{8} \cdot \frac{\left(-1 \cdot \frac{r}{s} + \left(\frac{-1}{3} \cdot \frac{r}{s} + \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}} + \frac{1}{2} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right) + 2}{\pi}}{s \cdot r} \]
      2. lower-+.f32N/A

        \[\leadsto \frac{\frac{1}{8} \cdot \frac{\left(-1 \cdot \frac{r}{s} + \left(\frac{-1}{3} \cdot \frac{r}{s} + \left(\frac{1}{18} \cdot \frac{{r}^{2}}{{s}^{2}} + \frac{1}{2} \cdot \frac{{r}^{2}}{{s}^{2}}\right)\right)\right) + 2}{\pi}}{s \cdot r} \]
    8. Applied rewrites10.2%

      \[\leadsto \frac{0.125 \cdot \frac{\mathsf{fma}\left(-1.3333333333333333, \frac{r}{s}, \frac{r \cdot r}{s \cdot s} \cdot 0.5555555555555556\right) + 2}{\pi}}{s \cdot r} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 10.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \frac{0.125 \cdot \frac{\mathsf{fma}\left(0.5555555555555556 \cdot \frac{r}{s \cdot s} - \frac{1.3333333333333333}{s}, r, 2\right)}{\pi}}{s \cdot r} \end{array} \]
(FPCore (s r)
 :precision binary32
 (/
  (*
   0.125
   (/
    (fma
     (- (* 0.5555555555555556 (/ r (* s s))) (/ 1.3333333333333333 s))
     r
     2.0)
    PI))
  (* s r)))
float code(float s, float r) {
	return (0.125f * (fmaf(((0.5555555555555556f * (r / (s * s))) - (1.3333333333333333f / s)), r, 2.0f) / ((float) M_PI))) / (s * r);
}
function code(s, r)
	return Float32(Float32(Float32(0.125) * Float32(fma(Float32(Float32(Float32(0.5555555555555556) * Float32(r / Float32(s * s))) - Float32(Float32(1.3333333333333333) / s)), r, Float32(2.0)) / Float32(pi))) / Float32(s * r))
end
\begin{array}{l}

\\
\frac{0.125 \cdot \frac{\mathsf{fma}\left(0.5555555555555556 \cdot \frac{r}{s \cdot s} - \frac{1.3333333333333333}{s}, r, 2\right)}{\pi}}{s \cdot r}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

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

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

    \[\leadsto \frac{\frac{1}{8} \cdot \frac{2 + r \cdot \left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}\right)}{\pi}}{s \cdot r} \]
  7. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{r \cdot \left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}\right) + 2}{\pi}}{s \cdot r} \]
    2. *-commutativeN/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}\right) \cdot r + 2}{\pi}}{s \cdot r} \]
    3. lower-fma.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    4. lower--.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    5. lower-*.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    6. lower-/.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{{s}^{2}} - \frac{4}{3} \cdot \frac{1}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    7. pow2N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{s \cdot s} - \frac{4}{3} \cdot \frac{1}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    8. lift-*.f32N/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{s \cdot s} - \frac{4}{3} \cdot \frac{1}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    9. mult-flip-revN/A

      \[\leadsto \frac{\frac{1}{8} \cdot \frac{\mathsf{fma}\left(\frac{5}{9} \cdot \frac{r}{s \cdot s} - \frac{\frac{4}{3}}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
    10. lower-/.f3210.3

      \[\leadsto \frac{0.125 \cdot \frac{\mathsf{fma}\left(0.5555555555555556 \cdot \frac{r}{s \cdot s} - \frac{1.3333333333333333}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
  8. Applied rewrites10.3%

    \[\leadsto \frac{0.125 \cdot \frac{\mathsf{fma}\left(0.5555555555555556 \cdot \frac{r}{s \cdot s} - \frac{1.3333333333333333}{s}, r, 2\right)}{\pi}}{s \cdot r} \]
  9. Add Preprocessing

Alternative 11: 10.3% accurate, 1.9× speedup?

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

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

    \[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  2. 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}} \]
  3. Step-by-step derivation
    1. lower-/.f32N/A

      \[\leadsto \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)}}{\color{blue}{r}} \]
  4. Applied rewrites8.9%

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

    \[\leadsto -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{5}{72} \cdot \frac{r}{s \cdot \mathsf{PI}\left(\right)} - \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. Step-by-step derivation
    1. mul-1-negN/A

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

      \[\leadsto -\frac{-1 \cdot \frac{\frac{5}{72} \cdot \frac{r}{s \cdot \mathsf{PI}\left(\right)} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s} \]
    3. lower-/.f32N/A

      \[\leadsto -\frac{-1 \cdot \frac{\frac{5}{72} \cdot \frac{r}{s \cdot \mathsf{PI}\left(\right)} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s} \]
  7. Applied rewrites10.3%

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

Alternative 12: 9.4% accurate, 3.3× speedup?

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

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

    \[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  2. 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}} \]
  3. Step-by-step derivation
    1. lower-/.f32N/A

      \[\leadsto \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)}}{\color{blue}{s}} \]
    2. lower--.f32N/A

      \[\leadsto \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} \]
    3. mult-flip-revN/A

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

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

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

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

      \[\leadsto \frac{\frac{\frac{1}{4}}{\pi \cdot r} - \frac{1}{6} \cdot \frac{1}{s \cdot \mathsf{PI}\left(\right)}}{s} \]
    8. mult-flip-revN/A

      \[\leadsto \frac{\frac{\frac{1}{4}}{\pi \cdot r} - \frac{\frac{1}{6}}{s \cdot \mathsf{PI}\left(\right)}}{s} \]
    9. lower-/.f32N/A

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

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

      \[\leadsto \frac{\frac{\frac{1}{4}}{\pi \cdot r} - \frac{\frac{1}{6}}{\mathsf{PI}\left(\right) \cdot s}}{s} \]
    12. lift-PI.f329.4

      \[\leadsto \frac{\frac{0.25}{\pi \cdot r} - \frac{0.16666666666666666}{\pi \cdot s}}{s} \]
  4. Applied rewrites9.4%

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

Alternative 13: 9.2% accurate, 6.0× speedup?

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

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

    \[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  2. Taylor expanded in s around inf

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{4}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \]
    6. lift-PI.f329.2

      \[\leadsto \frac{0.25}{\left(\pi \cdot s\right) \cdot r} \]
  4. Applied rewrites9.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\frac{1}{4}}{r}}{\mathsf{PI}\left(\right) \cdot \color{blue}{s}} \]
    12. lift-PI.f329.2

      \[\leadsto \frac{\frac{0.25}{r}}{\pi \cdot s} \]
  6. Applied rewrites9.2%

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

Alternative 14: 9.2% accurate, 6.0× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\frac{1}{4}}{\mathsf{PI}\left(\right)}}{s \cdot r} \]
    2. lift-PI.f329.2

      \[\leadsto \frac{\frac{0.25}{\pi}}{s \cdot r} \]
  8. Applied rewrites9.2%

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

Alternative 15: 9.2% accurate, 6.4× speedup?

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

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

    \[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  2. Taylor expanded in s around inf

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{4}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \]
    6. lift-PI.f329.2

      \[\leadsto \frac{0.25}{\left(\pi \cdot s\right) \cdot r} \]
  4. Applied rewrites9.2%

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

Alternative 16: 9.2% accurate, 6.4× speedup?

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

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

    \[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  2. Taylor expanded in s around inf

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{4}}{\left(\mathsf{PI}\left(\right) \cdot s\right) \cdot r} \]
    6. lift-PI.f329.2

      \[\leadsto \frac{0.25}{\left(\pi \cdot s\right) \cdot r} \]
  4. Applied rewrites9.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{4}}{\left(s \cdot r\right) \cdot \mathsf{PI}\left(\right)} \]
    10. lift-PI.f329.2

      \[\leadsto \frac{0.25}{\left(s \cdot r\right) \cdot \pi} \]
  6. Applied rewrites9.2%

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

Reproduce

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