\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\begin{array}{l}
\mathbf{if}\;x \leq -1.1391710068553142 \cdot 10^{+38} \lor \neg \left(x \leq 16483647715.548288\right):\\
\;\;\;\;\left(1 + \frac{x}{y}\right) - \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, \frac{x}{y}, x\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 -1.1391710068553142e+38) (not (<= x 16483647715.548288))) (- (+ 1.0 (/ x y)) (/ 1.0 y)) (/ (fma x (/ x y) x) (+ 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 <= -1.1391710068553142e+38) || !(x <= 16483647715.548288)) {
tmp = (1.0 + (x / y)) - (1.0 / y);
} else {
tmp = fma(x, (x / y), x) / (x + 1.0);
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 9.4 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
if x < -1.1391710068553142e38 or 16483647715.5482883 < x Initial program 24.1
Simplified24.1
Taylor expanded in x around inf 0.1
if -1.1391710068553142e38 < x < 16483647715.5482883Initial program 0.2
Simplified0.1
Applied *-un-lft-identity_binary640.1
Final simplification0.1
herbie shell --seed 2022068
(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)))