
(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 (if (<= y 1.8e-103) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 1.8e-103) {
tmp = x + ((y * (z - t)) / 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 (y <= 1.8d-103) then
tmp = x + ((y * (z - t)) / 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 (y <= 1.8e-103) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / (a / (z - t)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= 1.8e-103: tmp = x + ((y * (z - t)) / a) else: tmp = x + (y / (a / (z - t))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= 1.8e-103) tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / 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 (y <= 1.8e-103) tmp = x + ((y * (z - t)) / a); else tmp = x + (y / (a / (z - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, 1.8e-103], N[(x + N[(N[(y * N[(z - t), $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}\;y \leq 1.8 \cdot 10^{-103}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\
\end{array}
\end{array}
if y < 1.7999999999999999e-103Initial program 98.7%
if 1.7999999999999999e-103 < y Initial program 86.4%
associate-/l*98.8%
Simplified98.8%
Final simplification98.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -5.5e+120) (not (<= t 1.95e+119))) (* t (/ (- y) a)) (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -5.5e+120) || !(t <= 1.95e+119)) {
tmp = 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.5d+120)) .or. (.not. (t <= 1.95d+119))) then
tmp = 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.5e+120) || !(t <= 1.95e+119)) {
tmp = t * (-y / a);
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -5.5e+120) or not (t <= 1.95e+119): tmp = t * (-y / a) else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -5.5e+120) || !(t <= 1.95e+119)) tmp = Float64(t * Float64(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.5e+120) || ~((t <= 1.95e+119))) tmp = 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.5e+120], N[Not[LessEqual[t, 1.95e+119]], $MachinePrecision]], N[(t * N[((-y) / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.5 \cdot 10^{+120} \lor \neg \left(t \leq 1.95 \cdot 10^{+119}\right):\\
\;\;\;\;t \cdot \frac{-y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -5.50000000000000003e120 or 1.9499999999999999e119 < t Initial program 90.8%
associate-*l/95.5%
Simplified95.5%
Taylor expanded in z around 0 83.1%
+-commutative83.1%
mul-1-neg83.1%
associate-*r/86.6%
*-commutative86.6%
distribute-rgt-neg-out86.6%
fma-def86.7%
Simplified86.7%
Taylor expanded in y around inf 72.2%
*-commutative72.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*r/75.2%
neg-mul-175.2%
Simplified75.2%
if -5.50000000000000003e120 < t < 1.9499999999999999e119Initial program 95.5%
associate-*l/96.9%
Simplified96.9%
Taylor expanded in z around inf 83.6%
*-commutative83.6%
associate-*r/85.3%
Simplified85.3%
Final simplification82.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -6.2e+131) (not (<= t 1.48e+119))) (* t (/ (- y) a)) (+ x (/ z (/ a y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -6.2e+131) || !(t <= 1.48e+119)) {
tmp = t * (-y / a);
} else {
tmp = x + (z / (a / y));
}
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.2d+131)) .or. (.not. (t <= 1.48d+119))) then
tmp = t * (-y / a)
else
tmp = x + (z / (a / y))
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.2e+131) || !(t <= 1.48e+119)) {
tmp = t * (-y / a);
} else {
tmp = x + (z / (a / y));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -6.2e+131) or not (t <= 1.48e+119): tmp = t * (-y / a) else: tmp = x + (z / (a / y)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -6.2e+131) || !(t <= 1.48e+119)) tmp = Float64(t * Float64(Float64(-y) / a)); else tmp = Float64(x + Float64(z / Float64(a / y))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -6.2e+131) || ~((t <= 1.48e+119))) tmp = t * (-y / a); else tmp = x + (z / (a / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -6.2e+131], N[Not[LessEqual[t, 1.48e+119]], $MachinePrecision]], N[(t * N[((-y) / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.2 \cdot 10^{+131} \lor \neg \left(t \leq 1.48 \cdot 10^{+119}\right):\\
\;\;\;\;t \cdot \frac{-y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\end{array}
\end{array}
if t < -6.20000000000000032e131 or 1.47999999999999995e119 < t Initial program 90.8%
associate-*l/95.5%
Simplified95.5%
Taylor expanded in z around 0 83.1%
+-commutative83.1%
mul-1-neg83.1%
associate-*r/86.6%
*-commutative86.6%
distribute-rgt-neg-out86.6%
fma-def86.7%
Simplified86.7%
Taylor expanded in y around inf 72.2%
*-commutative72.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*r/75.2%
neg-mul-175.2%
Simplified75.2%
if -6.20000000000000032e131 < t < 1.47999999999999995e119Initial program 95.5%
associate-*l/96.9%
Simplified96.9%
Taylor expanded in z around inf 83.6%
*-commutative83.6%
associate-*r/85.3%
Simplified85.3%
clear-num85.3%
div-inv85.3%
Applied egg-rr85.3%
Final simplification82.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -6.5e-45) (not (<= t 1.6e+95))) (- x (* t (/ y a))) (+ x (/ z (/ a y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -6.5e-45) || !(t <= 1.6e+95)) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z / (a / y));
}
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-45)) .or. (.not. (t <= 1.6d+95))) then
tmp = x - (t * (y / a))
else
tmp = x + (z / (a / y))
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-45) || !(t <= 1.6e+95)) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z / (a / y));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -6.5e-45) or not (t <= 1.6e+95): tmp = x - (t * (y / a)) else: tmp = x + (z / (a / y)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -6.5e-45) || !(t <= 1.6e+95)) tmp = Float64(x - Float64(t * Float64(y / a))); else tmp = Float64(x + Float64(z / Float64(a / y))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -6.5e-45) || ~((t <= 1.6e+95))) tmp = x - (t * (y / a)); else tmp = x + (z / (a / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -6.5e-45], N[Not[LessEqual[t, 1.6e+95]], $MachinePrecision]], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{-45} \lor \neg \left(t \leq 1.6 \cdot 10^{+95}\right):\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\end{array}
\end{array}
if t < -6.4999999999999995e-45 or 1.6e95 < t Initial program 91.4%
associate-*l/96.2%
Simplified96.2%
associate-*l/91.4%
*-commutative91.4%
associate-/l*95.6%
Applied egg-rr95.6%
Taylor expanded in z around 0 80.6%
*-commutative80.6%
associate-*r/78.7%
mul-1-neg78.7%
sub-neg78.7%
associate-*r/80.6%
*-commutative80.6%
associate-*r/84.7%
Simplified84.7%
if -6.4999999999999995e-45 < t < 1.6e95Initial program 96.4%
associate-*l/96.7%
Simplified96.7%
Taylor expanded in z around inf 87.9%
*-commutative87.9%
associate-*r/89.4%
Simplified89.4%
clear-num89.4%
div-inv89.4%
Applied egg-rr89.4%
Final simplification87.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.45e+117) (not (<= t 3.6e+95))) (* t (/ (- y) a)) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.45e+117) || !(t <= 3.6e+95)) {
tmp = t * (-y / 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 <= (-1.45d+117)) .or. (.not. (t <= 3.6d+95))) then
tmp = t * (-y / 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 <= -1.45e+117) || !(t <= 3.6e+95)) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -1.45e+117) or not (t <= 3.6e+95): tmp = t * (-y / a) else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.45e+117) || !(t <= 3.6e+95)) tmp = Float64(t * Float64(Float64(-y) / a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -1.45e+117) || ~((t <= 3.6e+95))) tmp = t * (-y / a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.45e+117], N[Not[LessEqual[t, 3.6e+95]], $MachinePrecision]], N[(t * N[((-y) / a), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{+117} \lor \neg \left(t \leq 3.6 \cdot 10^{+95}\right):\\
\;\;\;\;t \cdot \frac{-y}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.45000000000000014e117 or 3.59999999999999978e95 < t Initial program 89.4%
associate-*l/94.8%
Simplified94.8%
Taylor expanded in z around 0 78.9%
+-commutative78.9%
mul-1-neg78.9%
associate-*r/83.3%
*-commutative83.3%
distribute-rgt-neg-out83.3%
fma-def83.3%
Simplified83.3%
Taylor expanded in y around inf 67.9%
*-commutative67.9%
associate-*r/71.9%
associate-*r*71.9%
*-commutative71.9%
associate-*r/71.9%
neg-mul-171.9%
Simplified71.9%
if -1.45000000000000014e117 < t < 3.59999999999999978e95Initial program 96.4%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in x around inf 47.1%
Final simplification55.0%
(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.2%
associate-*l/96.5%
Simplified96.5%
Final simplification96.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.2%
associate-*l/96.5%
Simplified96.5%
Taylor expanded in x around inf 36.6%
Final simplification36.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 2023301
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
: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)))