Average Error: 5.8 → 1.3
Time: 2.3m
Precision: 64
Internal precision: 128
\[\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 6163318119635.77:\\
\;\;\;\;{\left(\sqrt[3]{\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467}\right)}^3 + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(0.91893853320467 + \left(x - 0.5\right) \cdot \log x\right) - \left(\left(x - \frac{y \cdot z}{\frac{x}{z}}\right) + \frac{z}{x} \cdot \left(0.0027777777777778 - 0.0007936500793651 \cdot z\right)\right)\\
\end{array}\]
Target
| Original | 5.8 |
| Comparison | 1.3 |
| Herbie | 1.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
- Split input into 2 regimes.
-
if x < 6163318119635.77
Initial program 0.1
\[\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}\]
- Using strategy
rm
Applied add-cube-cbrt 0.2
\[\leadsto \color{blue}{{\left(\sqrt[3]{\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467}\right)}^3} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
if 6163318119635.77 < x
Initial program 10.0
\[\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}\]
Applied taylor 10.1
\[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\left(\frac{y \cdot {z}^2}{x} + 0.0007936500793651 \cdot \frac{{z}^2}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)\]
Taylor expanded around inf 10.1
\[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\left(\left(\frac{y \cdot {z}^2}{x} + 0.0007936500793651 \cdot \frac{{z}^2}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)}\]
Applied simplify 2.1
\[\leadsto \color{blue}{\left(0.91893853320467 + \left(x - 0.5\right) \cdot \log x\right) - \left(\left(x - \frac{y \cdot z}{\frac{x}{z}}\right) + \frac{z}{x} \cdot \left(0.0027777777777778 - 0.0007936500793651 \cdot z\right)\right)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(2420262585 3535420843 887897025 2320449328 1192482199 1130526203)'
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
: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)))