Average Error: 5.5 → 1.3
Time: 3.4m
Precision: 64
Internal Precision: 384
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 6031115.829667645:\\ \;\;\;\;\frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right) - \left(z \cdot 0.0027777777777778 - 0.083333333333333\right)}{x} + \frac{\left(\left(x \cdot x - 0.5 \cdot 0.5\right) \cdot \log x\right) \cdot \left(x + 0.91893853320467\right) - \left(x + 0.5\right) \cdot \left(x \cdot x - 0.91893853320467 \cdot 0.91893853320467\right)}{\left(x + 0.5\right) \cdot \left(x + 0.91893853320467\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right) + \left(\left(x - 0.5\right) \cdot \log x - \left(x - 0.91893853320467\right)\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.5
Target1.3
Herbie1.3
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 6031115.829667645

    1. Initial program 0.2

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    2. Taylor expanded around 0 0.2

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\color{blue}{\left(\left(0.0007936500793651 \cdot {z}^{2} + {z}^{2} \cdot y\right) - 0.0027777777777778 \cdot z\right)} + 0.083333333333333}{x}\]
    3. Applied simplify0.2

      \[\leadsto \color{blue}{\frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right) - \left(z \cdot 0.0027777777777778 - 0.083333333333333\right)}{x} + \left(\left(x - 0.5\right) \cdot \log x - \left(x - 0.91893853320467\right)\right)}\]
    4. Using strategy rm
    5. Applied flip--0.2

      \[\leadsto \frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right) - \left(z \cdot 0.0027777777777778 - 0.083333333333333\right)}{x} + \left(\left(x - 0.5\right) \cdot \log x - \color{blue}{\frac{x \cdot x - 0.91893853320467 \cdot 0.91893853320467}{x + 0.91893853320467}}\right)\]
    6. Applied flip--0.2

      \[\leadsto \frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right) - \left(z \cdot 0.0027777777777778 - 0.083333333333333\right)}{x} + \left(\color{blue}{\frac{x \cdot x - 0.5 \cdot 0.5}{x + 0.5}} \cdot \log x - \frac{x \cdot x - 0.91893853320467 \cdot 0.91893853320467}{x + 0.91893853320467}\right)\]
    7. Applied associate-*l/0.2

      \[\leadsto \frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right) - \left(z \cdot 0.0027777777777778 - 0.083333333333333\right)}{x} + \left(\color{blue}{\frac{\left(x \cdot x - 0.5 \cdot 0.5\right) \cdot \log x}{x + 0.5}} - \frac{x \cdot x - 0.91893853320467 \cdot 0.91893853320467}{x + 0.91893853320467}\right)\]
    8. Applied frac-sub0.2

      \[\leadsto \frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right) - \left(z \cdot 0.0027777777777778 - 0.083333333333333\right)}{x} + \color{blue}{\frac{\left(\left(x \cdot x - 0.5 \cdot 0.5\right) \cdot \log x\right) \cdot \left(x + 0.91893853320467\right) - \left(x + 0.5\right) \cdot \left(x \cdot x - 0.91893853320467 \cdot 0.91893853320467\right)}{\left(x + 0.5\right) \cdot \left(x + 0.91893853320467\right)}}\]

    if 6031115.829667645 < x

    1. Initial program 9.4

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    2. Taylor expanded around inf 9.5

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\left(\left(0.0007936500793651 \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)}\]
    3. Applied simplify2.1

      \[\leadsto \color{blue}{\frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right) + \left(\left(x - 0.5\right) \cdot \log x - \left(x - 0.91893853320467\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 3.4m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z)
  :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"

  :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)))