Average Error: 10.2 → 0.1
Time: 22.3s
Precision: 64
Internal Precision: 1152
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.3644885705085021:\\
\;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\
\mathbf{if}\;x \le 41773.77440307341:\\
\;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\
\end{array}\]
Target
| Original | 10.2 |
|---|
| Target | 0.3 |
|---|
| Herbie | 0.1 |
|---|
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]
Derivation
- Split input into 2 regimes
if x < -1.3644885705085021 or 41773.77440307341 < x
Initial program 20.0
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Taylor expanded around inf 0.4
\[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{5}} + 2 \cdot \frac{1}{{x}^{7}}\right)}\]
Applied simplify0.1
\[\leadsto \color{blue}{\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}}\]
if -1.3644885705085021 < x < 41773.77440307341
Initial program 0.1
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(151349756 408087815 228312487 2538703040 1980610373 1250971417)'
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))