\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\begin{array}{l}
\mathbf{if}\;x \leq -4.747139500856354 \cdot 10^{+27} \lor \neg \left(x \leq 4590262224990375\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 -4.747139500856354e+27) (not (<= x 4590262224990375.0))) (- (+ 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 <= -4.747139500856354e+27) || !(x <= 4590262224990375.0)) {
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.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
if x < -4.7471395008563539e27 or 4590262224990375 < x Initial program 22.6
Simplified22.6
Taylor expanded in x around inf 0.0
if -4.7471395008563539e27 < x < 4590262224990375Initial program 0.2
Simplified0.2
Final simplification0.1
herbie shell --seed 2021313
(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)))