(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z) :precision binary64 (if (<= z 1e+82) (- (/ (fma x y x) z) x) (* x (+ -1.0 (/ y z)))))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
double code(double x, double y, double z) {
double tmp;
if (z <= 1e+82) {
tmp = (fma(x, y, x) / z) - x;
} else {
tmp = x * (-1.0 + (y / z));
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function code(x, y, z) tmp = 0.0 if (z <= 1e+82) tmp = Float64(Float64(fma(x, y, x) / z) - x); else tmp = Float64(x * Float64(-1.0 + Float64(y / z))); end return tmp end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, 1e+82], N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+82}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.5 |
|---|---|
| Target | 0.4 |
| Herbie | 2.0 |
if z < 9.9999999999999996e81Initial program 7.3
Simplified2.6
if 9.9999999999999996e81 < z Initial program 21.3
Simplified8.0
Taylor expanded in y around inf 8.0
Simplified3.2
Taylor expanded in x around -inf 0.1
Final simplification2.0
herbie shell --seed 2022159
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))