Average Error: 10.2 → 0.3
Time: 7.7s
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 -0.0004101029468956529:\\
\;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{2}{{x}^3}\\
\mathbf{if}\;x \le 26943675.89880948:\\
\;\;\;\;\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}^2}}{x}\\
\end{array}\]
Target
| Original | 10.2 |
| Comparison | 0.5 |
| Herbie | 0.3 |
\[ \frac{2}{x \cdot \left({x}^2 - 1\right)} \]
Derivation
- Split input into 3 regimes.
-
if x < -0.0004101029468956529
Initial program 21.0
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Applied taylor 0.5
\[\leadsto 2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{5}} + 2 \cdot \frac{1}{{x}^{7}}\right)\]
Taylor expanded around inf 0.5
\[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{5}} + 2 \cdot \frac{1}{{x}^{7}}\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}}\]
Applied simplify 0.5
\[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \color{blue}{\frac{2}{{x}^3}}\]
if -0.0004101029468956529 < x < 26943675.89880948
Initial program 0.3
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
if 26943675.89880948 < x
Initial program 18.9
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Applied taylor 0.4
\[\leadsto 2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{5}} + 2 \cdot \frac{1}{{x}^{7}}\right)\]
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 simplify 0.1
\[\leadsto \color{blue}{\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}}\]
- Using strategy
rm
Applied associate-/r* 0.1
\[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \color{blue}{\frac{\frac{\frac{2}{x}}{x}}{x}}\]
Applied simplify 0.1
\[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\color{blue}{\frac{2}{{x}^2}}}{x}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1064875752 1442698706 3150723005 1316518582 2592983078 3835530843)'
(FPCore (x)
:name "3frac (problem 3.3.3)"
:target
(/ 2 (* x (- (sqr x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))