
(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 7 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 (+ x (+ y t)))
(t_2 (+ t (+ x y)))
(t_3
(*
z
(+
(fma (/ (+ y t) t_1) (/ a z) (* b (/ y (* z (- 0.0 t_1)))))
(/ (+ x y) t_2)))))
(if (<= z -2.5e-33)
t_3
(if (<= z 3.1e+37)
(* a (- (/ (+ y t) t_2) (/ (- (* y (- b z)) (* z x)) (* t_2 a))))
t_3))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + (y + t);
double t_2 = t + (x + y);
double t_3 = z * (fma(((y + t) / t_1), (a / z), (b * (y / (z * (0.0 - t_1))))) + ((x + y) / t_2));
double tmp;
if (z <= -2.5e-33) {
tmp = t_3;
} else if (z <= 3.1e+37) {
tmp = a * (((y + t) / t_2) - (((y * (b - z)) - (z * x)) / (t_2 * a)));
} else {
tmp = t_3;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(y + t)) t_2 = Float64(t + Float64(x + y)) t_3 = Float64(z * Float64(fma(Float64(Float64(y + t) / t_1), Float64(a / z), Float64(b * Float64(y / Float64(z * Float64(0.0 - t_1))))) + Float64(Float64(x + y) / t_2))) tmp = 0.0 if (z <= -2.5e-33) tmp = t_3; elseif (z <= 3.1e+37) tmp = Float64(a * Float64(Float64(Float64(y + t) / t_2) - Float64(Float64(Float64(y * Float64(b - z)) - Float64(z * x)) / Float64(t_2 * a)))); else tmp = t_3; end return 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[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(z * N[(N[(N[(N[(y + t), $MachinePrecision] / t$95$1), $MachinePrecision] * N[(a / z), $MachinePrecision] + N[(b * N[(y / N[(z * N[(0.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x + y), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.5e-33], t$95$3, If[LessEqual[z, 3.1e+37], N[(a * N[(N[(N[(y + t), $MachinePrecision] / t$95$2), $MachinePrecision] - N[(N[(N[(y * N[(b - z), $MachinePrecision]), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y + t\right)\\
t_2 := t + \left(x + y\right)\\
t_3 := z \cdot \left(\mathsf{fma}\left(\frac{y + t}{t\_1}, \frac{a}{z}, b \cdot \frac{y}{z \cdot \left(0 - t\_1\right)}\right) + \frac{x + y}{t\_2}\right)\\
\mathbf{if}\;z \leq -2.5 \cdot 10^{-33}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{+37}:\\
\;\;\;\;a \cdot \left(\frac{y + t}{t\_2} - \frac{y \cdot \left(b - z\right) - z \cdot x}{t\_2 \cdot a}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if z < -2.50000000000000014e-33 or 3.1000000000000002e37 < z Initial program 46.6%
Taylor expanded in z around -inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
Simplified71.0%
div-subN/A
*-commutativeN/A
*-commutativeN/A
times-fracN/A
fmm-defN/A
fma-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-+r+N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
neg-lowering-neg.f64N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
Applied egg-rr92.2%
if -2.50000000000000014e-33 < z < 3.1000000000000002e37Initial program 70.6%
Taylor expanded in a around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified85.0%
Final simplification88.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* z (+ x y)) (* a (+ y t))) (* y b)) (+ y (+ x t))))
(t_2 (- (+ z a) b)))
(if (<= t_1 (- INFINITY)) t_2 (if (<= t_1 1e+288) t_1 t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t));
double t_2 = (z + a) - b;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= 1e+288) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t));
double t_2 = (z + a) - b;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 <= 1e+288) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t)) t_2 = (z + a) - b tmp = 0 if t_1 <= -math.inf: tmp = t_2 elif t_1 <= 1e+288: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(z * Float64(x + y)) + Float64(a * Float64(y + t))) - Float64(y * b)) / Float64(y + Float64(x + t))) t_2 = Float64(Float64(z + a) - b) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= 1e+288) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t)); t_2 = (z + a) - b; tmp = 0.0; if (t_1 <= -Inf) tmp = t_2; elseif (t_1 <= 1e+288) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(a * N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 1e+288], t$95$1, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z \cdot \left(x + y\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{y + \left(x + t\right)}\\
t_2 := \left(z + a\right) - b\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+288}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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 1e288 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 6.5%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6468.4%
Simplified68.4%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1e288Initial program 99.7%
Final simplification85.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ z a) b)))
(if (<= y -8.2e+97)
t_1
(if (<= y -1.7e-144)
(/ (- (+ (* z x) (* y (+ z a))) (* y b)) (+ x y))
(if (<= y 1.7e-57)
(* z (- (/ (/ (* t a) z) (+ x t)) (/ -1.0 (+ (/ t x) 1.0))))
t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + a) - b;
double tmp;
if (y <= -8.2e+97) {
tmp = t_1;
} else if (y <= -1.7e-144) {
tmp = (((z * x) + (y * (z + a))) - (y * b)) / (x + y);
} else if (y <= 1.7e-57) {
tmp = z * ((((t * a) / z) / (x + t)) - (-1.0 / ((t / x) + 1.0)));
} 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) :: tmp
t_1 = (z + a) - b
if (y <= (-8.2d+97)) then
tmp = t_1
else if (y <= (-1.7d-144)) then
tmp = (((z * x) + (y * (z + a))) - (y * b)) / (x + y)
else if (y <= 1.7d-57) then
tmp = z * ((((t * a) / z) / (x + t)) - ((-1.0d0) / ((t / x) + 1.0d0)))
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 tmp;
if (y <= -8.2e+97) {
tmp = t_1;
} else if (y <= -1.7e-144) {
tmp = (((z * x) + (y * (z + a))) - (y * b)) / (x + y);
} else if (y <= 1.7e-57) {
tmp = z * ((((t * a) / z) / (x + t)) - (-1.0 / ((t / x) + 1.0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + a) - b tmp = 0 if y <= -8.2e+97: tmp = t_1 elif y <= -1.7e-144: tmp = (((z * x) + (y * (z + a))) - (y * b)) / (x + y) elif y <= 1.7e-57: tmp = z * ((((t * a) / z) / (x + t)) - (-1.0 / ((t / x) + 1.0))) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z + a) - b) tmp = 0.0 if (y <= -8.2e+97) tmp = t_1; elseif (y <= -1.7e-144) tmp = Float64(Float64(Float64(Float64(z * x) + Float64(y * Float64(z + a))) - Float64(y * b)) / Float64(x + y)); elseif (y <= 1.7e-57) tmp = Float64(z * Float64(Float64(Float64(Float64(t * a) / z) / Float64(x + t)) - Float64(-1.0 / Float64(Float64(t / x) + 1.0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z + a) - b; tmp = 0.0; if (y <= -8.2e+97) tmp = t_1; elseif (y <= -1.7e-144) tmp = (((z * x) + (y * (z + a))) - (y * b)) / (x + y); elseif (y <= 1.7e-57) tmp = z * ((((t * a) / z) / (x + t)) - (-1.0 / ((t / x) + 1.0))); 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]}, If[LessEqual[y, -8.2e+97], t$95$1, If[LessEqual[y, -1.7e-144], N[(N[(N[(N[(z * x), $MachinePrecision] + N[(y * N[(z + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.7e-57], N[(z * N[(N[(N[(N[(t * a), $MachinePrecision] / z), $MachinePrecision] / N[(x + t), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[(N[(t / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+97}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-144}:\\
\;\;\;\;\frac{\left(z \cdot x + y \cdot \left(z + a\right)\right) - y \cdot b}{x + y}\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-57}:\\
\;\;\;\;z \cdot \left(\frac{\frac{t \cdot a}{z}}{x + t} - \frac{-1}{\frac{t}{x} + 1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8.19999999999999977e97 or 1.70000000000000008e-57 < y Initial program 40.3%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6477.6%
Simplified77.6%
if -8.19999999999999977e97 < y < -1.70000000000000009e-144Initial program 75.4%
Taylor expanded in t around 0
/-lowering-/.f64N/A
--lowering--.f64N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-+r+N/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6465.2%
Simplified65.2%
if -1.70000000000000009e-144 < y < 1.70000000000000008e-57Initial program 71.9%
Taylor expanded in z around -inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
Simplified78.4%
Taylor expanded in x around inf
*-lowering-*.f64N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6478.4%
Simplified78.4%
Taylor expanded in y around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f6466.9%
Simplified66.9%
Final simplification71.3%
(FPCore (x y z t a b) :precision binary64 (if (<= x -2.7e+129) z (if (<= x 6.8e+141) (- (+ z a) b) z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -2.7e+129) {
tmp = z;
} else if (x <= 6.8e+141) {
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 <= (-2.7d+129)) then
tmp = z
else if (x <= 6.8d+141) 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 <= -2.7e+129) {
tmp = z;
} else if (x <= 6.8e+141) {
tmp = (z + a) - b;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -2.7e+129: tmp = z elif x <= 6.8e+141: tmp = (z + a) - b else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -2.7e+129) tmp = z; elseif (x <= 6.8e+141) 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 <= -2.7e+129) tmp = z; elseif (x <= 6.8e+141) tmp = (z + a) - b; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -2.7e+129], z, If[LessEqual[x, 6.8e+141], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+129}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+141}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -2.7000000000000001e129 or 6.7999999999999996e141 < x Initial program 50.3%
Taylor expanded in x around inf
Simplified55.7%
if -2.7000000000000001e129 < x < 6.7999999999999996e141Initial program 62.6%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6467.2%
Simplified67.2%
Final simplification63.4%
(FPCore (x y z t a b) :precision binary64 (if (<= t 1.2e+126) (- (+ z a) b) (+ a (* y (/ (- z b) t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 1.2e+126) {
tmp = (z + a) - b;
} else {
tmp = a + (y * ((z - b) / t));
}
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 (t <= 1.2d+126) then
tmp = (z + a) - b
else
tmp = a + (y * ((z - b) / t))
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 (t <= 1.2e+126) {
tmp = (z + a) - b;
} else {
tmp = a + (y * ((z - b) / t));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= 1.2e+126: tmp = (z + a) - b else: tmp = a + (y * ((z - b) / t)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 1.2e+126) tmp = Float64(Float64(z + a) - b); else tmp = Float64(a + Float64(y * Float64(Float64(z - b) / t))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= 1.2e+126) tmp = (z + a) - b; else tmp = a + (y * ((z - b) / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 1.2e+126], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(a + N[(y * N[(N[(z - b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.2 \cdot 10^{+126}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;a + y \cdot \frac{z - b}{t}\\
\end{array}
\end{array}
if t < 1.20000000000000006e126Initial program 63.4%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6462.7%
Simplified62.7%
if 1.20000000000000006e126 < t Initial program 31.9%
Taylor expanded in x around 0
/-lowering-/.f64N/A
associate--l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6424.2%
Simplified24.2%
Taylor expanded in t around inf
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
--lowering--.f6450.6%
Simplified50.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f6475.4%
Applied egg-rr75.4%
Final simplification64.7%
(FPCore (x y z t a b) :precision binary64 (if (<= a -1.6e+46) a (if (<= a 8.5e+85) z a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.6e+46) {
tmp = a;
} else if (a <= 8.5e+85) {
tmp = z;
} 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 <= (-1.6d+46)) then
tmp = a
else if (a <= 8.5d+85) then
tmp = z
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 <= -1.6e+46) {
tmp = a;
} else if (a <= 8.5e+85) {
tmp = z;
} else {
tmp = a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -1.6e+46: tmp = a elif a <= 8.5e+85: tmp = z else: tmp = a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.6e+46) tmp = a; elseif (a <= 8.5e+85) tmp = z; else tmp = a; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -1.6e+46) tmp = a; elseif (a <= 8.5e+85) tmp = z; else tmp = a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.6e+46], a, If[LessEqual[a, 8.5e+85], z, a]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+46}:\\
\;\;\;\;a\\
\mathbf{elif}\;a \leq 8.5 \cdot 10^{+85}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if a < -1.5999999999999999e46 or 8.4999999999999994e85 < a Initial program 45.7%
Taylor expanded in t around inf
Simplified56.4%
if -1.5999999999999999e46 < a < 8.4999999999999994e85Initial program 68.0%
Taylor expanded in x around inf
Simplified47.8%
(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 58.6%
Taylor expanded in t around inf
Simplified32.8%
(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 2024150
(FPCore (x y z t a b)
:name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
:precision binary64
:alt
(! :herbie-platform default (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3581311708415056400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 12285964308315609000000000000000000000000000000000000000000000000000000000000000000) (/ 1 (/ (+ (+ 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)))