\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}double f(double x) {
double r117229 = 1.0;
double r117230 = x;
double r117231 = r117230 + r117229;
double r117232 = r117229 / r117231;
double r117233 = 2.0;
double r117234 = r117233 / r117230;
double r117235 = r117232 - r117234;
double r117236 = r117230 - r117229;
double r117237 = r117229 / r117236;
double r117238 = r117235 + r117237;
return r117238;
}
double f(double x) {
double r117239 = 2.0;
double r117240 = x;
double r117241 = 1.0;
double r117242 = r117240 + r117241;
double r117243 = r117242 * r117240;
double r117244 = r117239 / r117243;
double r117245 = r117240 - r117241;
double r117246 = r117244 / r117245;
return r117246;
}




Bits error versus x
Results
| Original | 10.0 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 10.0
rmApplied frac-sub26.2
Applied frac-add25.7
Simplified26.1
Taylor expanded around 0 0.2
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019344 +o rules:numerics
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))