Disney BSSRDF, PDF of scattering profile

Percentage Accurate: 99.6% → 99.6%
Time: 20.2s
Alternatives: 12
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}

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\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.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. Add Preprocessing
  3. Final simplification99.6%

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

Alternative 2: 99.6% accurate, 1.0× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot e^{\frac{-r}{s \cdot 3}}}{6 \cdot \left(\pi \cdot \left(r \cdot s\right)\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. Add Preprocessing
  3. Taylor expanded in s around 0 99.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^{\frac{-r}{3 \cdot s}}}{\color{blue}{6 \cdot \left(r \cdot \left(s \cdot \pi\right)\right)}} \]
  4. Step-by-step derivation
    1. associate-*r*99.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^{\frac{-r}{3 \cdot s}}}{6 \cdot \color{blue}{\left(\left(r \cdot s\right) \cdot \pi\right)}} \]
  5. Simplified99.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^{\frac{-r}{3 \cdot s}}}{\color{blue}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)}} \]
  6. Final simplification99.6%

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

Alternative 3: 99.5% accurate, 1.0× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot e^{\frac{r \cdot -0.3333333333333333}{s}}}{6 \cdot \left(\pi \cdot \left(r \cdot s\right)\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. Add Preprocessing
  3. Taylor expanded in r around 0 99.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} \]
  4. Step-by-step derivation
    1. associate-*r/99.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{-0.3333333333333333 \cdot r}{s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  5. Simplified99.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{-0.3333333333333333 \cdot r}{s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  6. Taylor expanded in s around 0 99.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^{\frac{-0.3333333333333333 \cdot r}{s}}}{\color{blue}{6 \cdot \left(r \cdot \left(s \cdot \pi\right)\right)}} \]
  7. Step-by-step derivation
    1. associate-*r*99.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^{\frac{-r}{3 \cdot s}}}{6 \cdot \color{blue}{\left(\left(r \cdot s\right) \cdot \pi\right)}} \]
  8. Simplified99.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^{\frac{-0.3333333333333333 \cdot r}{s}}}{\color{blue}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)}} \]
  9. Final simplification99.6%

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

Alternative 4: 99.5% accurate, 1.0× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot e^{\frac{r \cdot -0.3333333333333333}{s}}}{r \cdot \left(s \cdot \left(\pi \cdot 6\right)\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. Add Preprocessing
  3. Taylor expanded in r around 0 99.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} \]
  4. Step-by-step derivation
    1. associate-*r/99.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{-0.3333333333333333 \cdot r}{s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  5. Simplified99.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{-0.3333333333333333 \cdot r}{s}}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
  6. Final simplification99.6%

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

Alternative 5: 99.5% accurate, 1.0× speedup?

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

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

    \[\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. Step-by-step derivation
    1. pow-to-exp99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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) \]
  6. Step-by-step derivation
    1. metadata-eval99.5%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.5% accurate, 1.1× speedup?

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

\\
\frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{e^{-0.3333333333333333 \cdot \frac{r}{s}}}{r}\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. Simplified99.3%

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

    \[\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. Final simplification99.5%

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

Alternative 7: 99.5% accurate, 1.1× speedup?

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

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

    \[\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. Step-by-step derivation
    1. pow-to-exp99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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) \]
  6. Final simplification99.5%

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

Alternative 8: 15.8% accurate, 1.7× speedup?

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

