Average Error: 0.1 → 0.2
Time: 11.0s
Precision: binary32
Cost: 26368
\[\left(0 \leq s \land s \leq 256\right) \land \left(10^{-6} < r \land r < 1000000\right)\]
\[\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r} \]
\[\begin{array}{l} t_0 := \frac{r}{s} \cdot -0.3333333333333333\\ 0.125 \cdot \frac{e^{-\frac{r}{s}} + {\left(\sqrt[3]{e^{2}}\right)}^{t_0} \cdot {\left(\sqrt[3]{e}\right)}^{t_0}}{s \cdot \left(r \cdot \pi\right)} \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))))
(FPCore (s r)
 :precision binary32
 (let* ((t_0 (* (/ r s) -0.3333333333333333)))
   (*
    0.125
    (/
     (+ (exp (- (/ r s))) (* (pow (cbrt (exp 2.0)) t_0) (pow (cbrt E) t_0)))
     (* s (* r PI))))))
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) {
	float t_0 = (r / s) * -0.3333333333333333f;
	return 0.125f * ((expf(-(r / s)) + (powf(cbrtf(expf(2.0f)), t_0) * powf(cbrtf(((float) M_E)), t_0))) / (s * (r * ((float) M_PI))));
}
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 code(s, r)
	t_0 = Float32(Float32(r / s) * Float32(-0.3333333333333333))
	return Float32(Float32(0.125) * Float32(Float32(exp(Float32(-Float32(r / s))) + Float32((cbrt(exp(Float32(2.0))) ^ t_0) * (cbrt(Float32(exp(1))) ^ t_0))) / Float32(s * Float32(r * Float32(pi)))))
end
\frac{0.25 \cdot e^{\frac{-r}{s}}}{\left(\left(2 \cdot \pi\right) \cdot s\right) \cdot r} + \frac{0.75 \cdot e^{\frac{-r}{3 \cdot s}}}{\left(\left(6 \cdot \pi\right) \cdot s\right) \cdot r}
\begin{array}{l}
t_0 := \frac{r}{s} \cdot -0.3333333333333333\\
0.125 \cdot \frac{e^{-\frac{r}{s}} + {\left(\sqrt[3]{e^{2}}\right)}^{t_0} \cdot {\left(\sqrt[3]{e}\right)}^{t_0}}{s \cdot \left(r \cdot \pi\right)}
\end{array}

