
(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 7 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 (+ x (* (- z t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / 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 + ((z - t) * (y / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / a));
}
def code(x, y, z, t, a): return x + ((z - t) * (y / a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(z - t) * Float64(y / a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((z - t) * (y / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z - t\right) \cdot \frac{y}{a}
\end{array}
Initial program 94.4%
*-commutative94.4%
associate-/l*99.7%
Applied egg-rr99.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -5.6e+63) (not (<= t 8.4e+42))) (- x (* t (/ y a))) (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -5.6e+63) || !(t <= 8.4e+42)) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z * (y / 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 ((t <= (-5.6d+63)) .or. (.not. (t <= 8.4d+42))) then
tmp = x - (t * (y / a))
else
tmp = x + (z * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -5.6e+63) || !(t <= 8.4e+42)) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -5.6e+63) or not (t <= 8.4e+42): tmp = x - (t * (y / a)) else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -5.6e+63) || !(t <= 8.4e+42)) tmp = Float64(x - Float64(t * Float64(y / a))); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -5.6e+63) || ~((t <= 8.4e+42))) tmp = x - (t * (y / a)); else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -5.6e+63], N[Not[LessEqual[t, 8.4e+42]], $MachinePrecision]], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.6 \cdot 10^{+63} \lor \neg \left(t \leq 8.4 \cdot 10^{+42}\right):\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -5.59999999999999974e63 or 8.39999999999999982e42 < t Initial program 91.5%
*-commutative91.5%
associate-/l*99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 82.7%
associate-*l/86.5%
*-commutative86.5%
neg-mul-186.5%
sub-neg86.5%
associate-*r/82.7%
associate-*l/90.1%
*-commutative90.1%
Simplified90.1%
if -5.59999999999999974e63 < t < 8.39999999999999982e42Initial program 96.3%
*-commutative96.3%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 88.8%
associate-*l/92.9%
*-commutative92.9%
Simplified92.9%
Final simplification91.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -9.2e+139) (not (<= t 4.1e+126))) (* y (/ t (- a))) (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9.2e+139) || !(t <= 4.1e+126)) {
tmp = y * (t / -a);
} else {
tmp = x + (z * (y / 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 ((t <= (-9.2d+139)) .or. (.not. (t <= 4.1d+126))) then
tmp = y * (t / -a)
else
tmp = x + (z * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9.2e+139) || !(t <= 4.1e+126)) {
tmp = y * (t / -a);
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -9.2e+139) or not (t <= 4.1e+126): tmp = y * (t / -a) else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -9.2e+139) || !(t <= 4.1e+126)) tmp = Float64(y * Float64(t / Float64(-a))); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -9.2e+139) || ~((t <= 4.1e+126))) tmp = y * (t / -a); else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -9.2e+139], N[Not[LessEqual[t, 4.1e+126]], $MachinePrecision]], N[(y * N[(t / (-a)), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.2 \cdot 10^{+139} \lor \neg \left(t \leq 4.1 \cdot 10^{+126}\right):\\
\;\;\;\;y \cdot \frac{t}{-a}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -9.2e139 or 4.1000000000000001e126 < t Initial program 91.3%
*-commutative91.3%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 82.6%
associate-*l/86.9%
*-commutative86.9%
neg-mul-186.9%
sub-neg86.9%
associate-*r/82.6%
associate-*l/91.1%
*-commutative91.1%
Simplified91.1%
clear-num91.0%
un-div-inv91.1%
Applied egg-rr91.1%
Taylor expanded in x around 0 67.7%
mul-1-neg67.7%
associate-*l/72.0%
*-commutative72.0%
distribute-rgt-neg-out72.0%
distribute-frac-neg272.0%
Simplified72.0%
if -9.2e139 < t < 4.1000000000000001e126Initial program 95.4%
*-commutative95.4%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 84.3%
associate-*l/88.5%
*-commutative88.5%
Simplified88.5%
Final simplification84.3%
(FPCore (x y z t a) :precision binary64 (if (<= t -6.5e+64) (- x (/ t (/ a y))) (if (<= t 1.15e+41) (+ x (* z (/ y a))) (- x (* t (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -6.5e+64) {
tmp = x - (t / (a / y));
} else if (t <= 1.15e+41) {
tmp = x + (z * (y / a));
} else {
tmp = x - (t * (y / 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 (t <= (-6.5d+64)) then
tmp = x - (t / (a / y))
else if (t <= 1.15d+41) then
tmp = x + (z * (y / a))
else
tmp = x - (t * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -6.5e+64) {
tmp = x - (t / (a / y));
} else if (t <= 1.15e+41) {
tmp = x + (z * (y / a));
} else {
tmp = x - (t * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -6.5e+64: tmp = x - (t / (a / y)) elif t <= 1.15e+41: tmp = x + (z * (y / a)) else: tmp = x - (t * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -6.5e+64) tmp = Float64(x - Float64(t / Float64(a / y))); elseif (t <= 1.15e+41) tmp = Float64(x + Float64(z * Float64(y / a))); else tmp = Float64(x - Float64(t * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -6.5e+64) tmp = x - (t / (a / y)); elseif (t <= 1.15e+41) tmp = x + (z * (y / a)); else tmp = x - (t * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -6.5e+64], N[(x - N[(t / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.15e+41], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{+64}:\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+41}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -6.50000000000000007e64Initial program 90.7%
*-commutative90.7%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 81.5%
associate-*l/86.9%
*-commutative86.9%
neg-mul-186.9%
sub-neg86.9%
associate-*r/81.5%
associate-*l/90.6%
*-commutative90.6%
Simplified90.6%
clear-num90.6%
un-div-inv90.7%
Applied egg-rr90.7%
if -6.50000000000000007e64 < t < 1.1499999999999999e41Initial program 96.3%
*-commutative96.3%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 88.8%
associate-*l/92.9%
*-commutative92.9%
Simplified92.9%
if 1.1499999999999999e41 < t Initial program 92.3%
*-commutative92.3%
associate-/l*99.2%
Applied egg-rr99.2%
Taylor expanded in z around 0 83.9%
associate-*l/86.0%
*-commutative86.0%
neg-mul-186.0%
sub-neg86.0%
associate-*r/83.9%
associate-*l/89.6%
*-commutative89.6%
Simplified89.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -3.5e+61) (not (<= t 1.38e+87))) (* y (/ t (- a))) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -3.5e+61) || !(t <= 1.38e+87)) {
tmp = y * (t / -a);
} else {
tmp = x;
}
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 ((t <= (-3.5d+61)) .or. (.not. (t <= 1.38d+87))) then
tmp = y * (t / -a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -3.5e+61) || !(t <= 1.38e+87)) {
tmp = y * (t / -a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -3.5e+61) or not (t <= 1.38e+87): tmp = y * (t / -a) else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -3.5e+61) || !(t <= 1.38e+87)) tmp = Float64(y * Float64(t / Float64(-a))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -3.5e+61) || ~((t <= 1.38e+87))) tmp = y * (t / -a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -3.5e+61], N[Not[LessEqual[t, 1.38e+87]], $MachinePrecision]], N[(y * N[(t / (-a)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.5 \cdot 10^{+61} \lor \neg \left(t \leq 1.38 \cdot 10^{+87}\right):\\
\;\;\;\;y \cdot \frac{t}{-a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -3.50000000000000018e61 or 1.38e87 < t Initial program 90.7%
*-commutative90.7%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 81.6%
associate-*l/86.7%
*-commutative86.7%
neg-mul-186.7%
sub-neg86.7%
associate-*r/81.6%
associate-*l/89.6%
*-commutative89.6%
Simplified89.6%
clear-num89.6%
un-div-inv89.7%
Applied egg-rr89.7%
Taylor expanded in x around 0 62.6%
mul-1-neg62.6%
associate-*l/65.8%
*-commutative65.8%
distribute-rgt-neg-out65.8%
distribute-frac-neg265.8%
Simplified65.8%
if -3.50000000000000018e61 < t < 1.38e87Initial program 96.5%
associate-/l*96.4%
Simplified96.4%
Taylor expanded in x around inf 52.9%
Final simplification57.5%
(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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{a}
\end{array}
Initial program 94.4%
associate-/l*96.5%
Simplified96.5%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 94.4%
associate-/l*96.5%
Simplified96.5%
Taylor expanded in x around inf 42.6%
(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 2024181
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:alt
(! :herbie-platform default (if (< y -430450648655599/4000000000000000000000000) (+ x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2894426862792089/10000000000000000000000000000000000000000000000000000000000000000) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t)))))))
(+ x (/ (* y (- z t)) a)))