(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 (- z t) (/ y a) x)))
(if (<= (- z t) -1.8034715821452683e-59)
t_1
(if (<= (- z t) 1.2397713062370286e+28)
(+ x (* y (* (- z t) (/ 1.0 a))))
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((z - t), (y / a), x);
double tmp;
if ((z - t) <= -1.8034715821452683e-59) {
tmp = t_1;
} else if ((z - t) <= 1.2397713062370286e+28) {
tmp = x + (y * ((z - t) * (1.0 / a)));
} 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(z - t), Float64(y / a), x) tmp = 0.0 if (Float64(z - t) <= -1.8034715821452683e-59) tmp = t_1; elseif (Float64(z - t) <= 1.2397713062370286e+28) tmp = Float64(x + Float64(y * Float64(Float64(z - t) * Float64(1.0 / a)))); 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[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[N[(z - t), $MachinePrecision], -1.8034715821452683e-59], t$95$1, If[LessEqual[N[(z - t), $MachinePrecision], 1.2397713062370286e+28], N[(x + N[(y * N[(N[(z - t), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{if}\;z - t \leq -1.8034715821452683 \cdot 10^{-59}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z - t \leq 1.2397713062370286 \cdot 10^{+28}:\\
\;\;\;\;x + y \cdot \left(\left(z - t\right) \cdot \frac{1}{a}\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 | 6.2 |
|---|---|
| Target | 0.7 |
| Herbie | 1.5 |
if (-.f64 z t) < -1.8034715821452683e-59 or 1.2397713062370286e28 < (-.f64 z t) Initial program 8.3
Simplified7.9
Taylor expanded in y around 0 8.3
Simplified1.7
if -1.8034715821452683e-59 < (-.f64 z t) < 1.2397713062370286e28Initial program 0.8
Applied add-cube-cbrt_binary641.2
Applied times-frac_binary642.4
Applied div-inv_binary642.4
Applied associate-*l*_binary641.3
Simplified1.0
Final simplification1.5
herbie shell --seed 2022131
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
: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)))