Error

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. Simplified0.8

    \[\leadsto \color{blue}{\frac{\frac{\frac{0.125}{s}}{\pi}}{r} \cdot \left(e^{\frac{-r}{s}} + {\left(e^{-0.3333333333333333}\right)}^{\left(\frac{r}{s}\right)}\right)} \]
    Proof
    (*.f32 (/.f32 (/.f32 (/.f32 1/8 s) (PI.f32)) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (/.f32 (/.f32 (Rewrite<= metadata-eval (/.f32 1/4 2)) s) (PI.f32)) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (Rewrite=> associate-/l/_binary32 (/.f32 (/.f32 1/4 2) (*.f32 (PI.f32) s))) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 5 points increase in error, 3 points decrease in error
    (*.f32 (/.f32 (/.f32 (Rewrite=> metadata-eval 1/8) (*.f32 (PI.f32) s)) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (/.f32 (Rewrite<= metadata-eval (/.f32 3/4 6)) (*.f32 (PI.f32) s)) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 (Rewrite<= associate-/r*_binary32 (/.f32 3/4 (*.f32 6 (*.f32 (PI.f32) s)))) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 3 points increase in error, 1 points decrease in error
    (*.f32 (/.f32 (/.f32 3/4 (Rewrite<= associate-*l*_binary32 (*.f32 (*.f32 6 (PI.f32)) s))) r) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 0 points increase in error, 3 points decrease in error
    (*.f32 (Rewrite<= associate-/r*_binary32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r))) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 -1/3) (/.f32 r s)))): 4 points increase in error, 5 points decrease in error
    (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (pow.f32 (exp.f32 (Rewrite<= metadata-eval (/.f32 -1 3))) (/.f32 r s)))): 0 points increase in error, 0 points decrease in error
    (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (Rewrite<= exp-prod_binary32 (exp.f32 (*.f32 (/.f32 -1 3) (/.f32 r s)))))): 0 points increase in error, 11 points decrease in error
    (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (exp.f32 (Rewrite<= times-frac_binary32 (/.f32 (*.f32 -1 r) (*.f32 3 s)))))): 4 points increase in error, 3 points decrease in error
    (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (+.f32 (exp.f32 (/.f32 (neg.f32 r) s)) (exp.f32 (/.f32 (Rewrite<= neg-mul-1_binary32 (neg.f32 r)) (*.f32 3 s))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-lft-out_binary32 (+.f32 (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s)))))): 2 points increase in error, 4 points decrease in error
    (+.f32 (*.f32 (/.f32 3/4 (Rewrite=> associate-*l*_binary32 (*.f32 (*.f32 6 (PI.f32)) (*.f32 s r)))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 1 points decrease in error
    (+.f32 (*.f32 (/.f32 3/4 (Rewrite=> associate-*l*_binary32 (*.f32 6 (*.f32 (PI.f32) (*.f32 s r))))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 1 points increase in error, 1 points decrease in error
    (+.f32 (*.f32 (Rewrite=> associate-/r*_binary32 (/.f32 (/.f32 3/4 6) (*.f32 (PI.f32) (*.f32 s r)))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 2 points decrease in error
    (+.f32 (*.f32 (/.f32 (Rewrite=> metadata-eval 1/8) (*.f32 (PI.f32) (*.f32 s r))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 (/.f32 (Rewrite<= metadata-eval (/.f32 1/4 2)) (*.f32 (PI.f32) (*.f32 s r))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 (Rewrite<= associate-/r*_binary32 (/.f32 1/4 (*.f32 2 (*.f32 (PI.f32) (*.f32 s r))))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 (/.f32 1/4 (Rewrite<= associate-*l*_binary32 (*.f32 (*.f32 2 (PI.f32)) (*.f32 s r)))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 0 points decrease in error
    (+.f32 (*.f32 (/.f32 1/4 (Rewrite<= associate-*l*_binary32 (*.f32 (*.f32 (*.f32 2 (PI.f32)) s) r))) (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 1 points increase in error, 0 points decrease in error
    (+.f32 (Rewrite=> associate-*l/_binary32 (/.f32 (*.f32 1/4 (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 2 (PI.f32)) s) r))) (*.f32 (/.f32 3/4 (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)) (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s))))): 0 points increase in error, 0 points decrease in error
    (+.f32 (/.f32 (*.f32 1/4 (exp.f32 (/.f32 (neg.f32 r) s))) (*.f32 (*.f32 (*.f32 2 (PI.f32)) s) r)) (Rewrite=> associate-*l/_binary32 (/.f32 (*.f32 3/4 (exp.f32 (/.f32 (neg.f32 r) (*.f32 3 s)))) (*.f32 (*.f32 (*.f32 6 (PI.f32)) s) r)))): 3 points increase in error, 11 points decrease in error
  3. Taylor expanded in s around 0 0.1

    \[\leadsto \color{blue}{0.125 \cdot \frac{e^{-1 \cdot \frac{r}{s}} + e^{-0.3333333333333333 \cdot \frac{r}{s}}}{s \cdot \left(r \cdot \pi\right)}} \]
  4. Applied egg-rr0.1

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

    \[\leadsto 0.125 \cdot \frac{e^{-1 \cdot \frac{r}{s}} + \color{blue}{{\left(\sqrt[3]{e^{2}}\right)}^{\left(-0.3333333333333333 \cdot \frac{r}{s}\right)} \cdot {\left(\sqrt[3]{e}\right)}^{\left(-0.3333333333333333 \cdot \frac{r}{s}\right)}}}{s \cdot \left(r \cdot \pi\right)} \]
  6. Final simplification0.2

    \[\leadsto 0.125 \cdot \frac{e^{-\frac{r}{s}} + {\left(\sqrt[3]{e^{2}}\right)}^{\left(\frac{r}{s} \cdot -0.3333333333333333\right)} \cdot {\left(\sqrt[3]{e}\right)}^{\left(\frac{r}{s} \cdot -0.3333333333333333\right)}}{s \cdot \left(r \cdot \pi\right)} \]

Alternatives

Alternative 1
Error0.1
Cost13344
\[0.125 \cdot \frac{e^{-\frac{r}{s}} + {e}^{\left(\frac{r}{s} \cdot -0.3333333333333333\right)}}{s \cdot \left(r \cdot \pi\right)} \]
Alternative 2
Error0.2
Cost10144
\[0.125 \cdot \frac{e^{-\frac{r}{s}} + e^{\frac{-0.3333333333333333}{\frac{s}{r}}}}{s \cdot \left(r \cdot \pi\right)} \]
Alternative 3
Error17.8
Cost9792
\[\frac{\frac{0.25}{s}}{\mathsf{log1p}\left(\mathsf{expm1}\left(r \cdot \pi\right)\right)} \]
Alternative 4
Error29.0
Cost3520
\[-1 + \left(1 + \frac{0.25}{r \cdot \left(s \cdot \pi\right)}\right) \]
Alternative 5
Error29.1
Cost3392
\[\frac{\frac{\frac{0.25}{\pi}}{s}}{r} \]
Alternative 6
Error29.1
Cost3392
\[\frac{0.25}{\pi \cdot \left(r \cdot s\right)} \]

Error

Reproduce

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