Average Error: 10.2 → 0.2
Time: 1.2m
Precision: 64
Internal Precision: 1088
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -141.9708462546792:\\
\;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{2}{{x}^{3}}\\
\mathbf{if}\;x \le 117.44589041658848:\\
\;\;\;\;\frac{\left(x - 2\right) - x \cdot 2}{\left(x + 1\right) \cdot x} + \frac{1}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{\frac{2}{x}}{x}}{x}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 10.2 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.2 |
|---|
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]
Derivation
- Split input into 3 regimes
if x < -141.9708462546792
Initial program 20.5
\[\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}}\]
- Using strategy
rm Applied div-inv0.1
\[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\color{blue}{2 \cdot \frac{1}{x}}}{x \cdot x}\]
Applied associate-/l*0.5
\[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \color{blue}{\frac{2}{\frac{x \cdot x}{\frac{1}{x}}}}\]
Applied simplify0.4
\[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{2}{\color{blue}{{x}^{3}}}\]
if -141.9708462546792 < x < 117.44589041658848
Initial program 0.1
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
- Using strategy
rm Applied frac-sub0.1
\[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
Applied simplify0.1
\[\leadsto \frac{\color{blue}{\left(x - 2\right) - x \cdot 2}}{\left(x + 1\right) \cdot x} + \frac{1}{x - 1}\]
if 117.44589041658848 < x
Initial program 20.5
\[\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}}\]
- 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}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2018198
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))