(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* y (- z t))))
(if (<= t_1 -4e+279)
(+ x (* (/ y a) (- t z)))
(if (<= t_1 4e+91) (+ x (/ (* y (- t z)) a)) (- x (/ y (/ a (- z t))))))))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 = y * (z - t);
double tmp;
if (t_1 <= -4e+279) {
tmp = x + ((y / a) * (t - z));
} else if (t_1 <= 4e+91) {
tmp = x + ((y * (t - z)) / a);
} else {
tmp = x - (y / (a / (z - t)));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y * (z - t)) / a)
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = y * (z - t)
if (t_1 <= (-4d+279)) then
tmp = x + ((y / a) * (t - z))
else if (t_1 <= 4d+91) then
tmp = x + ((y * (t - z)) / a)
else
tmp = x - (y / (a / (z - t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = y * (z - t);
double tmp;
if (t_1 <= -4e+279) {
tmp = x + ((y / a) * (t - z));
} else if (t_1 <= 4e+91) {
tmp = x + ((y * (t - z)) / a);
} else {
tmp = x - (y / (a / (z - t)));
}
return tmp;
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
def code(x, y, z, t, a): t_1 = y * (z - t) tmp = 0 if t_1 <= -4e+279: tmp = x + ((y / a) * (t - z)) elif t_1 <= 4e+91: tmp = x + ((y * (t - z)) / a) else: tmp = x - (y / (a / (z - t))) 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 = Float64(y * Float64(z - t)) tmp = 0.0 if (t_1 <= -4e+279) tmp = Float64(x + Float64(Float64(y / a) * Float64(t - z))); elseif (t_1 <= 4e+91) tmp = Float64(x + Float64(Float64(y * Float64(t - z)) / a)); else tmp = Float64(x - Float64(y / Float64(a / Float64(z - t)))); end return tmp end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
function tmp_2 = code(x, y, z, t, a) t_1 = y * (z - t); tmp = 0.0; if (t_1 <= -4e+279) tmp = x + ((y / a) * (t - z)); elseif (t_1 <= 4e+91) tmp = x + ((y * (t - z)) / a); else tmp = x - (y / (a / (z - t))); end tmp_2 = 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[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+279], N[(x + N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+91], N[(x + N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{+279}:\\
\;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{+91}:\\
\;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\
\end{array}
Results
| Original | 6.3 |
|---|---|
| Target | 0.8 |
| Herbie | 0.9 |
if (*.f64 y (-.f64 z t)) < -4.00000000000000023e279Initial program 49.4
Applied egg-rr0.3
Applied egg-rr0.2
Applied egg-rr0.2
if -4.00000000000000023e279 < (*.f64 y (-.f64 z t)) < 4.00000000000000032e91Initial program 0.5
if 4.00000000000000032e91 < (*.f64 y (-.f64 z t)) Initial program 16.4
Taylor expanded in z around 0 16.4
Simplified2.6
Final simplification0.9
herbie shell --seed 2022190
(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)))