Average Error: 6.2 → 3.2
Time: 11.0s
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}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -2.050097413200735 \cdot 10^{237}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 5.11078155891317075 \cdot 10^{291}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\frac{x}{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.400000000000006406 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)\right)} - \left(x - 0.91893853320467001\right)\right)\\ \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}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -2.050097413200735 \cdot 10^{237}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\

\mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 5.11078155891317075 \cdot 10^{291}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\frac{x}{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}} - \left(x - 0.91893853320467001\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.400000000000006406 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)\right)} - \left(x - 0.91893853320467001\right)\right)\\

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (((double) (((double) (((double) (x - 0.5)) * ((double) log(x)))) - x)) + 0.91893853320467)) + ((double) (((double) (((double) (((double) (((double) (((double) (y + 0.0007936500793651)) * z)) - 0.0027777777777778)) * z)) + 0.083333333333333)) / x))));
}
double code(double x, double y, double z) {
	double VAR;
	if ((((double) (((double) (((double) (((double) (y + 0.0007936500793651)) * z)) - 0.0027777777777778)) * z)) <= -2.050097413200735e+237)) {
		VAR = ((double) fma(((double) (((double) pow(z, 2.0)) / x)), y, ((double) (((double) (0.0007936500793651 * ((double) (((double) pow(z, 2.0)) / x)))) - ((double) fma(((double) log(((double) (1.0 / x)))), x, x))))));
	} else {
		double VAR_1;
		if ((((double) (((double) (((double) (((double) (y + 0.0007936500793651)) * z)) - 0.0027777777777778)) * z)) <= 5.110781558913171e+291)) {
			VAR_1 = ((double) fma(((double) log(x)), ((double) (x - 0.5)), ((double) (((double) (1.0 / ((double) (x / ((double) (((double) (((double) (((double) (((double) (y + 0.0007936500793651)) * z)) - 0.0027777777777778)) * z)) + 0.083333333333333)))))) - ((double) (x - 0.91893853320467))))));
		} else {
			VAR_1 = ((double) fma(((double) log(x)), ((double) (x - 0.5)), ((double) (((double) (1.0 / ((double) fma(((double) (0.4000000000000064 * x)), z, ((double) (((double) (12.000000000000048 * x)) - ((double) (0.10095227809524161 * ((double) (x * ((double) pow(z, 2.0)))))))))))) - ((double) (x - 0.91893853320467))))));
		}
		VAR = VAR_1;
	}
	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.2
Target1.2
Herbie3.2
\[\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 3 regimes
  2. if (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) < -2.050097413200735e+237

    1. Initial program 43.3

      \[\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. Simplified43.2

      \[\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 inf 43.2

      \[\leadsto \color{blue}{\left(7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - \left(x + x \cdot \log \left(\frac{1}{x}\right)\right)}\]
    4. Simplified14.2

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

    if -2.050097413200735e+237 < (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) < 5.110781558913171e+291

    1. Initial program 0.2

      \[\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. Simplified0.2

      \[\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. Using strategy rm
    4. Applied clear-num0.3

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

    if 5.110781558913171e+291 < (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)

    1. Initial program 57.4

      \[\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. Simplified57.4

      \[\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. Using strategy rm
    4. Applied clear-num57.4

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

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\color{blue}{\left(0.400000000000006406 \cdot \left(x \cdot z\right) + 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}} - \left(x - 0.91893853320467001\right)\right)\]
    6. Simplified31.3

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\color{blue}{\mathsf{fma}\left(0.400000000000006406 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)\right)}} - \left(x - 0.91893853320467001\right)\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -2.050097413200735 \cdot 10^{237}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 5.11078155891317075 \cdot 10^{291}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\frac{x}{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.400000000000006406 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)\right)} - \left(x - 0.91893853320467001\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +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)))