Average Error: 5.9 → 0.5
Time: 5.4s
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 := \frac{z}{\frac{x}{z}}\\ \left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \left(\left(0.0007936500793651 \cdot t_0 + \left(t_0 \cdot y + 0.083333333333333 \cdot \frac{1}{x}\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right) \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 (/ z (/ x z))))
   (+
    (- 0.91893853320467 (fma (log x) (- 0.5 x) x))
    (+
     (+
      (* 0.0007936500793651 t_0)
      (+ (* t_0 y) (* 0.083333333333333 (/ 1.0 x))))
     (* (/ z x) -0.0027777777777778)))))
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 = z / (x / z);
	return (0.91893853320467 - fma(log(x), (0.5 - x), x)) + (((0.0007936500793651 * t_0) + ((t_0 * y) + (0.083333333333333 * (1.0 / x)))) + ((z / x) * -0.0027777777777778));
}
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(z / Float64(x / z))
	return Float64(Float64(0.91893853320467 - fma(log(x), Float64(0.5 - x), x)) + Float64(Float64(Float64(0.0007936500793651 * t_0) + Float64(Float64(t_0 * y) + Float64(0.083333333333333 * Float64(1.0 / x)))) + Float64(Float64(z / x) * -0.0027777777777778)))
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[(z / N[(x / z), $MachinePrecision]), $MachinePrecision]}, N[(N[(0.91893853320467 - N[(N[Log[x], $MachinePrecision] * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.0007936500793651 * t$95$0), $MachinePrecision] + N[(N[(t$95$0 * y), $MachinePrecision] + N[(0.083333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * -0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $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 := \frac{z}{\frac{x}{z}}\\
\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \left(\left(0.0007936500793651 \cdot t_0 + \left(t_0 \cdot y + 0.083333333333333 \cdot \frac{1}{x}\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right)
\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.9
Target1.2
Herbie0.5
\[\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. Initial program 5.9

    \[\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. Simplified5.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 0 6.0

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

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

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

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

Reproduce

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