\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\begin{array}{l}
\mathbf{if}\;x \leq -7952346188264682 \lor \neg \left(x \leq 18038856771156356\right):\\
\;\;\;\;\left(1 + \frac{x}{y}\right) - \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 + \frac{x}{y}\right)}{x + 1}\\
\end{array}(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
(FPCore (x y) :precision binary64 (if (or (<= x -7952346188264682.0) (not (<= x 18038856771156356.0))) (- (+ 1.0 (/ x y)) (/ 1.0 y)) (/ (* x (+ 1.0 (/ x y))) (+ x 1.0))))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
double code(double x, double y) {
double tmp;
if ((x <= -7952346188264682.0) || !(x <= 18038856771156356.0)) {
tmp = (1.0 + (x / y)) - (1.0 / y);
} else {
tmp = (x * (1.0 + (x / y))) / (x + 1.0);
}
return tmp;
}












Bits error versus x












Bits error versus y
Results
| Original | 9.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 704 |
| Alternative 2 | |
|---|---|
| Error | 1.3 |
| Cost | 904 |
| Alternative 3 | |
|---|---|
| Error | 10.6 |
| Cost | 1860 |
| Alternative 4 | |
|---|---|
| Error | 19.2 |
| Cost | 2246 |
| Alternative 5 | |
|---|---|
| Error | 18.2 |
| Cost | 648 |
| Alternative 6 | |
|---|---|
| Error | 19.0 |
| Cost | 1797 |
| Alternative 7 | |
|---|---|
| Error | 27.6 |
| Cost | 706 |
| Alternative 8 | |
|---|---|
| Error | 53.5 |
| Cost | 64 |

if x < -7952346188264682 or 18038856771156356 < x Initial program 22.6
Taylor expanded around inf 0.0
Simplified0.0
Simplified0.0
if -7952346188264682 < x < 18038856771156356Initial program 0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2021044
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))