
(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 9 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 (* z (+ x y)))
(t_3 (/ (- (+ t_2 (* (+ y t) a)) (* y b)) t_1)))
(if (<= t_3 (- INFINITY))
(fma (+ y t) (/ a (+ t (+ x y))) z)
(if (<= t_3 1e+271)
(/ (- (+ t_2 (fma y a (* t a))) (* y b)) t_1)
(fma y (/ (- z b) (+ y t)) a)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (x + t);
double t_2 = z * (x + y);
double t_3 = ((t_2 + ((y + t) * a)) - (y * b)) / t_1;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = fma((y + t), (a / (t + (x + y))), z);
} else if (t_3 <= 1e+271) {
tmp = ((t_2 + fma(y, a, (t * a))) - (y * b)) / t_1;
} else {
tmp = fma(y, ((z - b) / (y + t)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(y + Float64(x + t)) t_2 = Float64(z * Float64(x + y)) t_3 = Float64(Float64(Float64(t_2 + Float64(Float64(y + t) * a)) - Float64(y * b)) / t_1) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = fma(Float64(y + t), Float64(a / Float64(t + Float64(x + y))), z); elseif (t_3 <= 1e+271) tmp = Float64(Float64(Float64(t_2 + fma(y, a, Float64(t * a))) - Float64(y * b)) / t_1); else tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); end return 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[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$2 + N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(y + t), $MachinePrecision] * N[(a / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[t$95$3, 1e+271], N[(N[(N[(t$95$2 + N[(y * a + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y + \left(x + t\right)\\
t_2 := z \cdot \left(x + y\right)\\
t_3 := \frac{\left(t\_2 + \left(y + t\right) \cdot a\right) - y \cdot b}{t\_1}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y + t, \frac{a}{t + \left(x + y\right)}, z\right)\\
\mathbf{elif}\;t\_3 \leq 10^{+271}:\\
\;\;\;\;\frac{\left(t\_2 + \mathsf{fma}\left(y, a, t \cdot a\right)\right) - y \cdot b}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\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.0Initial program 6.4%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified40.6%
Taylor expanded in x around inf
Simplified74.9%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 9.99999999999999953e270Initial program 99.6%
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6499.6
Applied egg-rr99.6%
if 9.99999999999999953e270 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 4.8%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified21.6%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6479.7
Simplified79.7%
Final simplification90.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b)) (+ y (+ x t)))))
(if (<= t_1 (- INFINITY))
(fma (+ y t) (/ a (+ t (+ x y))) z)
(if (<= t_1 1e+271) t_1 (fma y (/ (- z b) (+ y t)) a)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((z * (x + y)) + ((y + t) * a)) - (y * b)) / (y + (x + t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((y + t), (a / (t + (x + y))), z);
} else if (t_1 <= 1e+271) {
tmp = t_1;
} else {
tmp = fma(y, ((z - b) / (y + t)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(z * Float64(x + y)) + Float64(Float64(y + t) * a)) - Float64(y * b)) / Float64(y + Float64(x + t))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(y + t), Float64(a / Float64(t + Float64(x + y))), z); elseif (t_1 <= 1e+271) tmp = t_1; else tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(y + t), $MachinePrecision] * N[(a / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[t$95$1, 1e+271], t$95$1, N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y + t, \frac{a}{t + \left(x + y\right)}, z\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+271}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\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.0Initial program 6.4%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified40.6%
Taylor expanded in x around inf
Simplified74.9%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 9.99999999999999953e270Initial program 99.6%
if 9.99999999999999953e270 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 4.8%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified21.6%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6479.7
Simplified79.7%
Final simplification90.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (+ y t) (/ a (+ t (+ x y))) z)))
(if (<= x -3.05e+69)
t_1
(if (<= x 6.4e+72) (fma y (/ (- z b) (+ y t)) a) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((y + t), (a / (t + (x + y))), z);
double tmp;
if (x <= -3.05e+69) {
tmp = t_1;
} else if (x <= 6.4e+72) {
tmp = fma(y, ((z - b) / (y + t)), a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(y + t), Float64(a / Float64(t + Float64(x + y))), z) tmp = 0.0 if (x <= -3.05e+69) tmp = t_1; elseif (x <= 6.4e+72) tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y + t), $MachinePrecision] * N[(a / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[x, -3.05e+69], t$95$1, If[LessEqual[x, 6.4e+72], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y + t, \frac{a}{t + \left(x + y\right)}, z\right)\\
\mathbf{if}\;x \leq -3.05 \cdot 10^{+69}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{+72}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.05e69 or 6.4000000000000003e72 < x Initial program 47.0%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified57.2%
Taylor expanded in x around inf
Simplified79.7%
if -3.05e69 < x < 6.4000000000000003e72Initial program 67.0%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified72.7%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6483.8
Simplified83.8%
Final simplification82.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma a (/ t (+ x t)) z)))
(if (<= x -6.2e+74)
t_1
(if (<= x 1.02e+157) (fma y (/ (- z b) (+ y t)) a) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, (t / (x + t)), z);
double tmp;
if (x <= -6.2e+74) {
tmp = t_1;
} else if (x <= 1.02e+157) {
tmp = fma(y, ((z - b) / (y + t)), a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(a, Float64(t / Float64(x + t)), z) tmp = 0.0 if (x <= -6.2e+74) tmp = t_1; elseif (x <= 1.02e+157) tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(t / N[(x + t), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[x, -6.2e+74], t$95$1, If[LessEqual[x, 1.02e+157], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, \frac{t}{x + t}, z\right)\\
\mathbf{if}\;x \leq -6.2 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -6.20000000000000043e74 or 1.02000000000000003e157 < x Initial program 48.2%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified57.8%
Taylor expanded in x around inf
Simplified85.4%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6478.5
Simplified78.5%
if -6.20000000000000043e74 < x < 1.02000000000000003e157Initial program 64.6%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified71.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6480.8
Simplified80.8%
Final simplification80.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ a (- z b)))) (if (<= y -4.4e+16) t_1 (if (<= y 1.04e+127) (fma a (/ t (+ x t)) z) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a + (z - b);
double tmp;
if (y <= -4.4e+16) {
tmp = t_1;
} else if (y <= 1.04e+127) {
tmp = fma(a, (t / (x + t)), z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a + Float64(z - b)) tmp = 0.0 if (y <= -4.4e+16) tmp = t_1; elseif (y <= 1.04e+127) tmp = fma(a, Float64(t / Float64(x + t)), z); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a + N[(z - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.4e+16], t$95$1, If[LessEqual[y, 1.04e+127], N[(a * N[(t / N[(x + t), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a + \left(z - b\right)\\
\mathbf{if}\;y \leq -4.4 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.04 \cdot 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{x + t}, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.4e16 or 1.04e127 < y Initial program 39.2%
Taylor expanded in y around inf
associate--l+N/A
+-lowering-+.f64N/A
--lowering--.f6481.8
Simplified81.8%
if -4.4e16 < y < 1.04e127Initial program 72.0%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
Simplified80.3%
Taylor expanded in x around inf
Simplified64.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6462.2
Simplified62.2%
Final simplification69.6%
(FPCore (x y z t a b) :precision binary64 (if (<= x -1.85e+169) z (if (<= x 2.2e+157) (+ a (- z b)) z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -1.85e+169) {
tmp = z;
} else if (x <= 2.2e+157) {
tmp = a + (z - 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 <= (-1.85d+169)) then
tmp = z
else if (x <= 2.2d+157) then
tmp = a + (z - 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 <= -1.85e+169) {
tmp = z;
} else if (x <= 2.2e+157) {
tmp = a + (z - b);
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -1.85e+169: tmp = z elif x <= 2.2e+157: tmp = a + (z - b) else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -1.85e+169) tmp = z; elseif (x <= 2.2e+157) tmp = Float64(a + Float64(z - b)); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -1.85e+169) tmp = z; elseif (x <= 2.2e+157) tmp = a + (z - b); else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -1.85e+169], z, If[LessEqual[x, 2.2e+157], N[(a + N[(z - b), $MachinePrecision]), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{+169}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+157}:\\
\;\;\;\;a + \left(z - b\right)\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -1.85e169 or 2.2000000000000001e157 < x Initial program 50.5%
Taylor expanded in x around inf
Simplified72.1%
if -1.85e169 < x < 2.2000000000000001e157Initial program 62.3%
Taylor expanded in y around inf
associate--l+N/A
+-lowering-+.f64N/A
--lowering--.f6462.3
Simplified62.3%
(FPCore (x y z t a b) :precision binary64 (if (<= x -8.5e+39) z (if (<= x 5.8e+38) a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -8.5e+39) {
tmp = z;
} else if (x <= 5.8e+38) {
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 (x <= (-8.5d+39)) then
tmp = z
else if (x <= 5.8d+38) 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 (x <= -8.5e+39) {
tmp = z;
} else if (x <= 5.8e+38) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -8.5e+39: tmp = z elif x <= 5.8e+38: tmp = a else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -8.5e+39) tmp = z; elseif (x <= 5.8e+38) tmp = a; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -8.5e+39) tmp = z; elseif (x <= 5.8e+38) tmp = a; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -8.5e+39], z, If[LessEqual[x, 5.8e+38], a, z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+39}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+38}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -8.49999999999999971e39 or 5.80000000000000013e38 < x Initial program 47.9%
Taylor expanded in x around inf
Simplified56.9%
if -8.49999999999999971e39 < x < 5.80000000000000013e38Initial program 68.5%
Taylor expanded in t around inf
Simplified45.8%
(FPCore (x y z t a b) :precision binary64 (if (<= x -8.8e+173) z (+ z a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -8.8e+173) {
tmp = z;
} else {
tmp = z + 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 (x <= (-8.8d+173)) then
tmp = z
else
tmp = z + 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 (x <= -8.8e+173) {
tmp = z;
} else {
tmp = z + a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -8.8e+173: tmp = z else: tmp = z + a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -8.8e+173) tmp = z; else tmp = Float64(z + a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -8.8e+173) tmp = z; else tmp = z + a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -8.8e+173], z, N[(z + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+173}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;z + a\\
\end{array}
\end{array}
if x < -8.7999999999999999e173Initial program 44.1%
Taylor expanded in x around inf
Simplified71.3%
if -8.7999999999999999e173 < x Initial program 61.9%
Taylor expanded in b around 0
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6447.2
Simplified47.2%
Taylor expanded in y around inf
+-lowering-+.f6454.5
Simplified54.5%
Final simplification56.7%
(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 59.6%
Taylor expanded in t around inf
Simplified32.6%
(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 2024201
(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)))