Average Error: 5.7 → 4.1
Time: 4.7s
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} \mathbf{if}\;x \leq 1.4940346439628906 \cdot 10^{+38}:\\ \;\;\;\;\left(\left(\sqrt[3]{{\left(\log x \cdot \left(x - 0.5\right)\right)}^{3}} - x\right) + 0.91893853320467\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right) + \left(\left(y + 0.0007936500793651\right) \cdot \frac{z \cdot z}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right)\\ \end{array}\]
\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}
\mathbf{if}\;x \leq 1.4940346439628906 \cdot 10^{+38}:\\
\;\;\;\;\left(\left(\sqrt[3]{{\left(\log x \cdot \left(x - 0.5\right)\right)}^{3}} - x\right) + 0.91893853320467\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\

\mathbf{else}:\\
\;\;\;\;\left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right) + \left(\left(y + 0.0007936500793651\right) \cdot \frac{z \cdot z}{x} - 0.0027777777777778 \cdot \frac{z}{x}\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
 (if (<= x 1.4940346439628906e+38)
   (+
    (+ (- (cbrt (pow (* (log x) (- x 0.5)) 3.0)) x) 0.91893853320467)
    (/
     (+
      (* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
      0.083333333333333)
     x))
   (+
    (+ 0.91893853320467 (- (* (log x) (- x 0.5)) x))
    (-
     (* (+ y 0.0007936500793651) (/ (* z z) x))
     (* 0.0027777777777778 (/ z x))))))
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 tmp;
	if (x <= 1.4940346439628906e+38) {
		tmp = ((cbrt(pow((log(x) * (x - 0.5)), 3.0)) - x) + 0.91893853320467) + (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x);
	} else {
		tmp = (0.91893853320467 + ((log(x) * (x - 0.5)) - x)) + (((y + 0.0007936500793651) * ((z * z) / x)) - (0.0027777777777778 * (z / x)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.7
Target1.2
Herbie4.1
\[\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 2 regimes
  2. if x < 1.4940346439628906e38

    1. Initial program 0.3

      \[\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. Using strategy rm
    3. Applied add-cbrt-cube_binary640.4

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \color{blue}{\sqrt[3]{\left(\log x \cdot \log x\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}\]
    4. Applied add-cbrt-cube_binary640.4

      \[\leadsto \left(\left(\color{blue}{\sqrt[3]{\left(\left(x - 0.5\right) \cdot \left(x - 0.5\right)\right) \cdot \left(x - 0.5\right)}} \cdot \sqrt[3]{\left(\log x \cdot \log x\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}\]
    5. Applied cbrt-unprod_binary640.3

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

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

    if 1.4940346439628906e38 < x

    1. Initial program 10.6

      \[\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. Taylor expanded around inf 10.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\left(\left(0.0007936500793651 \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)}\]
    3. Simplified7.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4940346439628906 \cdot 10^{+38}:\\ \;\;\;\;\left(\left(\sqrt[3]{{\left(\log x \cdot \left(x - 0.5\right)\right)}^{3}} - x\right) + 0.91893853320467\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right) + \left(\left(y + 0.0007936500793651\right) \cdot \frac{z \cdot z}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right)\\ \end{array}\]

Reproduce

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