?

Average Error: 12.2 → 0.5
Time: 21.8s
Precision: binary32
Cost: 10500

?

\[\left(0 \leq s \land s \leq 256\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 0.25\right)\]
\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
\[\begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t_0 \leq 0.9700000286102295:\\ \;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{t_0}\right)\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right) + s \cdot \left(4 \cdot u + 64 \cdot {u}^{4}\right)\\ \end{array} \]
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
(FPCore (s u)
 :precision binary32
 (let* ((t_0 (- 1.0 (* 4.0 u))))
   (if (<= t_0 0.9700000286102295)
     (* s (+ (+ -1.0 (log (/ 1.0 t_0))) 1.0))
     (+
      (* s (+ (* 8.0 (pow u 2.0)) (* 21.333333333333332 (pow u 3.0))))
      (* s (+ (* 4.0 u) (* 64.0 (pow u 4.0))))))))
float code(float s, float u) {
	return s * logf((1.0f / (1.0f - (4.0f * u))));
}
float code(float s, float u) {
	float t_0 = 1.0f - (4.0f * u);
	float tmp;
	if (t_0 <= 0.9700000286102295f) {
		tmp = s * ((-1.0f + logf((1.0f / t_0))) + 1.0f);
	} else {
		tmp = (s * ((8.0f * powf(u, 2.0f)) + (21.333333333333332f * powf(u, 3.0f)))) + (s * ((4.0f * u) + (64.0f * powf(u, 4.0f))));
	}
	return tmp;
}
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
real(4) function code(s, u)
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: t_0
    real(4) :: tmp
    t_0 = 1.0e0 - (4.0e0 * u)
    if (t_0 <= 0.9700000286102295e0) then
        tmp = s * (((-1.0e0) + log((1.0e0 / t_0))) + 1.0e0)
    else
        tmp = (s * ((8.0e0 * (u ** 2.0e0)) + (21.333333333333332e0 * (u ** 3.0e0)))) + (s * ((4.0e0 * u) + (64.0e0 * (u ** 4.0e0))))
    end if
    code = tmp
end function
function code(s, u)
	return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u)))))
end
function code(s, u)
	t_0 = Float32(Float32(1.0) - Float32(Float32(4.0) * u))
	tmp = Float32(0.0)
	if (t_0 <= Float32(0.9700000286102295))
		tmp = Float32(s * Float32(Float32(Float32(-1.0) + log(Float32(Float32(1.0) / t_0))) + Float32(1.0)));
	else
		tmp = Float32(Float32(s * Float32(Float32(Float32(8.0) * (u ^ Float32(2.0))) + Float32(Float32(21.333333333333332) * (u ^ Float32(3.0))))) + Float32(s * Float32(Float32(Float32(4.0) * u) + Float32(Float32(64.0) * (u ^ Float32(4.0))))));
	end
	return tmp
end
function tmp = code(s, u)
	tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u))));
end
function tmp_2 = code(s, u)
	t_0 = single(1.0) - (single(4.0) * u);
	tmp = single(0.0);
	if (t_0 <= single(0.9700000286102295))
		tmp = s * ((single(-1.0) + log((single(1.0) / t_0))) + single(1.0));
	else
		tmp = (s * ((single(8.0) * (u ^ single(2.0))) + (single(21.333333333333332) * (u ^ single(3.0))))) + (s * ((single(4.0) * u) + (single(64.0) * (u ^ single(4.0)))));
	end
	tmp_2 = tmp;
end
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\begin{array}{l}
t_0 := 1 - 4 \cdot u\\
\mathbf{if}\;t_0 \leq 0.9700000286102295:\\
\;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{t_0}\right)\right) + 1\right)\\

