Average Error: 6.1 → 5.2
Time: 8.2s
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 2.45365975757305463 \cdot 10^{122}:\\ \;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\frac{\mathsf{fma}\left({z}^{2}, 7.93650079365100015 \cdot 10^{-4}, 0.0833333333333329956 - 0.0027777777777778 \cdot z\right)}{x} - \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 2.45365975757305463 \cdot 10^{122}:\\
\;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - \left(x - 0.91893853320467001\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\frac{\mathsf{fma}\left({z}^{2}, 7.93650079365100015 \cdot 10^{-4}, 0.0833333333333329956 - 0.0027777777777778 \cdot z\right)}{x} - \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 temp;
	if ((x <= 2.4536597575730546e+122)) {
		temp = (((log(x) * ((x * x) - (0.5 * 0.5))) / (x + 0.5)) + ((fma((((y + 0.0007936500793651) * z) - 0.0027777777777778), z, 0.083333333333333) / x) - (x - 0.91893853320467)));
	} else {
		temp = ((log(x) * (x - 0.5)) + ((fma(pow(z, 2.0), 0.0007936500793651, (0.083333333333333 - (0.0027777777777778 * z))) / x) - (x - 0.91893853320467)));
	}
	return temp;
}

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.1
Target1.3
Herbie5.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 2 regimes
  2. if x < 2.4536597575730546e+122

    1. Initial program 1.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. Simplified1.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. Using strategy rm
    4. Applied fma-udef1.5

      \[\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 *-un-lft-identity1.5

      \[\leadsto \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}{\color{blue}{1 \cdot x}} - \left(x - 0.91893853320467001\right)\right)\]
    7. Applied associate-/r*1.5

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

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

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

      \[\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(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - \left(x - 0.91893853320467001\right)\right)\]

    if 2.4536597575730546e+122 < x

    1. Initial program 13.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. Simplified13.7

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

      \[\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 *-un-lft-identity13.8

      \[\leadsto \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}{\color{blue}{1 \cdot x}} - \left(x - 0.91893853320467001\right)\right)\]
    7. Applied associate-/r*13.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 2.45365975757305463 \cdot 10^{122}:\\ \;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\frac{\mathsf{fma}\left({z}^{2}, 7.93650079365100015 \cdot 10^{-4}, 0.0833333333333329956 - 0.0027777777777778 \cdot z\right)}{x} - \left(x - 0.91893853320467001\right)\right)\\ \end{array}\]

Reproduce

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