Average Error: 5.5 → 1.8
Time: 3.1m
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 5277226.618941849:\\ \;\;\;\;\log \left(\frac{{x}^{\left(x - 0.5\right)}}{e^{x - 0.91893853320467}}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\ \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.8
\[\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 < 5277226.618941849

    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. Using strategy rm
    3. Applied add-log-exp1.4

      \[\leadsto \color{blue}{\log \left(e^{\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}\]
    4. Applied simplify1.4

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

    if 5277226.618941849 < 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.1m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(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)))