Average Error: 6.0 → 2.8
Time: 5.7s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.40766130450651064 \cdot 10^{85} \lor \neg \left(z \le 2.0917626344359026 \cdot 10^{45}\right):\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{{z}^{1}}{\frac{x}{z}}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956\right) \cdot \frac{1}{x}\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}
\begin{array}{l}
\mathbf{if}\;z \le -1.40766130450651064 \cdot 10^{85} \lor \neg \left(z \le 2.0917626344359026 \cdot 10^{45}\right):\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{{z}^{1}}{\frac{x}{z}}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956\right) \cdot \frac{1}{x}\\

\end{array}
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 VAR;
	if (((z <= -1.4076613045065106e+85) || !(z <= 2.0917626344359026e+45))) {
		VAR = fma(log(x), (x - 0.5), (fma(0.0007936500793651, (pow(z, 1.0) / (x / z)), ((0.083333333333333 * (1.0 / x)) - (0.0027777777777778 * (z / x)))) - (x - 0.91893853320467)));
	} else {
		VAR = (((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) * (1.0 / x)));
	}
	return VAR;
}

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

Original6.0
Target1.2
Herbie2.8
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467001 - x\right)\right) + \frac{0.0833333333333329956}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.4076613045065106e+85 or 2.0917626344359026e+45 < z

    1. Initial program 30.8

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified30.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)}\]
    3. Taylor expanded around 0 31.0

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\left(\left(7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + 0.0833333333333329956 \cdot \frac{1}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)} - \left(x - 0.91893853320467001\right)\right)\]
    4. Simplified31.0

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{{z}^{2}}{x}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right)} - \left(x - 0.91893853320467001\right)\right)\]
    5. Using strategy rm
    6. Applied sqr-pow31.0

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)} \cdot {z}^{\left(\frac{2}{2}\right)}}}{x}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\]
    7. Applied associate-/l*11.9

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \color{blue}{\frac{{z}^{\left(\frac{2}{2}\right)}}{\frac{x}{{z}^{\left(\frac{2}{2}\right)}}}}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\]
    8. Simplified11.9

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{{z}^{\left(\frac{2}{2}\right)}}{\color{blue}{\frac{x}{z}}}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\]

    if -1.4076613045065106e+85 < z < 2.0917626344359026e+45

    1. Initial program 0.8

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Using strategy rm
    3. Applied div-inv0.9

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \color{blue}{\left(\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956\right) \cdot \frac{1}{x}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.40766130450651064 \cdot 10^{85} \lor \neg \left(z \le 2.0917626344359026 \cdot 10^{45}\right):\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{{z}^{1}}{\frac{x}{z}}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956\right) \cdot \frac{1}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2020071 +o rules:numerics
(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)))