Average Error: 5.5 → 1.4
Time: 4.3m
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 3.2174206549099184 \cdot 10^{+22}:\\
\;\;\;\;\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)\\
\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}\]
Target
| Original | 5.5 |
|---|
| Target | 1.3 |
|---|
| Herbie | 1.4 |
|---|
\[\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
- Split input into 2 regimes
if x < 3.2174206549099184e+22
Initial program 0.3
\[\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}\]
Taylor expanded around 0 0.3
\[\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}\]
Applied simplify0.3
\[\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)}\]
if 3.2174206549099184e+22 < x
Initial program 9.7
\[\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}\]
Taylor expanded around inf 9.8
\[\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)}\]
Applied simplify2.2
\[\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)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
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)))