Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.5% → 99.5%
Time: 4.8s
Alternatives: 12
Speedup: N/A×

Specification

?
\[\left(0 \leq s \land s \leq 256\right) \land \left(10^{-6} < r \land r < 1000000\right)\]
\[\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} \]
(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
\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}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

\[\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} \]
(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
\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}

Alternative 1: 99.5% accurate, 0.8× speedup?

\[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75}{\left(\sinh \left(\frac{0.3333333333333333}{s} \cdot r\right) + \cosh \left(\frac{r}{s} \cdot 0.3333333333333333\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)} \]
(FPCore (s r)
 :precision binary32
 (+
  (/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
  (/
   0.75
   (*
    (+
     (sinh (* (/ 0.3333333333333333 s) r))
     (cosh (* (/ r s) 0.3333333333333333)))
    (* (* (* 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 / ((sinhf(((0.3333333333333333f / s) * r)) + coshf(((r / s) * 0.3333333333333333f))) * (((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(0.75) / Float32(Float32(sinh(Float32(Float32(Float32(0.3333333333333333) / s) * r)) + cosh(Float32(Float32(r / s) * Float32(0.3333333333333333)))) * 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) / ((sinh(((single(0.3333333333333333) / s) * r)) + cosh(((r / s) * single(0.3333333333333333)))) * (((single(6.0) * single(pi)) * s) * r)));
end
\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75}{\left(\sinh \left(\frac{0.3333333333333333}{s} \cdot r\right) + \cosh \left(\frac{r}{s} \cdot 0.3333333333333333\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)}
Derivation
  1. Initial program 99.5%

    \[\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. lift-/.f32N/A

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \color{blue}{\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{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\color{blue}{\frac{3}{4} \cdot e^{\frac{-r}{3 \cdot s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    3. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\frac{3}{4}}{\left(\sinh \left(r \cdot \frac{\frac{1}{3}}{s}\right) + \cosh \left(\mathsf{neg}\left(r \cdot \color{blue}{\frac{\frac{1}{3}}{s}}\right)\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)} \]
    7. metadata-evalN/A

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

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

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\frac{3}{4}}{\left(\sinh \left(r \cdot \frac{\frac{1}{3}}{s}\right) + \cosh \left(\mathsf{neg}\left(r \cdot \frac{1}{\color{blue}{3 \cdot s}}\right)\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)} \]
    10. mult-flipN/A

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\frac{3}{4}}{\left(\sinh \left(r \cdot \frac{\frac{1}{3}}{s}\right) + \cosh \left(\mathsf{neg}\left(\color{blue}{\frac{r}{3 \cdot s}}\right)\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)} \]
    11. distribute-neg-frac2N/A

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

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

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\frac{3}{4}}{\left(\sinh \left(r \cdot \frac{\frac{1}{3}}{s}\right) + \cosh \left(\frac{r}{\mathsf{neg}\left(\color{blue}{s \cdot 3}\right)}\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)} \]
    14. distribute-rgt-neg-inN/A

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\frac{3}{4}}{\left(\sinh \left(r \cdot \frac{\frac{1}{3}}{s}\right) + \cosh \left(\frac{r}{\color{blue}{s \cdot \left(\mathsf{neg}\left(3\right)\right)}}\right)\right) \cdot \left(\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r\right)} \]
    15. metadata-evalN/A

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 1.0× speedup?

\[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
(FPCore (s r)
 :precision binary32
 (+
  (/ (* 0.25 (exp (/ (- r) s))) (* (* (* 2.0 PI) s) r))
  (/ (* 0.75 (exp (* -0.3333333333333333 (/ r 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((-0.3333333333333333f * (r / 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(-0.3333333333333333) * Float32(r / 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((single(-0.3333333333333333) * (r / s)))) / (((single(6.0) * single(pi)) * s) * r));
end
\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
Derivation
  1. Initial program 99.5%

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

      \[\leadsto \frac{\frac{1}{4} \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{\frac{3}{4} \cdot e^{\frac{-1}{3} \cdot \color{blue}{\frac{r}{s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
    2. lower-/.f3299.5%

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

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

Alternative 3: 99.5% accurate, 1.1× speedup?

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

    \[\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. Applied rewrites99.5%

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{e^{\frac{r}{-3 \cdot s}}}{\pi \cdot s}, \frac{1}{8}, \frac{\frac{1}{8}}{\left(\pi \cdot s\right) \cdot e^{\frac{r}{s}}}\right)}{r}} \]
    2. div-flipN/A

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

      \[\leadsto \color{blue}{\frac{1}{\frac{r}{\mathsf{fma}\left(\frac{e^{\frac{r}{-3 \cdot s}}}{\pi \cdot s}, \frac{1}{8}, \frac{\frac{1}{8}}{\left(\pi \cdot s\right) \cdot e^{\frac{r}{s}}}\right)}}} \]
    4. lower-unsound-/.f3299.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{r}{\mathsf{fma}\left(\frac{e^{\frac{r}{-3 \cdot s}}}{\pi \cdot s}, 0.125, \frac{0.125}{\left(\pi \cdot s\right) \cdot e^{\frac{r}{s}}}\right)}}} \]
    5. lift-fma.f32N/A

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 1.2× speedup?

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

    \[\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. Applied rewrites99.5%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.5% accurate, 1.3× speedup?

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

    \[\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. Applied rewrites99.5%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi} + \frac{1}{8} \cdot \frac{1}{\pi \cdot e^{\frac{r}{s}}}}{r \cdot s}} \]
  4. Step-by-step derivation
    1. lower-/.f32N/A

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(0.125, \frac{e^{-0.3333333333333333 \cdot \frac{r}{s}}}{\pi}, 0.125 \cdot \frac{1}{\pi \cdot e^{\frac{r}{s}}}\right)}{r \cdot s}} \]
  6. Step-by-step derivation
    1. Applied rewrites99.5%

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

    Alternative 6: 43.5% accurate, 1.7× speedup?

    \[\frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right) \cdot s} \]
    (FPCore (s r) :precision binary32 (/ 0.25 (* (log (pow (exp PI) r)) s)))
    float code(float s, float r) {
    	return 0.25f / (logf(powf(expf(((float) M_PI)), r)) * s);
    }
    
    function code(s, r)
    	return Float32(Float32(0.25) / Float32(log((exp(Float32(pi)) ^ r)) * s))
    end
    
    function tmp = code(s, r)
    	tmp = single(0.25) / (log((exp(single(pi)) ^ r)) * s);
    end
    
    \frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right) \cdot s}
    
    Derivation
    1. Initial program 99.5%

      \[\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 \pi\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. lower-*.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{4}}{\left(r \cdot \pi\right) \cdot \color{blue}{s}} \]
      6. lower-*.f329.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{4}}{\log \left({\left(e^{\pi}\right)}^{r}\right) \cdot s} \]
      8. lower-exp.f3243.5%

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

      \[\leadsto \frac{0.25}{\log \left({\left(e^{\pi}\right)}^{r}\right) \cdot s} \]
    9. Add Preprocessing

    Alternative 7: 10.7% accurate, 2.5× speedup?

    \[\frac{0.25}{\log \left(e^{\left(r \cdot \pi\right) \cdot s}\right)} \]
    (FPCore (s r) :precision binary32 (/ 0.25 (log (exp (* (* r PI) s)))))
    float code(float s, float r) {
    	return 0.25f / logf(expf(((r * ((float) M_PI)) * s)));
    }
    
    function code(s, r)
    	return Float32(Float32(0.25) / log(exp(Float32(Float32(r * Float32(pi)) * s))))
    end
    
    function tmp = code(s, r)
    	tmp = single(0.25) / log(exp(((r * single(pi)) * s)));
    end
    
    \frac{0.25}{\log \left(e^{\left(r \cdot \pi\right) \cdot s}\right)}
    
    Derivation
    1. Initial program 99.5%

      \[\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 \pi\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. lower-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{4}}{\log \left({\left(e^{\pi}\right)}^{\left(r \cdot s\right)}\right)} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left({\left(e^{\pi}\right)}^{\left(s \cdot r\right)}\right)} \]
      10. pow-expN/A

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

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{\left(s \cdot r\right) \cdot \pi}\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{\left(r \cdot s\right) \cdot \pi}\right)} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{r \cdot \left(s \cdot \pi\right)}\right)} \]
      14. lift-*.f32N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{r \cdot \left(s \cdot \pi\right)}\right)} \]
      15. lift-*.f32N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{r \cdot \left(s \cdot \pi\right)}\right)} \]
      16. lower-exp.f3210.7%

        \[\leadsto \frac{0.25}{\log \left(e^{r \cdot \left(s \cdot \pi\right)}\right)} \]
      17. lift-*.f32N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{r \cdot \left(s \cdot \pi\right)}\right)} \]
      18. lift-*.f32N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{r \cdot \left(s \cdot \pi\right)}\right)} \]
      19. *-commutativeN/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{r \cdot \left(\pi \cdot s\right)}\right)} \]
      20. associate-*r*N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{\left(r \cdot \pi\right) \cdot s}\right)} \]
      21. lower-*.f32N/A

        \[\leadsto \frac{\frac{1}{4}}{\log \left(e^{\left(r \cdot \pi\right) \cdot s}\right)} \]
      22. lower-*.f3210.7%

        \[\leadsto \frac{0.25}{\log \left(e^{\left(r \cdot \pi\right) \cdot s}\right)} \]
    6. Applied rewrites10.7%

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

    Alternative 8: 9.4% accurate, 2.6× speedup?

    \[\frac{\mathsf{fma}\left(-0.16666666666666666, \frac{r}{s \cdot \pi}, 0.25 \cdot \frac{1}{\pi}\right)}{r \cdot s} \]
    (FPCore (s r)
     :precision binary32
     (/ (fma -0.16666666666666666 (/ r (* s PI)) (* 0.25 (/ 1.0 PI))) (* r s)))
    float code(float s, float r) {
    	return fmaf(-0.16666666666666666f, (r / (s * ((float) M_PI))), (0.25f * (1.0f / ((float) M_PI)))) / (r * s);
    }
    
    function code(s, r)
    	return Float32(fma(Float32(-0.16666666666666666), Float32(r / Float32(s * Float32(pi))), Float32(Float32(0.25) * Float32(Float32(1.0) / Float32(pi)))) / Float32(r * s))
    end
    
    \frac{\mathsf{fma}\left(-0.16666666666666666, \frac{r}{s \cdot \pi}, 0.25 \cdot \frac{1}{\pi}\right)}{r \cdot s}
    
    Derivation
    1. Initial program 99.5%

      \[\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. Applied rewrites99.5%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi} + \frac{1}{8} \cdot \frac{1}{\pi \cdot e^{\frac{r}{s}}}}{r \cdot s}} \]
    4. Step-by-step derivation
      1. lower-/.f32N/A

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

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

      \[\leadsto \frac{\frac{-1}{6} \cdot \frac{r}{s \cdot \pi} + \frac{1}{4} \cdot \frac{1}{\pi}}{\color{blue}{r} \cdot s} \]
    7. Step-by-step derivation
      1. lower-fma.f32N/A

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{-1}{6}, \frac{r}{s \cdot \pi}, \frac{1}{4} \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)}{r \cdot s} \]
      7. lower-PI.f329.4%

        \[\leadsto \frac{\mathsf{fma}\left(-0.16666666666666666, \frac{r}{s \cdot \pi}, 0.25 \cdot \frac{1}{\pi}\right)}{r \cdot s} \]
    8. Applied rewrites9.4%

      \[\leadsto \frac{\mathsf{fma}\left(-0.16666666666666666, \frac{r}{s \cdot \pi}, 0.25 \cdot \frac{1}{\pi}\right)}{\color{blue}{r} \cdot s} \]
    9. Add Preprocessing

    Alternative 9: 9.2% accurate, 6.0× speedup?

    \[\frac{\frac{0.25}{\pi}}{r \cdot s} \]
    (FPCore (s r) :precision binary32 (/ (/ 0.25 PI) (* r s)))
    float code(float s, float r) {
    	return (0.25f / ((float) M_PI)) / (r * s);
    }
    
    function code(s, r)
    	return Float32(Float32(Float32(0.25) / Float32(pi)) / Float32(r * s))
    end
    
    function tmp = code(s, r)
    	tmp = (single(0.25) / single(pi)) / (r * s);
    end
    
    \frac{\frac{0.25}{\pi}}{r \cdot s}
    
    Derivation
    1. Initial program 99.5%

      \[\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. Applied rewrites99.5%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{8} \cdot \frac{e^{\frac{-1}{3} \cdot \frac{r}{s}}}{\pi} + \frac{1}{8} \cdot \frac{1}{\pi \cdot e^{\frac{r}{s}}}}{r \cdot s}} \]
    4. Step-by-step derivation
      1. lower-/.f32N/A

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

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

      \[\leadsto \frac{\frac{\frac{1}{4}}{\pi}}{\color{blue}{r} \cdot s} \]
    7. Step-by-step derivation
      1. lower-/.f32N/A

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

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

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

    Alternative 10: 9.2% accurate, 6.4× speedup?

    \[\frac{0.25}{\left(s \cdot r\right) \cdot \pi} \]
    (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
    
    \frac{0.25}{\left(s \cdot r\right) \cdot \pi}
    
    Derivation
    1. Initial program 99.5%

      \[\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 \pi\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. lower-*.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{4}}{\left(s \cdot r\right) \cdot \color{blue}{\pi}} \]
      6. lower-*.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

    Alternative 11: 9.2% accurate, 6.4× speedup?

    \[\frac{0.25}{\left(r \cdot \pi\right) \cdot s} \]
    (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(0.25) / Float32(Float32(r * Float32(pi)) * s))
    end
    
    function tmp = code(s, r)
    	tmp = single(0.25) / ((r * single(pi)) * s);
    end
    
    \frac{0.25}{\left(r \cdot \pi\right) \cdot s}
    
    Derivation
    1. Initial program 99.5%

      \[\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 \pi\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. lower-*.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{4}}{\left(r \cdot \pi\right) \cdot \color{blue}{s}} \]
      6. lower-*.f329.2%

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

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

    Alternative 12: 9.2% accurate, 6.4× speedup?

    \[\frac{0.25}{r \cdot \left(s \cdot \pi\right)} \]
    (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
    
    \frac{0.25}{r \cdot \left(s \cdot \pi\right)}
    
    Derivation
    1. Initial program 99.5%

      \[\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 \pi\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. lower-*.f32N/A

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

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

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

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

    Reproduce

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