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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 5.9 |
|---|---|
| Target | 0.6 |
| Herbie | 1.8 |
if (-.f64 z t) < -1.8034715821452683e-59 or 4.204200830287601e-132 < (-.f64 z t) Initial program 6.9
Simplified6.9
Taylor expanded in y around 0 6.9
Simplified1.9
if -1.8034715821452683e-59 < (-.f64 z t) < 4.204200830287601e-132Initial program 0.9
Simplified1.0
Final simplification1.8
herbie shell --seed 2022131
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
:precision binary64
:herbie-target
(if (< y -1.0761266216389975e-10) (- x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))
(- x (/ (* y (- z t)) a)))