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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 6.2 |
|---|---|
| Target | 2.2 |
| Herbie | 2.5 |
if t < -1e94Initial program 11.2
Simplified1.3
Taylor expanded in z around 0 11.2
Simplified1.1
if -1e94 < t < 3.3499999999999998e-150Initial program 3.0
Simplified3.7
Taylor expanded in z around 0 3.0
if 3.3499999999999998e-150 < t Initial program 6.3
Simplified1.4
Taylor expanded in z around 0 6.3
Simplified2.6
Applied egg-rr2.8
Final simplification2.5
herbie shell --seed 2022166
(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)))