Average Error: 5.8 → 2.5
Time: 9.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}\;x \le 3175502898053929:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \mathsf{fma}\left(\mathsf{fma}\left(-0.5, 1, 0.5\right), \log x, \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)\\ \mathbf{elif}\;x \le 4.7841962310635935 \cdot 10^{133}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\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}\;x \le 3175502898053929:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \mathsf{fma}\left(\mathsf{fma}\left(-0.5, 1, 0.5\right), \log x, \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)\\

\mathbf{elif}\;x \le 4.7841962310635935 \cdot 10^{133}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\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 (((((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 ((x <= 3175502898053929.0)) {
		VAR = ((fma(sqrt(x), sqrt(x), -(sqrt(0.5) * sqrt(0.5))) * log(x)) + fma(fma(-0.5, 1.0, 0.5), log(x), (((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x) - (x - 0.91893853320467))));
	} else {
		double VAR_1;
		if ((x <= 4.784196231063594e+133)) {
			VAR_1 = fma((pow(z, 2.0) / x), y, ((0.0007936500793651 * (pow(z, 2.0) / x)) - fma(log((1.0 / x)), x, x)));
		} else {
			VAR_1 = ((log(x) * (x - 0.5)) + ((1.0 / fma((0.4000000000000064 * x), z, ((12.000000000000048 * x) - (0.10095227809524161 * (x * pow(z, 2.0)))))) - (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

Original5.8
Target1.1
Herbie2.5
\[\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 x < 3175502898053929.0

    1. Initial program 0.1

      \[\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.1

      \[\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 fma-udef0.1

      \[\leadsto \color{blue}{\log x \cdot \left(x - 0.5\right) + \left(\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)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.1

      \[\leadsto \log x \cdot \left(x - \color{blue}{\sqrt{0.5} \cdot \sqrt{0.5}}\right) + \left(\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)\]
    7. Applied add-sqr-sqrt0.2

      \[\leadsto \log x \cdot \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \sqrt{0.5} \cdot \sqrt{0.5}\right) + \left(\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)\]
    8. Applied prod-diff0.2

      \[\leadsto \log x \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) + \mathsf{fma}\left(-\sqrt{0.5}, \sqrt{0.5}, \sqrt{0.5} \cdot \sqrt{0.5}\right)\right)} + \left(\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)\]
    9. Applied distribute-rgt-in0.2

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \mathsf{fma}\left(-\sqrt{0.5}, \sqrt{0.5}, \sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x\right)} + \left(\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)\]
    10. Applied associate-+l+0.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \left(\mathsf{fma}\left(-\sqrt{0.5}, \sqrt{0.5}, \sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \left(\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)\right)}\]
    11. Simplified0.2

      \[\leadsto \mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(-0.5, 1, 0.5\right), \log x, \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)}\]

    if 3175502898053929.0 < x < 4.784196231063594e+133

    1. Initial program 5.5

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

      \[\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 5.6

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

      \[\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 4.784196231063594e+133 < x

    1. Initial program 13.1

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

      \[\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 fma-udef13.1

      \[\leadsto \color{blue}{\log x \cdot \left(x - 0.5\right) + \left(\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)}\]
    5. Using strategy rm
    6. Applied clear-num13.1

      \[\leadsto \log x \cdot \left(x - 0.5\right) + \left(\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)\]
    7. Taylor expanded around 0 11.4

      \[\leadsto \log x \cdot \left(x - 0.5\right) + \left(\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)\]
    8. Simplified4.9

      \[\leadsto \log x \cdot \left(x - 0.5\right) + \left(\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 simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 3175502898053929:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \log x + \mathsf{fma}\left(\mathsf{fma}\left(-0.5, 1, 0.5\right), \log x, \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)\\ \mathbf{elif}\;x \le 4.7841962310635935 \cdot 10^{133}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\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 2020078 +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)))