
(FPCore (x y z t a b) :precision binary64 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
code = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
def code(x, y, z, t, a, b): return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) end
function tmp = code(x, y, z, t, a, b) tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
code = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
def code(x, y, z, t, a, b): return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) end
function tmp = code(x, y, z, t, a, b) tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ y (+ x t)))
(t_2 (/ (- (+ (* (+ x y) z) (* (+ y t) a)) (* y b)) t_1))
(t_3 (- (+ z a) b)))
(if (or (<= t_2 (- INFINITY)) (not (<= t_2 4e+215)))
t_3
(/ (+ (* t a) (+ (* x z) (* y t_3))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (x + t);
double t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
double t_3 = (z + a) - b;
double tmp;
if ((t_2 <= -((double) INFINITY)) || !(t_2 <= 4e+215)) {
tmp = t_3;
} else {
tmp = ((t * a) + ((x * z) + (y * t_3))) / t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (x + t);
double t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
double t_3 = (z + a) - b;
double tmp;
if ((t_2 <= -Double.POSITIVE_INFINITY) || !(t_2 <= 4e+215)) {
tmp = t_3;
} else {
tmp = ((t * a) + ((x * z) + (y * t_3))) / t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = y + (x + t) t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1 t_3 = (z + a) - b tmp = 0 if (t_2 <= -math.inf) or not (t_2 <= 4e+215): tmp = t_3 else: tmp = ((t * a) + ((x * z) + (y * t_3))) / t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(y + Float64(x + t)) t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(y + t) * a)) - Float64(y * b)) / t_1) t_3 = Float64(Float64(z + a) - b) tmp = 0.0 if ((t_2 <= Float64(-Inf)) || !(t_2 <= 4e+215)) tmp = t_3; else tmp = Float64(Float64(Float64(t * a) + Float64(Float64(x * z) + Float64(y * t_3))) / t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = y + (x + t); t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1; t_3 = (z + a) - b; tmp = 0.0; if ((t_2 <= -Inf) || ~((t_2 <= 4e+215))) tmp = t_3; else tmp = ((t * a) + ((x * z) + (y * t_3))) / t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[Or[LessEqual[t$95$2, (-Infinity)], N[Not[LessEqual[t$95$2, 4e+215]], $MachinePrecision]], t$95$3, N[(N[(N[(t * a), $MachinePrecision] + N[(N[(x * z), $MachinePrecision] + N[(y * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y + \left(x + t\right)\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{t_1}\\
t_3 := \left(z + a\right) - b\\
\mathbf{if}\;t_2 \leq -\infty \lor \neg \left(t_2 \leq 4 \cdot 10^{+215}\right):\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\frac{t \cdot a + \left(x \cdot z + y \cdot t_3\right)}{t_1}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 3.99999999999999963e215 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 12.7%
Taylor expanded in y around inf 76.6%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 3.99999999999999963e215Initial program 99.7%
Taylor expanded in y around 0 99.7%
Final simplification89.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ z a) b)) (t_2 (/ (+ (* x z) (* y t_1)) (+ x y))))
(if (<= y -2.4e+49)
t_1
(if (<= y -2.6e-161)
t_2
(if (<= y 5.6e-62)
(/ z (/ (+ x (+ y t)) (+ x y)))
(if (<= y 9.5e+32) t_2 t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + a) - b;
double t_2 = ((x * z) + (y * t_1)) / (x + y);
double tmp;
if (y <= -2.4e+49) {
tmp = t_1;
} else if (y <= -2.6e-161) {
tmp = t_2;
} else if (y <= 5.6e-62) {
tmp = z / ((x + (y + t)) / (x + y));
} else if (y <= 9.5e+32) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (z + a) - b
t_2 = ((x * z) + (y * t_1)) / (x + y)
if (y <= (-2.4d+49)) then
tmp = t_1
else if (y <= (-2.6d-161)) then
tmp = t_2
else if (y <= 5.6d-62) then
tmp = z / ((x + (y + t)) / (x + y))
else if (y <= 9.5d+32) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + a) - b;
double t_2 = ((x * z) + (y * t_1)) / (x + y);
double tmp;
if (y <= -2.4e+49) {
tmp = t_1;
} else if (y <= -2.6e-161) {
tmp = t_2;
} else if (y <= 5.6e-62) {
tmp = z / ((x + (y + t)) / (x + y));
} else if (y <= 9.5e+32) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + a) - b t_2 = ((x * z) + (y * t_1)) / (x + y) tmp = 0 if y <= -2.4e+49: tmp = t_1 elif y <= -2.6e-161: tmp = t_2 elif y <= 5.6e-62: tmp = z / ((x + (y + t)) / (x + y)) elif y <= 9.5e+32: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z + a) - b) t_2 = Float64(Float64(Float64(x * z) + Float64(y * t_1)) / Float64(x + y)) tmp = 0.0 if (y <= -2.4e+49) tmp = t_1; elseif (y <= -2.6e-161) tmp = t_2; elseif (y <= 5.6e-62) tmp = Float64(z / Float64(Float64(x + Float64(y + t)) / Float64(x + y))); elseif (y <= 9.5e+32) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z + a) - b; t_2 = ((x * z) + (y * t_1)) / (x + y); tmp = 0.0; if (y <= -2.4e+49) tmp = t_1; elseif (y <= -2.6e-161) tmp = t_2; elseif (y <= 5.6e-62) tmp = z / ((x + (y + t)) / (x + y)); elseif (y <= 9.5e+32) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * z), $MachinePrecision] + N[(y * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.4e+49], t$95$1, If[LessEqual[y, -2.6e-161], t$95$2, If[LessEqual[y, 5.6e-62], N[(z / N[(N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e+32], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z + a\right) - b\\
t_2 := \frac{x \cdot z + y \cdot t_1}{x + y}\\
\mathbf{if}\;y \leq -2.4 \cdot 10^{+49}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.6 \cdot 10^{-161}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{-62}:\\
\;\;\;\;\frac{z}{\frac{x + \left(y + t\right)}{x + y}}\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+32}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -2.4e49 or 9.50000000000000006e32 < y Initial program 38.1%
Taylor expanded in y around inf 76.0%
if -2.4e49 < y < -2.59999999999999995e-161 or 5.60000000000000005e-62 < y < 9.50000000000000006e32Initial program 89.2%
Taylor expanded in y around 0 89.2%
Taylor expanded in t around 0 80.9%
if -2.59999999999999995e-161 < y < 5.60000000000000005e-62Initial program 72.2%
Taylor expanded in z around inf 43.6%
associate-/l*58.0%
+-commutative58.0%
associate-+r+58.0%
+-commutative58.0%
Simplified58.0%
Final simplification71.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ x (+ y t))) (t_2 (- (+ z a) b)))
(if (<= y -1.6e-74)
t_2
(if (<= y -2.7e-158)
(/ a (/ t_1 (+ y t)))
(if (<= y 2.6e-61) (/ z (/ t_1 (+ x y))) t_2)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + (y + t);
double t_2 = (z + a) - b;
double tmp;
if (y <= -1.6e-74) {
tmp = t_2;
} else if (y <= -2.7e-158) {
tmp = a / (t_1 / (y + t));
} else if (y <= 2.6e-61) {
tmp = z / (t_1 / (x + y));
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x + (y + t)
t_2 = (z + a) - b
if (y <= (-1.6d-74)) then
tmp = t_2
else if (y <= (-2.7d-158)) then
tmp = a / (t_1 / (y + t))
else if (y <= 2.6d-61) then
tmp = z / (t_1 / (x + y))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + (y + t);
double t_2 = (z + a) - b;
double tmp;
if (y <= -1.6e-74) {
tmp = t_2;
} else if (y <= -2.7e-158) {
tmp = a / (t_1 / (y + t));
} else if (y <= 2.6e-61) {
tmp = z / (t_1 / (x + y));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = x + (y + t) t_2 = (z + a) - b tmp = 0 if y <= -1.6e-74: tmp = t_2 elif y <= -2.7e-158: tmp = a / (t_1 / (y + t)) elif y <= 2.6e-61: tmp = z / (t_1 / (x + y)) else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(y + t)) t_2 = Float64(Float64(z + a) - b) tmp = 0.0 if (y <= -1.6e-74) tmp = t_2; elseif (y <= -2.7e-158) tmp = Float64(a / Float64(t_1 / Float64(y + t))); elseif (y <= 2.6e-61) tmp = Float64(z / Float64(t_1 / Float64(x + y))); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = x + (y + t); t_2 = (z + a) - b; tmp = 0.0; if (y <= -1.6e-74) tmp = t_2; elseif (y <= -2.7e-158) tmp = a / (t_1 / (y + t)); elseif (y <= 2.6e-61) tmp = z / (t_1 / (x + y)); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -1.6e-74], t$95$2, If[LessEqual[y, -2.7e-158], N[(a / N[(t$95$1 / N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e-61], N[(z / N[(t$95$1 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y + t\right)\\
t_2 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -1.6 \cdot 10^{-74}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -2.7 \cdot 10^{-158}:\\
\;\;\;\;\frac{a}{\frac{t_1}{y + t}}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-61}:\\
\;\;\;\;\frac{z}{\frac{t_1}{x + y}}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if y < -1.5999999999999999e-74 or 2.6000000000000001e-61 < y Initial program 52.3%
Taylor expanded in y around inf 73.4%
if -1.5999999999999999e-74 < y < -2.6999999999999998e-158Initial program 86.9%
Taylor expanded in a around inf 73.2%
associate-/l*86.2%
+-commutative86.2%
associate-+r+86.2%
Simplified86.2%
if -2.6999999999999998e-158 < y < 2.6000000000000001e-61Initial program 72.9%
Taylor expanded in z around inf 43.8%
associate-/l*57.8%
+-commutative57.8%
associate-+r+57.8%
+-commutative57.8%
Simplified57.8%
Final simplification69.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -7.5e+193) (not (<= x 1.5e+174))) (/ z (/ (+ x t) x)) (- (+ z a) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -7.5e+193) || !(x <= 1.5e+174)) {
tmp = z / ((x + t) / x);
} else {
tmp = (z + a) - b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: tmp
if ((x <= (-7.5d+193)) .or. (.not. (x <= 1.5d+174))) then
tmp = z / ((x + t) / x)
else
tmp = (z + a) - b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -7.5e+193) || !(x <= 1.5e+174)) {
tmp = z / ((x + t) / x);
} else {
tmp = (z + a) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x <= -7.5e+193) or not (x <= 1.5e+174): tmp = z / ((x + t) / x) else: tmp = (z + a) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -7.5e+193) || !(x <= 1.5e+174)) tmp = Float64(z / Float64(Float64(x + t) / x)); else tmp = Float64(Float64(z + a) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x <= -7.5e+193) || ~((x <= 1.5e+174))) tmp = z / ((x + t) / x); else tmp = (z + a) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -7.5e+193], N[Not[LessEqual[x, 1.5e+174]], $MachinePrecision]], N[(z / N[(N[(x + t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+193} \lor \neg \left(x \leq 1.5 \cdot 10^{+174}\right):\\
\;\;\;\;\frac{z}{\frac{x + t}{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(z + a\right) - b\\
\end{array}
\end{array}
if x < -7.5000000000000008e193 or 1.5e174 < x Initial program 45.5%
Taylor expanded in z around inf 27.7%
associate-/l*63.6%
+-commutative63.6%
associate-+r+63.6%
+-commutative63.6%
Simplified63.6%
Taylor expanded in y around 0 63.6%
+-commutative63.6%
Simplified63.6%
if -7.5000000000000008e193 < x < 1.5e174Initial program 65.6%
Taylor expanded in y around inf 68.7%
Final simplification67.5%
(FPCore (x y z t a b) :precision binary64 (if (<= a -2.8e+94) a (if (<= a 8.5e+160) (- z b) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.8e+94) {
tmp = a;
} else if (a <= 8.5e+160) {
tmp = z - b;
} else {
tmp = a;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: tmp
if (a <= (-2.8d+94)) then
tmp = a
else if (a <= 8.5d+160) then
tmp = z - b
else
tmp = a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.8e+94) {
tmp = a;
} else if (a <= 8.5e+160) {
tmp = z - b;
} else {
tmp = a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -2.8e+94: tmp = a elif a <= 8.5e+160: tmp = z - b else: tmp = a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.8e+94) tmp = a; elseif (a <= 8.5e+160) tmp = Float64(z - b); else tmp = a; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -2.8e+94) tmp = a; elseif (a <= 8.5e+160) tmp = z - b; else tmp = a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.8e+94], a, If[LessEqual[a, 8.5e+160], N[(z - b), $MachinePrecision], a]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.8 \cdot 10^{+94}:\\
\;\;\;\;a\\
\mathbf{elif}\;a \leq 8.5 \cdot 10^{+160}:\\
\;\;\;\;z - b\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if a < -2.79999999999999998e94 or 8.49999999999999982e160 < a Initial program 45.9%
Taylor expanded in t around inf 57.5%
if -2.79999999999999998e94 < a < 8.49999999999999982e160Initial program 67.9%
+-commutative67.9%
associate--l+67.9%
fma-def67.9%
+-commutative67.9%
+-commutative67.9%
Simplified67.9%
div-inv67.7%
fma-udef67.7%
*-commutative67.7%
fma-def67.7%
+-commutative67.7%
associate-+l+67.7%
+-commutative67.7%
Applied egg-rr67.7%
Taylor expanded in a around 0 53.9%
Taylor expanded in y around inf 56.4%
Final simplification56.8%
(FPCore (x y z t a b) :precision binary64 (if (<= x 9.8e+178) (- (+ z a) b) z))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 9.8e+178) {
tmp = (z + a) - b;
} else {
tmp = z;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: tmp
if (x <= 9.8d+178) then
tmp = (z + a) - b
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 9.8e+178) {
tmp = (z + a) - b;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= 9.8e+178: tmp = (z + a) - b else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= 9.8e+178) tmp = Float64(Float64(z + a) - b); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= 9.8e+178) tmp = (z + a) - b; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, 9.8e+178], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.8 \cdot 10^{+178}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < 9.8000000000000003e178Initial program 63.2%
Taylor expanded in y around inf 63.9%
if 9.8000000000000003e178 < x Initial program 45.8%
Taylor expanded in x around inf 73.8%
Final simplification65.4%
(FPCore (x y z t a b) :precision binary64 (if (<= z -2e+72) z (if (<= z 3.3e-72) a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -2e+72) {
tmp = z;
} else if (z <= 3.3e-72) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: tmp
if (z <= (-2d+72)) then
tmp = z
else if (z <= 3.3d-72) then
tmp = a
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -2e+72) {
tmp = z;
} else if (z <= 3.3e-72) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if z <= -2e+72: tmp = z elif z <= 3.3e-72: tmp = a else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -2e+72) tmp = z; elseif (z <= 3.3e-72) tmp = a; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (z <= -2e+72) tmp = z; elseif (z <= 3.3e-72) tmp = a; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -2e+72], z, If[LessEqual[z, 3.3e-72], a, z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+72}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-72}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.99999999999999989e72 or 3.3e-72 < z Initial program 49.5%
Taylor expanded in x around inf 58.5%
if -1.99999999999999989e72 < z < 3.3e-72Initial program 71.5%
Taylor expanded in t around inf 43.0%
Final simplification50.6%
(FPCore (x y z t a b) :precision binary64 a)
double code(double x, double y, double z, double t, double a, double b) {
return a;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
code = a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a;
}
def code(x, y, z, t, a, b): return a
function code(x, y, z, t, a, b) return a end
function tmp = code(x, y, z, t, a, b) tmp = a; end
code[x_, y_, z_, t_, a_, b_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 60.7%
Taylor expanded in t around inf 28.7%
Final simplification28.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ x t) y))
(t_2 (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))
(t_3 (/ t_2 t_1))
(t_4 (- (+ z a) b)))
(if (< t_3 -3.5813117084150564e+153)
t_4
(if (< t_3 1.2285964308315609e+82) (/ 1.0 (/ t_1 t_2)) t_4))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b);
double t_3 = t_2 / t_1;
double t_4 = (z + a) - b;
double tmp;
if (t_3 < -3.5813117084150564e+153) {
tmp = t_4;
} else if (t_3 < 1.2285964308315609e+82) {
tmp = 1.0 / (t_1 / t_2);
} else {
tmp = t_4;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_1 = (x + t) + y
t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b)
t_3 = t_2 / t_1
t_4 = (z + a) - b
if (t_3 < (-3.5813117084150564d+153)) then
tmp = t_4
else if (t_3 < 1.2285964308315609d+82) then
tmp = 1.0d0 / (t_1 / t_2)
else
tmp = t_4
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b);
double t_3 = t_2 / t_1;
double t_4 = (z + a) - b;
double tmp;
if (t_3 < -3.5813117084150564e+153) {
tmp = t_4;
} else if (t_3 < 1.2285964308315609e+82) {
tmp = 1.0 / (t_1 / t_2);
} else {
tmp = t_4;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x + t) + y t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b) t_3 = t_2 / t_1 t_4 = (z + a) - b tmp = 0 if t_3 < -3.5813117084150564e+153: tmp = t_4 elif t_3 < 1.2285964308315609e+82: tmp = 1.0 / (t_1 / t_2) else: tmp = t_4 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + t) + y) t_2 = Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) t_3 = Float64(t_2 / t_1) t_4 = Float64(Float64(z + a) - b) tmp = 0.0 if (t_3 < -3.5813117084150564e+153) tmp = t_4; elseif (t_3 < 1.2285964308315609e+82) tmp = Float64(1.0 / Float64(t_1 / t_2)); else tmp = t_4; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x + t) + y; t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b); t_3 = t_2 / t_1; t_4 = (z + a) - b; tmp = 0.0; if (t_3 < -3.5813117084150564e+153) tmp = t_4; elseif (t_3 < 1.2285964308315609e+82) tmp = 1.0 / (t_1 / t_2); else tmp = t_4; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[Less[t$95$3, -3.5813117084150564e+153], t$95$4, If[Less[t$95$3, 1.2285964308315609e+82], N[(1.0 / N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + t\right) + y\\
t_2 := \left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\\
t_3 := \frac{t_2}{t_1}\\
t_4 := \left(z + a\right) - b\\
\mathbf{if}\;t_3 < -3.5813117084150564 \cdot 10^{+153}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_3 < 1.2285964308315609 \cdot 10^{+82}:\\
\;\;\;\;\frac{1}{\frac{t_1}{t_2}}\\
\mathbf{else}:\\
\;\;\;\;t_4\\
\end{array}
\end{array}
herbie shell --seed 2023287
(FPCore (x y z t a b)
:name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
:precision binary64
:herbie-target
(if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 1.0 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))
(/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))