Disney BSSRDF, PDF of scattering profile

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

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 1.0× speedup?

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

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

    \[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  2. Step-by-step derivation
    1. times-frac99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{0.125}{e^{\frac{r}{s}}}}{s \cdot \left(r \cdot \pi\right)} + 0.75 \cdot \frac{e^{\color{blue}{-0.3333333333333333 \cdot \frac{r}{s}}}}{r \cdot \left(6 \cdot \left(\pi \cdot s\right)\right)} \]
  12. Step-by-step derivation
    1. metadata-eval99.3%

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

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

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

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

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

      \[\leadsto \frac{\frac{0.125}{e^{\frac{r}{s}}}}{s \cdot \left(r \cdot \pi\right)} + 0.75 \cdot \frac{e^{\color{blue}{\frac{r}{-s \cdot 3}}}}{r \cdot \left(6 \cdot \left(\pi \cdot s\right)\right)} \]
    7. distribute-rgt-neg-in99.3%

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

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

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

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

Alternative 2: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{\frac{\color{blue}{\frac{r \cdot 1}{-3}}}{s}}}{r}\right) \]
    5. *-rgt-identity99.3%

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

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

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

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

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\color{blue}{\left(r \cdot \frac{1}{e^{\frac{r}{-s}}}\right)}}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    4. add-sqr-sqrt-0.0%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot \frac{1}{e^{\frac{r}{\color{blue}{\sqrt{-s} \cdot \sqrt{-s}}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    5. sqrt-unprod7.4%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot \frac{1}{e^{\frac{r}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    6. sqr-neg7.4%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot \frac{1}{e^{\frac{r}{\sqrt{\color{blue}{s \cdot s}}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    7. sqrt-unprod7.4%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot \frac{1}{e^{\frac{r}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    8. add-sqr-sqrt7.4%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot \frac{1}{e^{\frac{r}{\color{blue}{s}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    9. rec-exp7.4%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot \color{blue}{e^{-\frac{r}{s}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    10. distribute-frac-neg27.4%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot e^{\color{blue}{\frac{r}{-s}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    11. add-sqr-sqrt-0.0%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot e^{\frac{r}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    13. sqr-neg99.3%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left({\left(r \cdot e^{\frac{r}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}}\right)}^{-1} + \frac{e^{\frac{r}{s \cdot -3}}}{r}\right) \]
    15. add-sqr-sqrt99.3%

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

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

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

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

Alternative 3: 99.5% accurate, 1.1× speedup?

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

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

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

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

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \color{blue}{\frac{e^{-1 \cdot \frac{r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}}{r}} \]
  5. Step-by-step derivation
    1. +-commutative99.3%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{\color{blue}{e^{-0.3333333333333333 \cdot \frac{r}{s}} + e^{-1 \cdot \frac{r}{s}}}}{r} \]
    2. associate-*r/99.3%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{e^{\color{blue}{\frac{-0.3333333333333333 \cdot r}{s}}} + e^{-1 \cdot \frac{r}{s}}}{r} \]
    3. *-commutative99.3%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{e^{\frac{r \cdot \color{blue}{\frac{1}{-3}}}{s}} + e^{-1 \cdot \frac{r}{s}}}{r} \]
    5. associate-/l*99.3%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{e^{\frac{\color{blue}{\frac{r \cdot 1}{-3}}}{s}} + e^{-1 \cdot \frac{r}{s}}}{r} \]
    6. *-rgt-identity99.3%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{e^{\frac{\frac{\color{blue}{r}}{-3}}{s}} + e^{-1 \cdot \frac{r}{s}}}{r} \]
    7. associate-/l/99.3%

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{e^{\frac{r}{s \cdot -3}} + e^{\color{blue}{-\frac{r}{s}}}}{r} \]
    9. distribute-neg-frac299.3%

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

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

Alternative 4: 43.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.25 \cdot 1}{r \cdot \left(s \cdot \pi\right)}} \]
    2. metadata-eval9.1%

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

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

      \[\leadsto \frac{0.25}{\color{blue}{s \cdot \left(\pi \cdot r\right)}} \]
    5. *-commutative9.1%

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

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

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

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

Alternative 5: 15.9% accurate, 1.8× speedup?

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

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

    \[\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 99.3%

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

      \[\leadsto \color{blue}{\frac{0.125 \cdot e^{-1 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \pi\right)}} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    2. neg-mul-199.3%

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

      \[\leadsto \frac{0.125 \cdot \color{blue}{\frac{1}{e^{\frac{r}{s}}}}}{r \cdot \left(s \cdot \pi\right)} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    4. associate-*r/99.3%

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

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

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

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

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

Alternative 6: 10.5% accurate, 1.9× speedup?

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

\\
\frac{0.125}{s \cdot \pi} \cdot \frac{2 + r \cdot \left(0.5555555555555556 \cdot \frac{r}{{s}^{2}} + 1.3333333333333333 \cdot \frac{-1}{s}\right)}{r}
\end{array}
Derivation
  1. Initial program 99.3%

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

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

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \color{blue}{\frac{2 + r \cdot \left(0.5555555555555556 \cdot \frac{r}{{s}^{2}} - 1.3333333333333333 \cdot \frac{1}{s}\right)}{r}} \]
  5. Final simplification9.8%

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \frac{2 + r \cdot \left(0.5555555555555556 \cdot \frac{r}{{s}^{2}} + 1.3333333333333333 \cdot \frac{-1}{s}\right)}{r} \]
  6. Add Preprocessing

Alternative 7: 10.5% accurate, 12.2× speedup?

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

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

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

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

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

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \color{blue}{\left(2 \cdot \frac{1}{r} + -1 \cdot \frac{1.3333333333333333 + -1 \cdot \frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}}{s}\right)} \]
    2. mul-1-neg9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(2 \cdot \frac{1}{r} + \color{blue}{\left(-\frac{1.3333333333333333 + -1 \cdot \frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}}{s}\right)}\right) \]
    3. unsub-neg9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \color{blue}{\left(2 \cdot \frac{1}{r} - \frac{1.3333333333333333 + -1 \cdot \frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}}{s}\right)} \]
    4. associate-*r/9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\color{blue}{\frac{2 \cdot 1}{r}} - \frac{1.3333333333333333 + -1 \cdot \frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}}{s}\right) \]
    5. metadata-eval9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{\color{blue}{2}}{r} - \frac{1.3333333333333333 + -1 \cdot \frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}}{s}\right) \]
    6. mul-1-neg9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{2}{r} - \frac{1.3333333333333333 + \color{blue}{\left(-\frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}\right)}}{s}\right) \]
    7. unsub-neg9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{2}{r} - \frac{\color{blue}{1.3333333333333333 - \frac{0.05555555555555555 \cdot r + 0.5 \cdot r}{s}}}{s}\right) \]
    8. distribute-rgt-out9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{2}{r} - \frac{1.3333333333333333 - \frac{\color{blue}{r \cdot \left(0.05555555555555555 + 0.5\right)}}{s}}{s}\right) \]
    9. metadata-eval9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{2}{r} - \frac{1.3333333333333333 - \frac{r \cdot \color{blue}{0.5555555555555556}}{s}}{s}\right) \]
    10. associate-/l*9.8%

      \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{2}{r} - \frac{1.3333333333333333 - \color{blue}{r \cdot \frac{0.5555555555555556}{s}}}{s}\right) \]
  6. Simplified9.8%

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \color{blue}{\left(\frac{2}{r} - \frac{1.3333333333333333 - r \cdot \frac{0.5555555555555556}{s}}{s}\right)} \]
  7. Final simplification9.8%

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{2}{r} + \frac{r \cdot \frac{0.5555555555555556}{s} - 1.3333333333333333}{s}\right) \]
  8. Add Preprocessing

Alternative 8: 9.3% accurate, 21.0× speedup?

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

\\
\frac{1}{\frac{r}{\frac{0.125}{s \cdot \pi} \cdot 2}}
\end{array}
Derivation
  1. Initial program 99.3%

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

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

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \color{blue}{\frac{2}{r}} \]
  5. Step-by-step derivation
    1. associate-*r/9.1%

      \[\leadsto \color{blue}{\frac{\frac{0.125}{s \cdot \pi} \cdot 2}{r}} \]
    2. clear-num9.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{r}{\frac{0.125}{s \cdot \pi} \cdot 2}}} \]
  6. Applied egg-rr9.1%

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

Alternative 9: 9.3% 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.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.25 \cdot 1}{r \cdot \left(s \cdot \pi\right)}} \]
    2. metadata-eval9.1%

      \[\leadsto \frac{\color{blue}{0.25}}{r \cdot \left(s \cdot \pi\right)} \]
    3. associate-/r*9.1%

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

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

Alternative 10: 9.3% 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.3%

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

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

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

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

Reproduce

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