
(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 (+ 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 90.5%
associate-*l/97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.15e-33) (not (<= z 3.4e+146))) (* (/ y a) (- z)) (+ x (* (/ y a) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.15e-33) || !(z <= 3.4e+146)) {
tmp = (y / a) * -z;
} else {
tmp = x + ((y / a) * 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 ((z <= (-1.15d-33)) .or. (.not. (z <= 3.4d+146))) then
tmp = (y / a) * -z
else
tmp = x + ((y / a) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.15e-33) || !(z <= 3.4e+146)) {
tmp = (y / a) * -z;
} else {
tmp = x + ((y / a) * z);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.15e-33) or not (z <= 3.4e+146): tmp = (y / a) * -z else: tmp = x + ((y / a) * z) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.15e-33) || !(z <= 3.4e+146)) tmp = Float64(Float64(y / a) * Float64(-z)); else tmp = Float64(x + Float64(Float64(y / a) * z)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.15e-33) || ~((z <= 3.4e+146))) tmp = (y / a) * -z; else tmp = x + ((y / a) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.15e-33], N[Not[LessEqual[z, 3.4e+146]], $MachinePrecision]], N[(N[(y / a), $MachinePrecision] * (-z)), $MachinePrecision], N[(x + N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{-33} \lor \neg \left(z \leq 3.4 \cdot 10^{+146}\right):\\
\;\;\;\;\frac{y}{a} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{a} \cdot z\\
\end{array}
\end{array}
if z < -1.14999999999999993e-33 or 3.39999999999999991e146 < z Initial program 84.6%
associate-*l/98.3%
Simplified98.3%
Taylor expanded in z around inf 75.6%
associate-*l/85.2%
*-commutative85.2%
Simplified85.2%
clear-num85.2%
un-div-inv85.2%
Applied egg-rr85.2%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
associate-*r/64.1%
associate-*r*64.1%
neg-mul-164.1%
Simplified64.1%
if -1.14999999999999993e-33 < z < 3.39999999999999991e146Initial program 94.6%
associate-*l/97.4%
Simplified97.4%
Taylor expanded in z around inf 61.1%
associate-*l/63.1%
*-commutative63.1%
Simplified63.1%
clear-num63.1%
un-div-inv63.4%
Applied egg-rr63.4%
div-inv63.1%
clear-num63.1%
cancel-sign-sub-inv63.1%
*-commutative63.1%
associate-/r/59.9%
+-commutative59.9%
associate-/r/63.1%
*-commutative63.1%
add-sqr-sqrt24.0%
sqrt-unprod53.8%
sqr-neg53.8%
sqrt-unprod32.0%
add-sqr-sqrt53.4%
Applied egg-rr53.4%
Final simplification57.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2e+60) (not (<= z 2.7e+141))) (- x (* (/ y a) z)) (+ x (* (/ y a) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2e+60) || !(z <= 2.7e+141)) {
tmp = x - ((y / a) * z);
} 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 <= (-2d+60)) .or. (.not. (z <= 2.7d+141))) then
tmp = x - ((y / a) * z)
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 <= -2e+60) || !(z <= 2.7e+141)) {
tmp = x - ((y / a) * z);
} else {
tmp = x + ((y / a) * t);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -2e+60) or not (z <= 2.7e+141): tmp = x - ((y / a) * z) else: tmp = x + ((y / a) * t) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2e+60) || !(z <= 2.7e+141)) tmp = Float64(x - Float64(Float64(y / a) * z)); else tmp = Float64(x + Float64(Float64(y / a) * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -2e+60) || ~((z <= 2.7e+141))) tmp = x - ((y / a) * z); else tmp = x + ((y / a) * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2e+60], N[Not[LessEqual[z, 2.7e+141]], $MachinePrecision]], N[(x - N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+60} \lor \neg \left(z \leq 2.7 \cdot 10^{+141}\right):\\
\;\;\;\;x - \frac{y}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{a} \cdot t\\
\end{array}
\end{array}
if z < -1.9999999999999999e60 or 2.7000000000000001e141 < z Initial program 83.4%
associate-*l/97.9%
Simplified97.9%
Taylor expanded in z around inf 82.6%
associate-*l/94.4%
*-commutative94.4%
Simplified94.4%
if -1.9999999999999999e60 < z < 2.7000000000000001e141Initial program 94.1%
associate-*l/97.7%
Simplified97.7%
Taylor expanded in z around 0 82.4%
*-commutative82.4%
associate-*l/86.7%
neg-mul-186.7%
distribute-rgt-neg-out86.7%
Simplified86.7%
Final simplification89.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -6e-34) (not (<= z 5.6e+147))) (* y (/ (- z) a)) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -6e-34) || !(z <= 5.6e+147)) {
tmp = y * (-z / 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 ((z <= (-6d-34)) .or. (.not. (z <= 5.6d+147))) then
tmp = y * (-z / 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 ((z <= -6e-34) || !(z <= 5.6e+147)) {
tmp = y * (-z / a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -6e-34) or not (z <= 5.6e+147): tmp = y * (-z / a) else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -6e-34) || !(z <= 5.6e+147)) tmp = Float64(y * Float64(Float64(-z) / a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -6e-34) || ~((z <= 5.6e+147))) tmp = y * (-z / a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -6e-34], N[Not[LessEqual[z, 5.6e+147]], $MachinePrecision]], N[(y * N[((-z) / a), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-34} \lor \neg \left(z \leq 5.6 \cdot 10^{+147}\right):\\
\;\;\;\;y \cdot \frac{-z}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6e-34 or 5.6000000000000002e147 < z Initial program 84.6%
associate-*l/98.3%
Simplified98.3%
Taylor expanded in z around inf 75.6%
associate-*l/85.2%
*-commutative85.2%
Simplified85.2%
clear-num85.2%
un-div-inv85.2%
Applied egg-rr85.2%
Taylor expanded in x around 0 55.2%
mul-1-neg55.2%
associate-*r/59.4%
distribute-rgt-neg-in59.4%
Simplified59.4%
if -6e-34 < z < 5.6000000000000002e147Initial program 94.6%
associate-*l/97.4%
Simplified97.4%
Taylor expanded in z around inf 61.1%
associate-*l/63.1%
*-commutative63.1%
Simplified63.1%
Taylor expanded in x around inf 50.9%
Final simplification54.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.15e-34) (not (<= z 2.7e+146))) (* (/ y a) (- z)) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.15e-34) || !(z <= 2.7e+146)) {
tmp = (y / a) * -z;
} 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 ((z <= (-1.15d-34)) .or. (.not. (z <= 2.7d+146))) then
tmp = (y / a) * -z
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 ((z <= -1.15e-34) || !(z <= 2.7e+146)) {
tmp = (y / a) * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.15e-34) or not (z <= 2.7e+146): tmp = (y / a) * -z else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.15e-34) || !(z <= 2.7e+146)) tmp = Float64(Float64(y / a) * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.15e-34) || ~((z <= 2.7e+146))) tmp = (y / a) * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.15e-34], N[Not[LessEqual[z, 2.7e+146]], $MachinePrecision]], N[(N[(y / a), $MachinePrecision] * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{-34} \lor \neg \left(z \leq 2.7 \cdot 10^{+146}\right):\\
\;\;\;\;\frac{y}{a} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.15000000000000006e-34 or 2.69999999999999989e146 < z Initial program 84.6%
associate-*l/98.3%
Simplified98.3%
Taylor expanded in z around inf 75.6%
associate-*l/85.2%
*-commutative85.2%
Simplified85.2%
clear-num85.2%
un-div-inv85.2%
Applied egg-rr85.2%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
associate-*r/64.1%
associate-*r*64.1%
neg-mul-164.1%
Simplified64.1%
if -1.15000000000000006e-34 < z < 2.69999999999999989e146Initial program 94.6%
associate-*l/97.4%
Simplified97.4%
Taylor expanded in z around inf 61.1%
associate-*l/63.1%
*-commutative63.1%
Simplified63.1%
Taylor expanded in x around inf 50.9%
Final simplification56.2%
(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 90.5%
associate-*l/97.7%
Simplified97.7%
Taylor expanded in z around inf 67.0%
associate-*l/72.1%
*-commutative72.1%
Simplified72.1%
Final simplification72.1%
(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 90.5%
associate-*l/97.7%
Simplified97.7%
Taylor expanded in z around inf 67.0%
associate-*l/72.1%
*-commutative72.1%
Simplified72.1%
clear-num72.0%
un-div-inv72.3%
Applied egg-rr72.3%
Final simplification72.3%
(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 90.5%
associate-*l/97.7%
Simplified97.7%
Taylor expanded in z around inf 67.0%
associate-*l/72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in x around inf 39.5%
Final simplification39.5%
(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 2024036
(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)))