Average Error: 5.8 → 2.4
Time: 6.1s
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 41606032291.8435135:\\ \;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(y, {z}^{2}, 7.93650079365100015 \cdot 10^{-4} \cdot {z}^{2} - 0.0027777777777778 \cdot z\right) + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{elif}\;x \le 6.52148871011840621 \cdot 10^{132}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(\frac{{z}^{2}}{x}, y + 7.93650079365100015 \cdot 10^{-4}, -0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(z \cdot 0.400000000000006406, x, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\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 41606032291.8435135:\\
\;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(y, {z}^{2}, 7.93650079365100015 \cdot 10^{-4} \cdot {z}^{2} - 0.0027777777777778 \cdot z\right) + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(z \cdot 0.400000000000006406, x, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\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 <= 41606032291.84351)) {
		VAR = (((log(x) * ((x * x) - (0.5 * 0.5))) / (x + 0.5)) + (((fma(y, pow(z, 2.0), ((0.0007936500793651 * pow(z, 2.0)) - (0.0027777777777778 * z))) + 0.083333333333333) / x) - (x - 0.91893853320467)));
	} else {
		double VAR_1;
		if ((x <= 6.521488710118406e+132)) {
			VAR_1 = fma(log(x), (x - 0.5), (fma((pow(z, 2.0) / x), (y + 0.0007936500793651), -(0.0027777777777778 * (z / x))) - (x - 0.91893853320467)));
		} else {
			VAR_1 = fma(log(x), (x - 0.5), ((1.0 / fma((z * 0.4000000000000064), x, (x * (12.000000000000048 - (pow(z, 2.0) * 0.10095227809524161))))) - (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.4
\[\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 < 41606032291.84351

    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. Taylor expanded around 0 0.1

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

      \[\leadsto \log x \cdot \left(x - 0.5\right) + \left(\frac{\color{blue}{\mathsf{fma}\left(y, {z}^{2}, 7.93650079365100015 \cdot 10^{-4} \cdot {z}^{2} - 0.0027777777777778 \cdot z\right)} + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\]
    7. Using strategy rm
    8. Applied flip--0.1

      \[\leadsto \log x \cdot \color{blue}{\frac{x \cdot x - 0.5 \cdot 0.5}{x + 0.5}} + \left(\frac{\mathsf{fma}\left(y, {z}^{2}, 7.93650079365100015 \cdot 10^{-4} \cdot {z}^{2} - 0.0027777777777778 \cdot z\right) + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\]
    9. Applied associate-*r/0.1

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

    if 41606032291.84351 < x < 6.521488710118406e+132

    1. Initial program 5.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. Simplified5.3

      \[\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-num5.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)\]
    5. Taylor expanded around inf 5.3

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

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

    if 6.521488710118406e+132 < x

    1. Initial program 13.0

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

      \[\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 11.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. Simplified4.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 41606032291.8435135:\\ \;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(y, {z}^{2}, 7.93650079365100015 \cdot 10^{-4} \cdot {z}^{2} - 0.0027777777777778 \cdot z\right) + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{elif}\;x \le 6.52148871011840621 \cdot 10^{132}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(\frac{{z}^{2}}{x}, y + 7.93650079365100015 \cdot 10^{-4}, -0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(z \cdot 0.400000000000006406, x, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\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)))