Average Error: 6.6 → 0.4
Time: 10.3s
Precision: binary64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} \]
\[\begin{array}{l} t_0 := 0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\\ t_1 := z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ t_2 := z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z + -0.0027777777777778\right)\\ t_3 := \log \left(\frac{1}{x}\right)\\ \mathbf{if}\;t_2 \leq -3.802629011133731 \cdot 10^{+174}:\\ \;\;\;\;\left(0.91893853320467 - \left(\left(x + x \cdot t_3\right) + t_3 \cdot -0.5\right)\right) + t_1\\ \mathbf{elif}\;t_2 \leq 1.4441499038557408 \cdot 10^{+173}:\\ \;\;\;\;t_0 + {\left(x \cdot \frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), 0.083333333333333\right)}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;t_1 + t_0\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+
  (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
  (/
   (+
    (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
    0.083333333333333)
   x)))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 0.91893853320467 (fma (log x) (- 0.5 x) x)))
        (t_1 (* z (* z (/ (+ y 0.0007936500793651) x))))
        (t_2 (* z (+ (* (+ y 0.0007936500793651) z) -0.0027777777777778)))
        (t_3 (log (/ 1.0 x))))
   (if (<= t_2 -3.802629011133731e+174)
     (+ (- 0.91893853320467 (+ (+ x (* x t_3)) (* t_3 -0.5))) t_1)
     (if (<= t_2 1.4441499038557408e+173)
       (+
        t_0
        (pow
         (*
          x
          (/
           1.0
           (fma
            z
            (fma z (+ y 0.0007936500793651) -0.0027777777777778)
            0.083333333333333)))
         -1.0))
       (+ t_1 t_0)))))
double code(double x, double y, double z) {
	return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
double code(double x, double y, double z) {
	double t_0 = 0.91893853320467 - fma(log(x), (0.5 - x), x);
	double t_1 = z * (z * ((y + 0.0007936500793651) / x));
	double t_2 = z * (((y + 0.0007936500793651) * z) + -0.0027777777777778);
	double t_3 = log((1.0 / x));
	double tmp;
	if (t_2 <= -3.802629011133731e+174) {
		tmp = (0.91893853320467 - ((x + (x * t_3)) + (t_3 * -0.5))) + t_1;
	} else if (t_2 <= 1.4441499038557408e+173) {
		tmp = t_0 + pow((x * (1.0 / fma(z, fma(z, (y + 0.0007936500793651), -0.0027777777777778), 0.083333333333333))), -1.0);
	} else {
		tmp = t_1 + t_0;
	}
	return tmp;
}
function code(x, y, z)
	return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x))
end
function code(x, y, z)
	t_0 = Float64(0.91893853320467 - fma(log(x), Float64(0.5 - x), x))
	t_1 = Float64(z * Float64(z * Float64(Float64(y + 0.0007936500793651) / x)))
	t_2 = Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) + -0.0027777777777778))
	t_3 = log(Float64(1.0 / x))
	tmp = 0.0
	if (t_2 <= -3.802629011133731e+174)
		tmp = Float64(Float64(0.91893853320467 - Float64(Float64(x + Float64(x * t_3)) + Float64(t_3 * -0.5))) + t_1);
	elseif (t_2 <= 1.4441499038557408e+173)
		tmp = Float64(t_0 + (Float64(x * Float64(1.0 / fma(z, fma(z, Float64(y + 0.0007936500793651), -0.0027777777777778), 0.083333333333333))) ^ -1.0));
	else
		tmp = Float64(t_1 + t_0);
	end
	return tmp
end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(0.91893853320467 - N[(N[Log[x], $MachinePrecision] * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] + -0.0027777777777778), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -3.802629011133731e+174], N[(N[(0.91893853320467 - N[(N[(x + N[(x * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 1.4441499038557408e+173], N[(t$95$0 + N[Power[N[(x * N[(1.0 / N[(z * N[(z * N[(y + 0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] + 0.083333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], N[(t$95$1 + t$95$0), $MachinePrecision]]]]]]]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\begin{array}{l}
t_0 := 0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\\
t_1 := z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\
t_2 := z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z + -0.0027777777777778\right)\\
t_3 := \log \left(\frac{1}{x}\right)\\
\mathbf{if}\;t_2 \leq -3.802629011133731 \cdot 10^{+174}:\\
\;\;\;\;\left(0.91893853320467 - \left(\left(x + x \cdot t_3\right) + t_3 \cdot -0.5\right)\right) + t_1\\

\mathbf{elif}\;t_2 \leq 1.4441499038557408 \cdot 10^{+173}:\\
\;\;\;\;t_0 + {\left(x \cdot \frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), 0.083333333333333\right)}\right)}^{-1}\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.6
Target1.3
Herbie0.4
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right) \]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < -3.8026290111337312e174

    1. Initial program 32.0

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} \]
    2. Simplified32.0

      \[\leadsto \color{blue}{\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x}} \]
    3. Taylor expanded in x around inf 32.0

      \[\leadsto \left(0.91893853320467 - \color{blue}{\left(\left(\log \left(\frac{1}{x}\right) \cdot x + x\right) - 0.5 \cdot \log \left(\frac{1}{x}\right)\right)}\right) + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x} \]
    4. Taylor expanded in z around inf 32.0

      \[\leadsto \left(0.91893853320467 - \left(\left(\log \left(\frac{1}{x}\right) \cdot x + x\right) - 0.5 \cdot \log \left(\frac{1}{x}\right)\right)\right) + \color{blue}{\frac{\left(0.0007936500793651 + y\right) \cdot {z}^{2}}{x}} \]
    5. Simplified1.9

      \[\leadsto \left(0.91893853320467 - \left(\left(\log \left(\frac{1}{x}\right) \cdot x + x\right) - 0.5 \cdot \log \left(\frac{1}{x}\right)\right)\right) + \color{blue}{z \cdot \left(z \cdot \frac{0.0007936500793651 + y}{x}\right)} \]

    if -3.8026290111337312e174 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < 1.4441499038557408e173

    1. Initial program 0.4

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} \]
    2. Simplified0.3

      \[\leadsto \color{blue}{\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x}} \]
    3. Applied egg-rr0.3

      \[\leadsto \left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \color{blue}{{\left(\frac{x}{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}\right)}^{-1}} \]
    4. Applied egg-rr0.3

      \[\leadsto \left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + {\color{blue}{\left(\frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), 0.083333333333333\right)} \cdot x\right)}}^{-1} \]

    if 1.4441499038557408e173 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z)

    1. Initial program 33.8

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} \]
    2. Simplified33.8

      \[\leadsto \color{blue}{\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x}} \]
    3. Taylor expanded in z around inf 34.3

      \[\leadsto \left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \color{blue}{\frac{\left(0.0007936500793651 + y\right) \cdot {z}^{2}}{x}} \]
    4. Simplified0.6

      \[\leadsto \left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \color{blue}{z \cdot \left(z \cdot \frac{0.0007936500793651 + y}{x}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z + -0.0027777777777778\right) \leq -3.802629011133731 \cdot 10^{+174}:\\ \;\;\;\;\left(0.91893853320467 - \left(\left(x + x \cdot \log \left(\frac{1}{x}\right)\right) + \log \left(\frac{1}{x}\right) \cdot -0.5\right)\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ \mathbf{elif}\;z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z + -0.0027777777777778\right) \leq 1.4441499038557408 \cdot 10^{+173}:\\ \;\;\;\;\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + {\left(x \cdot \frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), 0.083333333333333\right)}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right) + \left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022150 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))