\mathbf{else}:\\
\;\;\;\;s \cdot \left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right) + s \cdot \left(4 \cdot u + 64 \cdot {u}^{4}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (-.f32 1 (*.f32 4 u)) < 0.970000029

    1. Initial program 1.5

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Applied egg-rr1.7

      \[\leadsto s \cdot \color{blue}{\left(\left(0 - \left(-1 - \log \left(\frac{1}{1 - 4 \cdot u}\right)\right)\right) - 1\right)} \]
    3. Applied egg-rr1.5

      \[\leadsto s \cdot \color{blue}{\left(\left(-1 + \log \left(\frac{1}{1 - 4 \cdot u}\right)\right) + 1\right)} \]

    if 0.970000029 < (-.f32 1 (*.f32 4 u))

    1. Initial program 14.3

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Applied egg-rr14.4

      \[\leadsto s \cdot \color{blue}{\left(\left(0 - \left(-1 - \log \left(\frac{1}{1 - 4 \cdot u}\right)\right)\right) - 1\right)} \]
    3. Taylor expanded in u around 0 0.4

      \[\leadsto \color{blue}{21.333333333333332 \cdot \left(s \cdot {u}^{3}\right) + \left(4 \cdot \left(s \cdot u\right) + \left(8 \cdot \left(s \cdot {u}^{2}\right) + 64 \cdot \left(s \cdot {u}^{4}\right)\right)\right)} \]
    4. Simplified0.2

      \[\leadsto \color{blue}{s \cdot \left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right) + s \cdot \left(4 \cdot u + 64 \cdot {u}^{4}\right)} \]
      Proof

      [Start]0.4

      \[ 21.333333333333332 \cdot \left(s \cdot {u}^{3}\right) + \left(4 \cdot \left(s \cdot u\right) + \left(8 \cdot \left(s \cdot {u}^{2}\right) + 64 \cdot \left(s \cdot {u}^{4}\right)\right)\right) \]

      rational.json-simplify-41 [=>]0.4

      \[ 21.333333333333332 \cdot \left(s \cdot {u}^{3}\right) + \color{blue}{\left(8 \cdot \left(s \cdot {u}^{2}\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right)\right)} \]

      rational.json-simplify-41 [<=]0.4

      \[ \color{blue}{\left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) + \left(21.333333333333332 \cdot \left(s \cdot {u}^{3}\right) + 8 \cdot \left(s \cdot {u}^{2}\right)\right)} \]

      rational.json-simplify-1 [<=]0.4

      \[ \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) + \color{blue}{\left(8 \cdot \left(s \cdot {u}^{2}\right) + 21.333333333333332 \cdot \left(s \cdot {u}^{3}\right)\right)} \]

      rational.json-simplify-1 [=>]0.4

      \[ \color{blue}{\left(8 \cdot \left(s \cdot {u}^{2}\right) + 21.333333333333332 \cdot \left(s \cdot {u}^{3}\right)\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right)} \]

      rational.json-simplify-43 [=>]0.4

      \[ \left(\color{blue}{s \cdot \left({u}^{2} \cdot 8\right)} + 21.333333333333332 \cdot \left(s \cdot {u}^{3}\right)\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]

      rational.json-simplify-2 [<=]0.4

      \[ \left(s \cdot \color{blue}{\left(8 \cdot {u}^{2}\right)} + 21.333333333333332 \cdot \left(s \cdot {u}^{3}\right)\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]

      rational.json-simplify-43 [=>]0.3

      \[ \left(s \cdot \left(8 \cdot {u}^{2}\right) + \color{blue}{s \cdot \left({u}^{3} \cdot 21.333333333333332\right)}\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]

      rational.json-simplify-2 [<=]0.3

      \[ \left(s \cdot \left(8 \cdot {u}^{2}\right) + s \cdot \color{blue}{\left(21.333333333333332 \cdot {u}^{3}\right)}\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]

      rational.json-simplify-2 [=>]0.3

      \[ \left(s \cdot \left(8 \cdot {u}^{2}\right) + \color{blue}{\left(21.333333333333332 \cdot {u}^{3}\right) \cdot s}\right) + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]

      rational.json-simplify-47 [=>]0.3

      \[ \color{blue}{s \cdot \left(21.333333333333332 \cdot {u}^{3} + 8 \cdot {u}^{2}\right)} + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]

      rational.json-simplify-1 [=>]0.3

      \[ s \cdot \color{blue}{\left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right)} + \left(64 \cdot \left(s \cdot {u}^{4}\right) + 4 \cdot \left(s \cdot u\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.9700000286102295:\\ \;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{1 - 4 \cdot u}\right)\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right) + s \cdot \left(4 \cdot u + 64 \cdot {u}^{4}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.4
Cost10436
\[\begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t_0 \leq 0.9700000286102295:\\ \;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{t_0}\right)\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(4 \cdot u + \left(\left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right) + 64 \cdot {u}^{4}\right)\right)\\ \end{array} \]
Alternative 2
Error0.6
Cost7140
\[\begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t_0 \leq 0.9850000143051147:\\ \;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{t_0}\right)\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(u \cdot 4\right) + s \cdot \left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right)\\ \end{array} \]
Alternative 3
Error0.6
Cost7076
\[\begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t_0 \leq 0.9850000143051147:\\ \;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{t_0}\right)\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(4 \cdot u + \left(8 \cdot {u}^{2} + 21.333333333333332 \cdot {u}^{3}\right)\right)\\ \end{array} \]
Alternative 4
Error1.2
Cost3748
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.004999999888241291:\\ \;\;\;\;{u}^{2} \cdot \left(s \cdot 8\right) + s \cdot \left(u \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(\left(-1 + \log \left(\frac{1}{1 - 4 \cdot u}\right)\right) + 1\right)\\ \end{array} \]
Alternative 5
Error1.2
Cost3716
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.004000000189989805:\\ \;\;\;\;{u}^{2} \cdot \left(s \cdot 8\right) + s \cdot \left(u \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 6
Error1.2
Cost3652
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.004000000189989805:\\ \;\;\;\;\left(4 \cdot u + 8 \cdot {u}^{2}\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 7
Error3.5
Cost3620
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.00019999999494757503:\\ \;\;\;\;s \cdot \left(4 \cdot u\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 8
Error8.5
Cost160
\[4 \cdot \left(u \cdot s\right) \]
Alternative 9
Error8.5
Cost160
\[s \cdot \left(4 \cdot u\right) \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (s u)
  :name "Disney BSSRDF, sample scattering profile, lower"
  :precision binary32
  :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 2.328306437e-10 u) (<= u 0.25)))
  (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))