(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ y z) (/ 1.0 z))) (t_1 (/ (* x (+ (- y z) 1.0)) z)))
(if (<= t_1 (- INFINITY))
(* x (+ (* (cbrt t_0) (cbrt (pow t_0 2.0))) -1.0))
(if (<= t_1 6e+304) (- (/ (fma x y x) z) x) (- (* y (/ x z)) x)))))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 = (y / z) + (1.0 / z);
double t_1 = (x * ((y - z) + 1.0)) / z;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x * ((cbrt(t_0) * cbrt(pow(t_0, 2.0))) + -1.0);
} else if (t_1 <= 6e+304) {
tmp = (fma(x, y, x) / z) - x;
} else {
tmp = (y * (x / z)) - x;
}
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(y / z) + Float64(1.0 / z)) t_1 = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x * Float64(Float64(cbrt(t_0) * cbrt((t_0 ^ 2.0))) + -1.0)); elseif (t_1 <= 6e+304) tmp = Float64(Float64(fma(x, y, x) / z) - x); else tmp = Float64(Float64(y * Float64(x / z)) - x); 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[(y / z), $MachinePrecision] + N[(1.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x * N[(N[(N[Power[t$95$0, 1/3], $MachinePrecision] * N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 6e+304], N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]]]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
t_0 := \frac{y}{z} + \frac{1}{z}\\
t_1 := \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x \cdot \left(\sqrt[3]{t_0} \cdot \sqrt[3]{{t_0}^{2}} + -1\right)\\
\mathbf{elif}\;t_1 \leq 6 \cdot 10^{+304}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z} - x\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.7 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -inf.0Initial program 64.0
Simplified20.6
Taylor expanded in x around 0 0.0
Applied egg-rr2.3
if -inf.0 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 5.9999999999999996e304Initial program 0.1
Simplified0.1
if 5.9999999999999996e304 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 62.5
Simplified21.6
Taylor expanded in y around inf 22.4
Simplified0.8
Final simplification0.3
herbie shell --seed 2022160
(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))