Average Error: 6.0 → 0.4
Time: 5.1s
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} \]
\[\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \mathsf{fma}\left(-0.0027777777777778, \frac{z}{x}, \mathsf{fma}\left(y + 0.0007936500793651, z \cdot \frac{z}{x}, {\left(x \cdot 12.000000000000048\right)}^{-1}\right)\right) \]
(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
 (+
  (- 0.91893853320467 (fma (log x) (- 0.5 x) x))
  (fma
   -0.0027777777777778
   (/ z x)
   (fma
    (+ y 0.0007936500793651)
    (* z (/ z x))
    (pow (* x 12.000000000000048) -1.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) {
	return (0.91893853320467 - fma(log(x), (0.5 - x), x)) + fma(-0.0027777777777778, (z / x), fma((y + 0.0007936500793651), (z * (z / x)), pow((x * 12.000000000000048), -1.0)));
}
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)
	return Float64(Float64(0.91893853320467 - fma(log(x), Float64(0.5 - x), x)) + fma(-0.0027777777777778, Float64(z / x), fma(Float64(y + 0.0007936500793651), Float64(z * Float64(z / x)), (Float64(x * 12.000000000000048) ^ -1.0))))
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_] := N[(N[(0.91893853320467 - N[(N[Log[x], $MachinePrecision] * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] + N[(-0.0027777777777778 * N[(z / x), $MachinePrecision] + N[(N[(y + 0.0007936500793651), $MachinePrecision] * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision] + N[Power[N[(x * 12.000000000000048), $MachinePrecision], -1.0], $MachinePrecision]), $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}
\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) + \mathsf{fma}\left(-0.0027777777777778, \frac{z}{x}, \mathsf{fma}\left(y + 0.0007936500793651, z \cdot \frac{z}{x}, {\left(x \cdot 12.000000000000048\right)}^{-1}\right)\right)

Error

Target

Original6.0
Target1.4
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. Initial program 6.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. Simplified6.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 z around 0 8.8

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

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

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

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

Reproduce

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