Average Error: 0.1 → 0.2
Time: 7.0s
Precision: binary32
\[0 \leq s \land s \leq 256 \land 10^{-06} < r \land r < 1000000\]
\[\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}\]
\[\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(s \cdot \sqrt[3]{\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(r \cdot \left(r \cdot r\right)\right)}\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}
\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(s \cdot \sqrt[3]{\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(r \cdot \left(r \cdot r\right)\right)}\right)}
(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))))
(FPCore (s r)
 :precision binary32
 (+
  (/ (* 0.25 (exp (/ (- r) s))) (* r (* s (* 2.0 PI))))
  (/
   (* 0.75 (exp (/ (- r) (* s 3.0))))
   (* 6.0 (* s (cbrt (* (* PI (* PI PI)) (* r (* r 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));
}
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 * (s * cbrtf((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * (r * (r * r))))));
}

Error

Bits error versus s

Bits error versus r

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.1

    \[\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 around 0 0.2

    \[\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(s \cdot \left(r \cdot \pi\right)\right)}}\]
  3. Simplified0.2

    \[\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(s \cdot \left(\pi \cdot r\right)\right)}}\]
  4. Using strategy rm
  5. Applied add-cbrt-cube_binary320.2

    \[\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 \left(s \cdot \left(\pi \cdot \color{blue}{\sqrt[3]{\left(r \cdot r\right) \cdot r}}\right)\right)}\]
  6. Applied add-cbrt-cube_binary320.2

    \[\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 \left(s \cdot \left(\color{blue}{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}} \cdot \sqrt[3]{\left(r \cdot r\right) \cdot r}\right)\right)}\]
  7. Applied cbrt-unprod_binary320.2

    \[\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 \left(s \cdot \color{blue}{\sqrt[3]{\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(r \cdot r\right) \cdot r\right)}}\right)}\]
  8. Final simplification0.2

    \[\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(s \cdot \sqrt[3]{\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(r \cdot \left(r \cdot r\right)\right)}\right)}\]

Reproduce

herbie shell --seed 2021174 
(FPCore (s r)
  :name "Disney BSSRDF, PDF of scattering profile"
  :precision binary32
  :pre (and (<= 0.0 s 256.0) (< 1e-06 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))))