
(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 (<= y -5e-67) (+ x (* y (/ (- t z) a))) (+ x (* (/ y a) (- t z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -5e-67) {
tmp = x + (y * ((t - z) / a));
} else {
tmp = x + ((y / a) * (t - z));
}
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 (y <= (-5d-67)) then
tmp = x + (y * ((t - z) / a))
else
tmp = x + ((y / a) * (t - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -5e-67) {
tmp = x + (y * ((t - z) / a));
} else {
tmp = x + ((y / a) * (t - z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= -5e-67: tmp = x + (y * ((t - z) / a)) else: tmp = x + ((y / a) * (t - z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= -5e-67) tmp = Float64(x + Float64(y * Float64(Float64(t - z) / a))); else tmp = Float64(x + Float64(Float64(y / a) * Float64(t - z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= -5e-67) tmp = x + (y * ((t - z) / a)); else tmp = x + ((y / a) * (t - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -5e-67], N[(x + N[(y * N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-67}:\\
\;\;\;\;x + y \cdot \frac{t - z}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\
\end{array}
\end{array}
if y < -4.9999999999999999e-67Initial program 84.6%
associate-/l*99.7%
Simplified99.7%
clear-num99.8%
associate-/r/99.6%
clear-num99.8%
Applied egg-rr99.8%
if -4.9999999999999999e-67 < y Initial program 95.2%
associate-*l/98.7%
Simplified98.7%
Final simplification99.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -3.2e+96) (not (<= t 5.1e+61))) (+ x (* y (/ t a))) (- x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -3.2e+96) || !(t <= 5.1e+61)) {
tmp = x + (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 <= (-3.2d+96)) .or. (.not. (t <= 5.1d+61))) then
tmp = x + (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 <= -3.2e+96) || !(t <= 5.1e+61)) {
tmp = x + (y * (t / a));
} else {
tmp = x - (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -3.2e+96) or not (t <= 5.1e+61): tmp = x + (y * (t / a)) else: tmp = x - (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -3.2e+96) || !(t <= 5.1e+61)) tmp = Float64(x + Float64(y * Float64(t / 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 <= -3.2e+96) || ~((t <= 5.1e+61))) tmp = x + (y * (t / a)); else tmp = x - (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -3.2e+96], N[Not[LessEqual[t, 5.1e+61]], $MachinePrecision]], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{+96} \lor \neg \left(t \leq 5.1 \cdot 10^{+61}\right):\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -3.20000000000000006e96 or 5.1000000000000001e61 < t Initial program 90.9%
associate-/l*93.3%
Simplified93.3%
clear-num93.2%
associate-/r/91.9%
clear-num92.0%
Applied egg-rr92.0%
Taylor expanded in z around 0 83.8%
neg-mul-183.8%
Simplified83.8%
if -3.20000000000000006e96 < t < 5.1000000000000001e61Initial program 92.8%
associate-*l/96.9%
Simplified96.9%
Taylor expanded in z around inf 85.7%
associate-*l/92.0%
*-commutative92.0%
Simplified92.0%
Final simplification89.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -2.8e+96) (not (<= t 6.2e+60))) (+ x (* t (/ y a))) (- x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -2.8e+96) || !(t <= 6.2e+60)) {
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 <= (-2.8d+96)) .or. (.not. (t <= 6.2d+60))) 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 <= -2.8e+96) || !(t <= 6.2e+60)) {
tmp = x + (t * (y / a));
} else {
tmp = x - (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -2.8e+96) or not (t <= 6.2e+60): 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 <= -2.8e+96) || !(t <= 6.2e+60)) 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 <= -2.8e+96) || ~((t <= 6.2e+60))) 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, -2.8e+96], N[Not[LessEqual[t, 6.2e+60]], $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 -2.8 \cdot 10^{+96} \lor \neg \left(t \leq 6.2 \cdot 10^{+60}\right):\\
\;\;\;\;x + t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -2.8e96 or 6.2000000000000001e60 < t Initial program 90.9%
associate-*l/97.7%
Simplified97.7%
Taylor expanded in z around 0 82.1%
*-commutative82.1%
associate-*l/87.7%
neg-mul-187.7%
distribute-rgt-neg-out87.7%
Simplified87.7%
if -2.8e96 < t < 6.2000000000000001e60Initial program 92.8%
associate-*l/96.9%
Simplified96.9%
Taylor expanded in z around inf 85.7%
associate-*l/92.0%
*-commutative92.0%
Simplified92.0%
Final simplification90.4%
(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 92.1%
associate-*l/97.2%
Simplified97.2%
Final simplification97.2%
(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 92.1%
associate-*l/97.2%
Simplified97.2%
Taylor expanded in z around inf 69.4%
associate-*l/75.6%
*-commutative75.6%
Simplified75.6%
frac-2neg75.6%
associate-*r/69.4%
add-sqr-sqrt34.6%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod22.7%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
associate-/l*42.1%
Simplified42.1%
Taylor expanded in x around 0 41.4%
+-commutative41.4%
associate-*r/40.6%
Simplified40.6%
Final simplification40.6%
(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(Float64(y * 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[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot z}{a}
\end{array}
Initial program 92.1%
associate-*l/97.2%
Simplified97.2%
Taylor expanded in z around inf 69.4%
associate-*l/75.6%
*-commutative75.6%
Simplified75.6%
frac-2neg75.6%
associate-*r/69.4%
add-sqr-sqrt34.6%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod22.7%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
associate-/l*42.1%
Simplified42.1%
sub-neg42.1%
associate-/r/40.6%
*-un-lft-identity40.6%
associate-*l/40.6%
distribute-rgt-neg-in40.6%
remove-double-neg40.6%
*-commutative40.6%
associate-*r*42.1%
div-inv42.1%
associate-/r/40.9%
+-commutative40.9%
associate-/r/42.1%
associate-*l/41.4%
Applied egg-rr41.4%
Final simplification41.4%
(FPCore (x y z t a) :precision binary64 (- x (* z (/ y a))))
double code(double x, double y, double z, double t, double a) {
return x - (z * (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 * (y / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - (z * (y / a));
}
def code(x, y, z, t, a): return x - (z * (y / a))
function code(x, y, z, t, a) return Float64(x - Float64(z * Float64(y / a))) end
function tmp = code(x, y, z, t, a) tmp = x - (z * (y / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot \frac{y}{a}
\end{array}
Initial program 92.1%
associate-*l/97.2%
Simplified97.2%
Taylor expanded in z around inf 69.4%
associate-*l/75.6%
*-commutative75.6%
Simplified75.6%
Final simplification75.6%
(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 92.1%
associate-*l/97.2%
Simplified97.2%
Taylor expanded in z around inf 69.4%
associate-*l/75.6%
*-commutative75.6%
Simplified75.6%
frac-2neg75.6%
associate-*r/69.4%
add-sqr-sqrt34.6%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod22.7%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
associate-/l*42.1%
Simplified42.1%
Taylor expanded in x around inf 40.2%
Final simplification40.2%
(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 2024026
(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)))