Average Error: 12.9 → 1.8
Time: 24.2s
Precision: binary64
Cost: 46216
\[\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 := \log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)\\ t_1 := {t_0}^{3}\\ \mathbf{if}\;4 \cdot u \leq 0.00062:\\ \;\;\;\;\left(\left(\left(21.333333333333332 \cdot s\right) \cdot \left(u \cdot u\right)\right) \cdot u + s \cdot \left(64 \cdot {u}^{4} + 8 \cdot \left(u \cdot u\right)\right)\right) + \left(s \cdot 4\right) \cdot u\\ \mathbf{else}:\\ \;\;\;\;s \cdot \begin{array}{l} \mathbf{if}\;t_1 \ne 0:\\ \;\;\;\;\frac{1}{{t_1}^{-0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array}\\ \end{array} \]
(FPCore (s u) :precision binary64 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
(FPCore (s u)
 :precision binary64
 (let* ((t_0 (log (/ -1.0 (fma u 4.0 -1.0)))) (t_1 (pow t_0 3.0)))
   (if (<= (* 4.0 u) 0.00062)
     (+
      (+
       (* (* (* 21.333333333333332 s) (* u u)) u)
       (* s (+ (* 64.0 (pow u 4.0)) (* 8.0 (* u u)))))
      (* (* s 4.0) u))
     (* s (if (!= t_1 0.0) (/ 1.0 (pow t_1 -0.3333333333333333)) t_0)))))
double code(double s, double u) {
	return s * log((1.0 / (1.0 - (4.0 * u))));
}
double code(double s, double u) {
	double t_0 = log((-1.0 / fma(u, 4.0, -1.0)));
	double t_1 = pow(t_0, 3.0);
	double tmp;
	if ((4.0 * u) <= 0.00062) {
		tmp = ((((21.333333333333332 * s) * (u * u)) * u) + (s * ((64.0 * pow(u, 4.0)) + (8.0 * (u * u))))) + ((s * 4.0) * u);
	} else {
		double tmp_1;
		if (t_1 != 0.0) {
			tmp_1 = 1.0 / pow(t_1, -0.3333333333333333);
		} else {
			tmp_1 = t_0;
		}
		tmp = s * tmp_1;
	}
	return tmp;
}
function code(s, u)
	return Float64(s * log(Float64(1.0 / Float64(1.0 - Float64(4.0 * u)))))
end
function code(s, u)
	t_0 = log(Float64(-1.0 / fma(u, 4.0, -1.0)))
	t_1 = t_0 ^ 3.0
	tmp = 0.0
	if (Float64(4.0 * u) <= 0.00062)
		tmp = Float64(Float64(Float64(Float64(Float64(21.333333333333332 * s) * Float64(u * u)) * u) + Float64(s * Float64(Float64(64.0 * (u ^ 4.0)) + Float64(8.0 * Float64(u * u))))) + Float64(Float64(s * 4.0) * u));
	else
		tmp_1 = 0.0
		if (t_1 != 0.0)
			tmp_1 = Float64(1.0 / (t_1 ^ -0.3333333333333333));
		else
			tmp_1 = t_0;
		end
		tmp = Float64(s * tmp_1);
	end
	return tmp
end
code[s_, u_] := N[(s * N[Log[N[(1.0 / N[(1.0 - N[(4.0 * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[s_, u_] := Block[{t$95$0 = N[Log[N[(-1.0 / N[(u * 4.0 + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 3.0], $MachinePrecision]}, If[LessEqual[N[(4.0 * u), $MachinePrecision], 0.00062], N[(N[(N[(N[(N[(21.333333333333332 * s), $MachinePrecision] * N[(u * u), $MachinePrecision]), $MachinePrecision] * u), $MachinePrecision] + N[(s * N[(N[(64.0 * N[Power[u, 4.0], $MachinePrecision]), $MachinePrecision] + N[(8.0 * N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(s * 4.0), $MachinePrecision] * u), $MachinePrecision]), $MachinePrecision], N[(s * If[Unequal[t$95$1, 0.0], N[(1.0 / N[Power[t$95$1, -0.3333333333333333], $MachinePrecision]), $MachinePrecision], t$95$0]), $MachinePrecision]]]]
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\begin{array}{l}
t_0 := \log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)\\
t_1 := {t_0}^{3}\\
\mathbf{if}\;4 \cdot u \leq 0.00062:\\
\;\;\;\;\left(\left(\left(21.333333333333332 \cdot s\right) \cdot \left(u \cdot u\right)\right) \cdot u + s \cdot \left(64 \cdot {u}^{4} + 8 \cdot \left(u \cdot u\right)\right)\right) + \left(s \cdot 4\right) \cdot u\\

\mathbf{else}:\\
\;\;\;\;s \cdot \begin{array}{l}
\mathbf{if}\;t_1 \ne 0:\\
\;\;\;\;\frac{1}{{t_1}^{-0.3333333333333333}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 4 u) < 6.2e-4

    1. Initial program 18.1

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Taylor expanded in u around 0 0.7

      \[\leadsto \color{blue}{21.333333333333332 \cdot \left({u}^{3} \cdot s\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)} \]
    3. Applied egg-rr0.7

      \[\leadsto 21.333333333333332 \cdot \left({u}^{3} \cdot s\right) + \color{blue}{\left(s \cdot \left(8 \cdot \left(u \cdot u\right) + 4 \cdot u\right) + 64 \cdot \left(s \cdot {u}^{4}\right)\right)} \]
    4. Applied egg-rr0.6

      \[\leadsto \color{blue}{\left(\left(21.333333333333332 \cdot s\right) \cdot {u}^{3} + s \cdot \left(64 \cdot {u}^{4} + 8 \cdot \left(u \cdot u\right)\right)\right) + \left(s \cdot 4\right) \cdot u} \]
    5. Applied egg-rr0.6

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

    if 6.2e-4 < (*.f64 4 u)

    1. Initial program 3.9

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

      \[\leadsto s \cdot \color{blue}{\sqrt[3]{{\log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)}^{3}}} \]
    3. Applied egg-rr3.9

      \[\leadsto s \cdot \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;{\log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)}^{3} \ne 0:\\ \;\;\;\;\frac{1}{{\left({\log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)}^{3}\right)}^{-0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)\\ } \end{array}} \]
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error1.8
Cost26436
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.00062:\\ \;\;\;\;\left(\left(\left(21.333333333333332 \cdot s\right) \cdot \left(u \cdot u\right)\right) \cdot u + s \cdot \left(64 \cdot {u}^{4} + 8 \cdot \left(u \cdot u\right)\right)\right) + \left(s \cdot 4\right) \cdot u\\ \mathbf{else}:\\ \;\;\;\;s \cdot {\left({\log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)}^{3}\right)}^{0.3333333333333333}\\ \end{array} \]
Alternative 2
Error1.8
Cost26372
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.00062:\\ \;\;\;\;\left(\left(\left(21.333333333333332 \cdot s\right) \cdot \left(u \cdot u\right)\right) \cdot u + s \cdot \left(64 \cdot {u}^{4} + 8 \cdot \left(u \cdot u\right)\right)\right) + \left(s \cdot 4\right) \cdot u\\ \mathbf{else}:\\ \;\;\;\;s \cdot \sqrt[3]{{\log \left(\frac{-1}{\mathsf{fma}\left(u, 4, -1\right)}\right)}^{3}}\\ \end{array} \]
Alternative 3
Error1.9
Cost8452
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.00062:\\ \;\;\;\;21.333333333333332 \cdot \left({u}^{3} \cdot s\right) + \left(4 \cdot \left(s \cdot u\right) + \left(u \cdot u\right) \cdot \left(\left(64 \cdot s\right) \cdot \left(u \cdot u\right) + 8 \cdot s\right)\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 4
Error1.9
Cost8452
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.00062:\\ \;\;\;\;\left(\left(s \cdot u\right) \cdot u\right) \cdot \left(u \cdot 21.333333333333332\right) + \left(s \cdot \left(8 \cdot \left(u \cdot u\right) + 4 \cdot u\right) + 64 \cdot \left(s \cdot {u}^{4}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 5
Error1.8
Cost8452
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 0.00062:\\ \;\;\;\;\left(\left(\left(21.333333333333332 \cdot s\right) \cdot \left(u \cdot u\right)\right) \cdot u + s \cdot \left(64 \cdot {u}^{4} + 8 \cdot \left(u \cdot u\right)\right)\right) + \left(s \cdot 4\right) \cdot u\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 6
Error3.1
Cost7940
\[\begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t_0 \leq 0.99985:\\ \;\;\;\;s \cdot \log \left(\frac{1}{t_0}\right)\\ \mathbf{else}:\\ \;\;\;\;21.333333333333332 \cdot \left({u}^{3} \cdot s\right) + s \cdot \left(8 \cdot \left(u \cdot u\right) + 4 \cdot u\right)\\ \end{array} \]
Alternative 7
Error3.2
Cost7812
\[\begin{array}{l} t_0 := 1 - 4 \cdot u\\ \mathbf{if}\;t_0 \leq 0.99985:\\ \;\;\;\;s \cdot \log \left(\frac{1}{t_0}\right)\\ \mathbf{else}:\\ \;\;\;\;21.333333333333332 \cdot \left({u}^{3} \cdot s\right) + s \cdot \left(u \cdot \left(8 \cdot u + 4\right)\right)\\ \end{array} \]
Alternative 8
Error6.3
Cost7428
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 5 \cdot 10^{-6}:\\ \;\;\;\;4 \cdot \left(s \cdot u\right) + 8 \cdot \left(s \cdot {u}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 9
Error6.3
Cost7236
\[\begin{array}{l} \mathbf{if}\;4 \cdot u \leq 5 \cdot 10^{-6}:\\ \;\;\;\;\left(u \cdot \left(s \cdot u\right)\right) \cdot 8 + \left(s \cdot 4\right) \cdot u\\ \mathbf{else}:\\ \;\;\;\;s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)\\ \end{array} \]
Alternative 10
Error22.0
Cost832
\[\left(u \cdot \left(s \cdot u\right)\right) \cdot 8 + \left(s \cdot 4\right) \cdot u \]
Alternative 11
Error36.6
Cost320
\[4 \cdot \left(s \cdot u\right) \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (s u)
  :name "Disney BSSRDF, sample scattering profile, lower"
  :precision binary64
  :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))))))