\frac{1}{x - 1} + \frac{x}{x + 1}\begin{array}{l}
\mathbf{if}\;x \leq -1.0171651250769214:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.0121555451085444:\\
\;\;\;\;-1 - \left(x \cdot x\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}(FPCore (x) :precision binary64 (+ (/ 1.0 (- x 1.0)) (/ x (+ x 1.0))))
(FPCore (x) :precision binary64 (if (<= x -1.0171651250769214) 1.0 (if (<= x 1.0121555451085444) (- -1.0 (* (* x x) 2.0)) 1.0)))
double code(double x) {
return (1.0 / (x - 1.0)) + (x / (x + 1.0));
}
double code(double x) {
double tmp;
if (x <= -1.0171651250769214) {
tmp = 1.0;
} else if (x <= 1.0121555451085444) {
tmp = -1.0 - ((x * x) * 2.0);
} else {
tmp = 1.0;
}
return tmp;
}








Bits error versus x
Results
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 13568 |
| Alternative 2 | |
|---|---|
| Error | 0.0 |
| Cost | 1088 |
| Alternative 3 | |
|---|---|
| Error | 0.0 |
| Cost | 704 |
| Alternative 4 | |
|---|---|
| Error | 0.7 |
| Cost | 706 |
| Alternative 5 | |
|---|---|
| Error | 31.9 |
| Cost | 64 |

if x < -1.01716512507692136 or 1.0121555451085444 < x Initial program 0.7
if -1.01716512507692136 < x < 1.0121555451085444Initial program 0.0
Taylor expanded around 0 0.3
Simplified0.3
Simplified0.3
Final simplification0.5
herbie shell --seed 2021044
(FPCore (x)
:name "Asymptote B"
:precision binary64
(+ (/ 1.0 (- x 1.0)) (/ x (+ x 1.0))))