Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.6% → 99.6%
Time: 18.1s
Alternatives: 18
Speedup: 1.0×

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

\\
\frac{e^{-\frac{r}{s}} \cdot 0.125}{r \cdot \left(s \cdot \pi\right)} + \frac{0.75 \cdot e^{\frac{\frac{r}{s}}{-3}}}{\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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. 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{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  5. Applied rewrites99.6%

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

Alternative 2: 99.6% accurate, 1.0× speedup?

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

\\
\frac{e^{-\frac{r}{s}} \cdot 0.125}{r \cdot \left(s \cdot \pi\right)} + \frac{0.75 \cdot e^{\frac{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot r\right) \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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. 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{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  5. Applied rewrites99.6%

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

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

Alternative 3: 99.6% accurate, 1.1× speedup?

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

\\
\frac{e^{-\frac{r}{s}} \cdot 0.125}{r \cdot \left(s \cdot \pi\right)} + \frac{0.75 \cdot e^{-0.3333333333333333 \cdot \frac{r}{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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. 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{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  4. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  5. Applied rewrites99.6%

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

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

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

Alternative 4: 99.5% accurate, 1.1× speedup?

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

\\
\frac{\mathsf{fma}\left(e^{-\frac{r}{s}}, \frac{0.25}{\pi + \pi}, \frac{\frac{0.75}{e^{\frac{r}{3 \cdot s}}}}{6 \cdot \pi}\right)}{r \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. Applied rewrites99.5%

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

Alternative 5: 99.5% accurate, 1.2× speedup?

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

\\
\frac{\frac{0.75}{e^{\frac{r}{3 \cdot s}} \cdot 6} + \frac{0.25}{e^{\frac{r}{s}} \cdot 2}}{r \cdot \left(s \cdot \pi\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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. Applied rewrites99.5%

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

Alternative 6: 99.5% accurate, 1.2× speedup?

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

\\
\frac{\mathsf{fma}\left(0.125, \frac{1}{e^{0.3333333333333333 \cdot \frac{r}{s}}}, 0.125 \cdot \frac{1}{e^{\frac{r}{s}}}\right)}{r \cdot \left(s \cdot \pi\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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. Applied rewrites97.0%

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

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

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

Alternative 7: 99.5% accurate, 1.2× speedup?

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

\\
\frac{\mathsf{fma}\left(0.125, e^{-\frac{r}{s}}, 0.125 \cdot \frac{1}{e^{0.3333333333333333 \cdot \frac{r}{s}}}\right)}{r \cdot \left(s \cdot \pi\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. Applied rewrites99.5%

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

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

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

Alternative 8: 16.3% accurate, 1.4× speedup?

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

\\
\frac{\frac{\frac{0.75}{6 + 2 \cdot \frac{r}{s}} + \frac{0.25}{e^{\frac{r}{s}} \cdot 2}}{r \cdot s}}{\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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. Applied rewrites99.5%

    \[\leadsto \color{blue}{\frac{\frac{\frac{0.75}{e^{\frac{r}{3 \cdot s}} \cdot 6} + \frac{0.25}{e^{\frac{r}{s}} \cdot 2}}{r \cdot s}}{\pi}} \]
  4. Taylor expanded in s around inf

    \[\leadsto \frac{\frac{\frac{\frac{3}{4}}{\color{blue}{6 + 2 \cdot \frac{r}{s}}} + \frac{\frac{1}{4}}{e^{\frac{r}{s}} \cdot 2}}{r \cdot s}}{\pi} \]
  5. Applied rewrites16.3%

    \[\leadsto \frac{\frac{\frac{0.75}{\color{blue}{6 + 2 \cdot \frac{r}{s}}} + \frac{0.25}{e^{\frac{r}{s}} \cdot 2}}{r \cdot s}}{\pi} \]
  6. Add Preprocessing

Alternative 9: 10.2% accurate, 1.6× speedup?

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

\\
-1 \cdot \frac{\frac{\frac{\mathsf{fma}\left(\frac{-0.006944444444444444 + -0.0625}{s}, r, 0.16666666666666666\right)}{\pi} \cdot \left(r \cdot \pi\right) - s \cdot 0.25}{r}}{\left(s \cdot \pi\right) \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}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  3. Applied rewrites10.2%

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\mathsf{fma}\left(-0.0625, \frac{r}{\pi}, -0.006944444444444444 \cdot \frac{r}{\pi}\right)}{s} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s}} \]
  4. Applied rewrites10.2%

    \[\leadsto -1 \cdot \frac{\frac{\left(\frac{0.16666666666666666}{\pi} + \frac{r}{\pi} \cdot \frac{-0.006944444444444444 + -0.0625}{s}\right) \cdot \left(r \cdot \pi\right) - s \cdot 0.25}{r \cdot \left(s \cdot \pi\right)}}{s} \]
  5. Applied rewrites10.2%

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

Alternative 10: 10.2% accurate, 1.9× speedup?

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

\\
\frac{\frac{0.25}{r \cdot \pi} - \frac{\frac{0.16666666666666666}{\pi} + \frac{r}{\pi} \cdot \frac{-0.006944444444444444 + -0.0625}{s}}{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}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  3. Applied rewrites10.2%

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\mathsf{fma}\left(-0.0625, \frac{r}{\pi}, -0.006944444444444444 \cdot \frac{r}{\pi}\right)}{s} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s}} \]
  4. Applied rewrites10.2%

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

Alternative 11: 10.2% accurate, 2.0× speedup?

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

\\
-1 \cdot \frac{\frac{r \cdot \left(0.16666666666666666 + -0.06944444444444445 \cdot \frac{r}{s}\right) - s \cdot 0.25}{r \cdot \left(s \cdot \pi\right)}}{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}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{-1}{16} \cdot \frac{r}{\mathsf{PI}\left(\right)} + \frac{-1}{144} \cdot \frac{r}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s} - \frac{1}{4} \cdot \frac{1}{r \cdot \mathsf{PI}\left(\right)}}{s}} \]
  3. Applied rewrites10.2%

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\mathsf{fma}\left(-0.0625, \frac{r}{\pi}, -0.006944444444444444 \cdot \frac{r}{\pi}\right)}{s} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s}} \]
  4. Applied rewrites10.2%

    \[\leadsto -1 \cdot \frac{\frac{\left(\frac{0.16666666666666666}{\pi} + \frac{r}{\pi} \cdot \frac{-0.006944444444444444 + -0.0625}{s}\right) \cdot \left(r \cdot \pi\right) - s \cdot 0.25}{r \cdot \left(s \cdot \pi\right)}}{s} \]
  5. Taylor expanded in r around 0

    \[\leadsto -1 \cdot \frac{\frac{r \cdot \left(\frac{1}{6} + \frac{-5}{72} \cdot \frac{r}{s}\right) - s \cdot \frac{1}{4}}{r \cdot \left(s \cdot \pi\right)}}{s} \]
  6. Applied rewrites10.2%

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

Alternative 12: 9.2% accurate, 2.3× speedup?

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

\\
-1 \cdot \frac{\frac{0.16666666666666666 \cdot \frac{r}{s \cdot \pi} - 0.25 \cdot \frac{1}{\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 -inf

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{\mathsf{fma}\left(-0.0625, \frac{r}{\pi}, -0.006944444444444444 \cdot \frac{r}{\pi}\right)}{s} - 0.16666666666666666 \cdot \frac{1}{\pi}}{s} - 0.25 \cdot \frac{1}{r \cdot \pi}}{s}} \]
  4. Taylor expanded in r around 0

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

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

Alternative 13: 9.1% accurate, 2.5× speedup?

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

\\
\frac{\frac{0.25 \cdot \frac{s}{r \cdot \pi} - 0.16666666666666666 \cdot \frac{1}{\pi}}{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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. Taylor expanded in s around inf

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

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

    \[\leadsto \frac{\frac{\frac{1}{4} \cdot \frac{s}{r \cdot \mathsf{PI}\left(\right)} - \frac{1}{6} \cdot \frac{1}{\mathsf{PI}\left(\right)}}{s}}{s} \]
  6. Applied rewrites9.1%

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

Alternative 14: 9.1% accurate, 3.3× speedup?

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

\\
\frac{\frac{0.25}{r \cdot \pi} - \frac{0.16666666666666666}{s \cdot \pi}}{s}
\end{array}
Derivation
  1. Initial program 99.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. Applied rewrites99.6%

    \[\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{\frac{r}{s}}{-3}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  3. Taylor expanded in s around inf

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

    \[\leadsto \color{blue}{\frac{0.25 \cdot \frac{1}{r \cdot \pi} - 0.16666666666666666 \cdot \frac{1}{s \cdot \pi}}{s}} \]
  5. Applied rewrites9.2%

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

Alternative 15: 9.1% accurate, 4.8× speedup?

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

\\
\frac{0.25}{s \cdot \pi} \cdot \frac{1}{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. Applied rewrites99.5%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{4}}{s \cdot \mathsf{PI}\left(\right)}} \cdot \frac{1}{r} \]
  4. Applied rewrites9.1%

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

Alternative 16: 9.1% accurate, 6.4× speedup?

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

\\
\frac{0.25}{\left(r \cdot \pi\right) \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. Applied rewrites9.1%

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

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

Alternative 17: 9.1% accurate, 6.4× speedup?

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

\\
\frac{0.25}{\left(r \cdot s\right) \cdot \pi}
\end{array}
Derivation
  1. Initial program 99.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. Applied rewrites9.1%

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

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

Alternative 18: 9.1% accurate, 6.4× 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.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. Applied rewrites9.1%

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

Reproduce

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