(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t) :precision binary64 (if (<= t -1e-68) (fma y (- (/ z t) (/ x t)) x) (if (<= t 1e-97) (+ x (/ (* y (- z x)) t)) (fma (- z x) (/ y t) 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-68) {
tmp = fma(y, ((z / t) - (x / t)), x);
} else if (t <= 1e-97) {
tmp = x + ((y * (z - x)) / t);
} else {
tmp = fma((z - x), (y / t), 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-68) tmp = fma(y, Float64(Float64(z / t) - Float64(x / t)), x); elseif (t <= 1e-97) tmp = Float64(x + Float64(Float64(y * Float64(z - x)) / t)); else tmp = fma(Float64(z - x), Float64(y / t), 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-68], N[(y * N[(N[(z / t), $MachinePrecision] - N[(x / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 1e-97], N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision] + x), $MachinePrecision]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -1 \cdot 10^{-68}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t} - \frac{x}{t}, x\right)\\
\mathbf{elif}\;t \leq 10^{-97}:\\
\;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)\\
\end{array}
| Original | 6.6 |
|---|---|
| Target | 2.0 |
| Herbie | 1.6 |
if t < -1.00000000000000007e-68Initial program 8.0
Taylor expanded in z around 0 8.0
Simplified1.5
Applied egg-rr8.0
Taylor expanded in y around 0 1.6
Simplified1.6
if -1.00000000000000007e-68 < t < 1.00000000000000004e-97Initial program 2.3
if 1.00000000000000004e-97 < t Initial program 8.0
Simplified1.2
Final simplification1.6
herbie shell --seed 2022210
(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)))