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




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.3 |
|---|---|
| Target | 0.5 |
| Herbie | 0.5 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -0.0033332639133751216Initial program 16.3
Simplified5.3
Taylor expanded in y around 0 5.3
Applied egg-rr0.1
Applied egg-rr0.1
if -0.0033332639133751216 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 1.74768709744543126e-157Initial program 0.2
Simplified0.1
Taylor expanded in y around 0 0.1
Applied egg-rr0.0
if 1.74768709744543126e-157 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 12.5
Simplified4.4
Taylor expanded in y around 0 4.4
Applied egg-rr1.1
Final simplification0.5
herbie shell --seed 2022151
(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))