(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- z x) (/ y t) x)))
(if (<= x -2.2e-118)
t_1
(if (<= x 3.3e-122) (fma y (- (/ z t) (/ x t)) x) t_1))))double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
double t_1 = fma((z - x), (y / t), x);
double tmp;
if (x <= -2.2e-118) {
tmp = t_1;
} else if (x <= 3.3e-122) {
tmp = fma(y, ((z / t) - (x / t)), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function code(x, y, z, t) t_1 = fma(Float64(z - x), Float64(y / t), x) tmp = 0.0 if (x <= -2.2e-118) tmp = t_1; elseif (x <= 3.3e-122) tmp = fma(y, Float64(Float64(z / t) - Float64(x / t)), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -2.2e-118], t$95$1, If[LessEqual[x, 3.3e-122], N[(y * N[(N[(z / t), $MachinePrecision] - N[(x / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - x, \frac{y}{t}, x\right)\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{-118}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-122}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t} - \frac{x}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 6.5 |
|---|---|
| Target | 1.9 |
| Herbie | 2.1 |
if x < -2.19999999999999984e-118 or 3.29999999999999999e-122 < x Initial program 7.1
Simplified0.6
if -2.19999999999999984e-118 < x < 3.29999999999999999e-122Initial program 5.4
Simplified4.5
Taylor expanded in z around 0 5.4
Simplified5.0
Applied egg-rr5.6
Applied egg-rr5.0
Final simplification2.1
herbie shell --seed 2022162
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:herbie-target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))