
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
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
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot \left(z - t\right)}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
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
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot \left(z - t\right)}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (- z t) -2e+143) (+ x (/ (* y (- t z)) a)) (- x (/ y (/ a (- z t))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z - t) <= -2e+143) {
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
real(8) :: tmp
if ((z - t) <= (-2d+143)) 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) {
double tmp;
if ((z - t) <= -2e+143) {
tmp = x + ((y * (t - z)) / a);
} else {
tmp = x - (y / (a / (z - t)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z - t) <= -2e+143: tmp = x + ((y * (t - z)) / a) else: tmp = x - (y / (a / (z - t))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(z - t) <= -2e+143) 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_2 = code(x, y, z, t, a) tmp = 0.0; if ((z - t) <= -2e+143) tmp = x + ((y * (t - z)) / a); else tmp = x - (y / (a / (z - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z - t), $MachinePrecision], -2e+143], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - t \leq -2 \cdot 10^{+143}:\\
\;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\
\end{array}
\end{array}
if (-.f64 z t) < -2e143Initial program 98.5%
if -2e143 < (-.f64 z t) Initial program 95.9%
associate-/l*98.9%
Simplified98.9%
Final simplification98.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -8.5e+60) (not (<= z 0.0175))) (- x (/ z (/ a y))) (- x (/ y (/ (- a) t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8.5e+60) || !(z <= 0.0175)) {
tmp = x - (z / (a / y));
} else {
tmp = x - (y / (-a / 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
real(8) :: tmp
if ((z <= (-8.5d+60)) .or. (.not. (z <= 0.0175d0))) then
tmp = x - (z / (a / y))
else
tmp = x - (y / (-a / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8.5e+60) || !(z <= 0.0175)) {
tmp = x - (z / (a / y));
} else {
tmp = x - (y / (-a / t));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -8.5e+60) or not (z <= 0.0175): tmp = x - (z / (a / y)) else: tmp = x - (y / (-a / t)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -8.5e+60) || !(z <= 0.0175)) tmp = Float64(x - Float64(z / Float64(a / y))); else tmp = Float64(x - Float64(y / Float64(Float64(-a) / t))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -8.5e+60) || ~((z <= 0.0175))) tmp = x - (z / (a / y)); else tmp = x - (y / (-a / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -8.5e+60], N[Not[LessEqual[z, 0.0175]], $MachinePrecision]], N[(x - N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[((-a) / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{+60} \lor \neg \left(z \leq 0.0175\right):\\
\;\;\;\;x - \frac{z}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{-a}{t}}\\
\end{array}
\end{array}
if z < -8.50000000000000064e60 or 0.017500000000000002 < z Initial program 96.2%
associate-*r/93.5%
Simplified93.5%
Taylor expanded in z around inf 85.0%
*-commutative85.0%
associate-/r/91.4%
Applied egg-rr91.4%
if -8.50000000000000064e60 < z < 0.017500000000000002Initial program 96.8%
associate-/l*98.7%
Simplified98.7%
Taylor expanded in z around 0 90.0%
associate-*r/90.0%
neg-mul-190.0%
Simplified90.0%
Final simplification90.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -8.4e+52) (not (<= z 0.0124))) (- x (/ z (/ a y))) (+ x (* y (/ t a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8.4e+52) || !(z <= 0.0124)) {
tmp = x - (z / (a / y));
} else {
tmp = x + (y * (t / a));
}
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
real(8) :: tmp
if ((z <= (-8.4d+52)) .or. (.not. (z <= 0.0124d0))) then
tmp = x - (z / (a / y))
else
tmp = x + (y * (t / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8.4e+52) || !(z <= 0.0124)) {
tmp = x - (z / (a / y));
} else {
tmp = x + (y * (t / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -8.4e+52) or not (z <= 0.0124): tmp = x - (z / (a / y)) else: tmp = x + (y * (t / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -8.4e+52) || !(z <= 0.0124)) tmp = Float64(x - Float64(z / Float64(a / y))); else tmp = Float64(x + Float64(y * Float64(t / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -8.4e+52) || ~((z <= 0.0124))) tmp = x - (z / (a / y)); else tmp = x + (y * (t / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -8.4e+52], N[Not[LessEqual[z, 0.0124]], $MachinePrecision]], N[(x - N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+52} \lor \neg \left(z \leq 0.0124\right):\\
\;\;\;\;x - \frac{z}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\end{array}
\end{array}
if z < -8.3999999999999999e52 or 0.0123999999999999996 < z Initial program 96.2%
associate-*r/93.5%
Simplified93.5%
Taylor expanded in z around inf 85.0%
*-commutative85.0%
associate-/r/91.4%
Applied egg-rr91.4%
if -8.3999999999999999e52 < z < 0.0123999999999999996Initial program 96.8%
associate-*r/98.6%
Simplified98.6%
Taylor expanded in z around 0 90.0%
neg-mul-190.0%
distribute-neg-frac90.0%
Simplified90.0%
Final simplification90.5%
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- t z) a))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((t - z) / a));
}
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 * ((t - z) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((t - z) / a));
}
def code(x, y, z, t, a): return x + (y * ((t - z) / a))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(t - z) / a))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((t - z) / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{t - z}{a}
\end{array}
Initial program 96.6%
associate-*r/96.6%
Simplified96.6%
Final simplification96.6%
(FPCore (x y z t a) :precision binary64 (+ x (* (/ y a) (- t z))))
double code(double x, double y, double z, double t, double a) {
return x + ((y / a) * (t - z));
}
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 / a) * (t - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y / a) * (t - z));
}
def code(x, y, z, t, a): return x + ((y / a) * (t - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y / a) * Float64(t - z))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y / a) * (t - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{a} \cdot \left(t - z\right)
\end{array}
Initial program 96.6%
associate-*l/97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x y z t a) :precision binary64 (- x (* y (/ z a))))
double code(double x, double y, double z, double t, double a) {
return x - (y * (z / a));
}
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 / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - (y * (z / a));
}
def code(x, y, z, t, a): return x - (y * (z / a))
function code(x, y, z, t, a) return Float64(x - Float64(y * Float64(z / a))) end
function tmp = code(x, y, z, t, a) tmp = x - (y * (z / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(y * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \frac{z}{a}
\end{array}
Initial program 96.6%
associate-*r/96.6%
Simplified96.6%
Taylor expanded in z around inf 67.8%
Final simplification67.8%
(FPCore (x y z t a) :precision binary64 (- x (* (/ y a) z)))
double code(double x, double y, double z, double t, double a) {
return x - ((y / a) * z);
}
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 / a) * z)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y / a) * z);
}
def code(x, y, z, t, a): return x - ((y / a) * z)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y / a) * z)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y / a) * z); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{a} \cdot z
\end{array}
Initial program 96.6%
associate-*r/96.6%
Simplified96.6%
Taylor expanded in z around inf 68.5%
associate-*l/70.6%
*-commutative70.6%
Simplified70.6%
Final simplification70.6%
(FPCore (x y z t a) :precision binary64 (- x (/ z (/ a y))))
double code(double x, double y, double z, double t, double a) {
return x - (z / (a / y));
}
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 - (z / (a / y))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - (z / (a / y));
}
def code(x, y, z, t, a): return x - (z / (a / y))
function code(x, y, z, t, a) return Float64(x - Float64(z / Float64(a / y))) end
function tmp = code(x, y, z, t, a) tmp = x - (z / (a / y)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{z}{\frac{a}{y}}
\end{array}
Initial program 96.6%
associate-*r/96.6%
Simplified96.6%
Taylor expanded in z around inf 67.8%
*-commutative67.8%
associate-/r/70.8%
Applied egg-rr70.8%
Final simplification70.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ a (- z t))))
(if (< y -1.0761266216389975e-10)
(- x (/ 1.0 (/ t_1 y)))
(if (< y 2.894426862792089e-49)
(- x (/ (* y (- z t)) a))
(- x (/ y t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x - (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x - ((y * (z - t)) / a);
} else {
tmp = x - (y / t_1);
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = a / (z - t)
if (y < (-1.0761266216389975d-10)) then
tmp = x - (1.0d0 / (t_1 / y))
else if (y < 2.894426862792089d-49) then
tmp = x - ((y * (z - t)) / a)
else
tmp = x - (y / t_1)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x - (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x - ((y * (z - t)) / a);
} else {
tmp = x - (y / t_1);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = a / (z - t) tmp = 0 if y < -1.0761266216389975e-10: tmp = x - (1.0 / (t_1 / y)) elif y < 2.894426862792089e-49: tmp = x - ((y * (z - t)) / a) else: tmp = x - (y / t_1) return tmp
function code(x, y, z, t, a) t_1 = Float64(a / Float64(z - t)) tmp = 0.0 if (y < -1.0761266216389975e-10) tmp = Float64(x - Float64(1.0 / Float64(t_1 / y))); elseif (y < 2.894426862792089e-49) tmp = Float64(x - Float64(Float64(y * Float64(z - t)) / a)); else tmp = Float64(x - Float64(y / t_1)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = a / (z - t); tmp = 0.0; if (y < -1.0761266216389975e-10) tmp = x - (1.0 / (t_1 / y)); elseif (y < 2.894426862792089e-49) tmp = x - ((y * (z - t)) / a); else tmp = x - (y / t_1); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -1.0761266216389975e-10], N[(x - N[(1.0 / N[(t$95$1 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[y, 2.894426862792089e-49], N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{z - t}\\
\mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x - \frac{1}{\frac{t_1}{y}}\\
\mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{t_1}\\
\end{array}
\end{array}
herbie shell --seed 2023174
(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)))