\\
\frac{0.25 \cdot e^{\frac{-r}{s}}}{r \cdot \left(s \cdot \left(2 \cdot \pi\right)\right)} + \frac{0.75 \cdot \frac{1}{1 + \frac{r}{s} \cdot 0.3333333333333333}}{6 \cdot \left(\pi \cdot \left(r \cdot s\right)\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. Add Preprocessing
  3. Taylor expanded in s around 0 99.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^{\frac{-r}{3 \cdot s}}}{\color{blue}{6 \cdot \left(r \cdot \left(s \cdot \pi\right)\right)}} \]
  4. Step-by-step derivation
    1. associate-*r*99.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^{\frac{-r}{3 \cdot s}}}{6 \cdot \color{blue}{\left(\left(r \cdot s\right) \cdot \pi\right)}} \]
  5. Simplified99.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^{\frac{-r}{3 \cdot s}}}{\color{blue}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)}} \]
  6. Step-by-step derivation
    1. distribute-frac-neg99.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{r}{3 \cdot s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    2. exp-neg99.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 \color{blue}{\frac{1}{e^{\frac{r}{3 \cdot s}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    3. add-sqr-sqrt99.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 \frac{1}{e^{\frac{\color{blue}{\sqrt{r} \cdot \sqrt{r}}}{3 \cdot s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    4. sqrt-unprod99.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 \frac{1}{e^{\frac{\color{blue}{\sqrt{r \cdot r}}}{3 \cdot s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    5. sqr-neg99.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 \frac{1}{e^{\frac{\sqrt{\color{blue}{\left(-r\right) \cdot \left(-r\right)}}}{3 \cdot s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    6. sqrt-unprod-0.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 \frac{1}{e^{\frac{\color{blue}{\sqrt{-r} \cdot \sqrt{-r}}}{3 \cdot s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    7. add-sqr-sqrt6.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 \frac{1}{e^{\frac{\color{blue}{-r}}{3 \cdot s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    8. *-commutative6.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 \frac{1}{e^{\frac{-r}{\color{blue}{s \cdot 3}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    9. associate-/r*6.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 \frac{1}{e^{\color{blue}{\frac{\frac{-r}{s}}{3}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    10. exp-cbrt6.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 \frac{1}{\color{blue}{\sqrt[3]{e^{\frac{-r}{s}}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    11. div-inv6.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 \frac{1}{\sqrt[3]{e^{\color{blue}{\left(-r\right) \cdot \frac{1}{s}}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    12. exp-prod6.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 \frac{1}{\sqrt[3]{\color{blue}{{\left(e^{-r}\right)}^{\left(\frac{1}{s}\right)}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    13. add-sqr-sqrt-0.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 \frac{1}{\sqrt[3]{{\left(e^{\color{blue}{\sqrt{-r} \cdot \sqrt{-r}}}\right)}^{\left(\frac{1}{s}\right)}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    14. sqrt-unprod97.4%

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

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

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot \frac{1}{\sqrt[3]{{\left(e^{\color{blue}{\sqrt{r} \cdot \sqrt{r}}}\right)}^{\left(\frac{1}{s}\right)}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
    17. add-sqr-sqrt97.4%

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

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

      \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot \frac{1}{\sqrt[3]{e^{\color{blue}{\frac{r}{s}}}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
  7. Applied egg-rr98.4%

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

    \[\leadsto \frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot \frac{1}{\color{blue}{1 + 0.3333333333333333 \cdot \frac{r}{s}}}}{6 \cdot \left(\left(r \cdot s\right) \cdot \pi\right)} \]
  9. Final simplification13.9%

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

Alternative 9: 9.6% accurate, 2.0× speedup?

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

\\
0.125 \cdot \frac{e^{\frac{-r}{s}} + 1}{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. Simplified99.3%

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

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

    \[\leadsto \color{blue}{0.125 \cdot \frac{1 + e^{-1 \cdot \frac{r}{s}}}{r \cdot \left(s \cdot \pi\right)}} \]
  6. Step-by-step derivation
    1. mul-1-neg8.2%

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

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

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

Alternative 10: 9.6% accurate, 2.0× speedup?

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

\\
\frac{0.125}{r} \cdot \frac{e^{\frac{-r}{s}} + 1}{s \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. Simplified99.3%

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

    \[\leadsto \frac{0.125}{s \cdot \pi} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{\color{blue}{1}}{r}\right) \]
  5. Step-by-step derivation
    1. metadata-eval8.2%

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

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

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

      \[\leadsto \color{blue}{\frac{-0.75}{-6 \cdot \left(\pi \cdot s\right)}} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    5. div-inv8.2%

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

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

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

      \[\leadsto \left(-0.75 \cdot \frac{1}{-\color{blue}{\left(s \cdot \pi\right)} \cdot 6}\right) \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    9. distribute-rgt-neg-in8.2%

      \[\leadsto \left(-0.75 \cdot \frac{1}{\color{blue}{\left(s \cdot \pi\right) \cdot \left(-6\right)}}\right) \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
    10. metadata-eval8.2%

      \[\leadsto \left(-0.75 \cdot \frac{1}{\left(s \cdot \pi\right) \cdot \color{blue}{-6}}\right) \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
  6. Applied egg-rr8.2%

    \[\leadsto \color{blue}{\left(-0.75 \cdot \frac{1}{\left(s \cdot \pi\right) \cdot -6}\right)} \cdot \left(\frac{e^{\frac{r}{-s}}}{r} + \frac{1}{r}\right) \]
  7. Taylor expanded in r around inf 8.2%

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

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

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

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

      \[\leadsto \frac{0.125}{r} \cdot \frac{1 + e^{\frac{\color{blue}{-r}}{s}}}{s \cdot \pi} \]
  9. Simplified8.2%

    \[\leadsto \color{blue}{\frac{0.125}{r} \cdot \frac{1 + e^{\frac{-r}{s}}}{s \cdot \pi}} \]
  10. Final simplification8.2%

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

Alternative 11: 9.6% accurate, 2.0× speedup?

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

\\
\frac{0.125}{\pi} \cdot \frac{e^{\frac{-r}{s}} + 1}{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. Simplified99.3%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{0.125}{\pi} \cdot \frac{1 + e^{\color{blue}{\frac{-1 \cdot r}{s}}}}{s \cdot r} \]
    7. mul-1-neg8.2%

      \[\leadsto \frac{0.125}{\pi} \cdot \frac{1 + e^{\frac{\color{blue}{-r}}{s}}}{s \cdot r} \]
    8. *-commutative8.2%

      \[\leadsto \frac{0.125}{\pi} \cdot \frac{1 + e^{\frac{-r}{s}}}{\color{blue}{r \cdot s}} \]
  7. Simplified8.2%

    \[\leadsto \color{blue}{\frac{0.125}{\pi} \cdot \frac{1 + e^{\frac{-r}{s}}}{r \cdot s}} \]
  8. Final simplification8.2%

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

Alternative 12: 9.1% 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.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. Simplified99.3%

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

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

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

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

Reproduce

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