(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ x (/ z y)) x))) (if (<= z -1e+73) t_0 (if (<= z 16000000.0) (- (/ (fma x y x) z) x) t_0))))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
double code(double x, double y, double z) {
double t_0 = (x / (z / y)) - x;
double tmp;
if (z <= -1e+73) {
tmp = t_0;
} else if (z <= 16000000.0) {
tmp = (fma(x, y, x) / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function code(x, y, z) t_0 = Float64(Float64(x / Float64(z / y)) - x) tmp = 0.0 if (z <= -1e+73) tmp = t_0; elseif (z <= 16000000.0) tmp = Float64(Float64(fma(x, y, x) / z) - x); else tmp = t_0; 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_] := Block[{t$95$0 = N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[z, -1e+73], t$95$0, If[LessEqual[z, 16000000.0], N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
t_0 := \frac{x}{\frac{z}{y}} - x\\
\mathbf{if}\;z \leq -1 \cdot 10^{+73}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 16000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 9.9 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if z < -9.99999999999999983e72 or 1.6e7 < z Initial program 18.1
Simplified5.7
Applied egg-rr5.7
Taylor expanded in y around inf 5.8
Simplified0.2
if -9.99999999999999983e72 < z < 1.6e7Initial program 0.6
Simplified0.3
Final simplification0.2
herbie shell --seed 2022166
(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))