
(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 12 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 (/ (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b)) (+ y (+ x t)))))
(if (<= t_1 -2e+273)
(- (+ z a) b)
(if (<= t_1 2e+260) t_1 (fma (+ y t) (/ a (+ t (+ x y))) z)))))
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 <= -2e+273) {
tmp = (z + a) - b;
} else if (t_1 <= 2e+260) {
tmp = t_1;
} else {
tmp = fma((y + t), (a / (t + (x + y))), z);
}
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 <= -2e+273) tmp = Float64(Float64(z + a) - b); elseif (t_1 <= 2e+260) tmp = t_1; else tmp = fma(Float64(y + t), Float64(a / Float64(t + Float64(x + y))), z); 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, -2e+273], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], If[LessEqual[t$95$1, 2e+260], t$95$1, N[(N[(y + t), $MachinePrecision] * N[(a / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + z), $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 -2 \cdot 10^{+273}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+260}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y + t, \frac{a}{t + \left(x + y\right)}, z\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)) < -1.99999999999999989e273Initial program 9.9%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6484.4
Simplified84.4%
if -1.99999999999999989e273 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.00000000000000013e260Initial program 99.6%
if 2.00000000000000013e260 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 5.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
Simplified38.5%
Taylor expanded in x around inf
Simplified86.2%
Final simplification93.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b)) (+ y (+ x t))))
(t_2 (- (+ z a) b)))
(if (<= t_1 -2e+64) t_2 (if (<= t_1 5e+92) (fma a (/ y (+ x y)) z) t_2))))
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 t_2 = (z + a) - b;
double tmp;
if (t_1 <= -2e+64) {
tmp = t_2;
} else if (t_1 <= 5e+92) {
tmp = fma(a, (y / (x + y)), z);
} 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(Float64(y + t) * a)) - Float64(y * b)) / Float64(y + Float64(x + t))) t_2 = Float64(Float64(z + a) - b) tmp = 0.0 if (t_1 <= -2e+64) tmp = t_2; elseif (t_1 <= 5e+92) tmp = fma(a, Float64(y / Float64(x + y)), z); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+64], t$95$2, If[LessEqual[t$95$1, 5e+92], N[(a * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$2]]]]
\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)}\\
t_2 := \left(z + a\right) - b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+64}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{x + y}, z\right)\\
\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)) < -2.00000000000000004e64 or 5.00000000000000022e92 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 30.4%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6478.2
Simplified78.2%
if -2.00000000000000004e64 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5.00000000000000022e92Initial program 99.7%
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
Simplified92.2%
Taylor expanded in x around inf
Simplified48.8%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6444.7
Simplified44.7%
Final simplification64.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (+ y t) (/ a (+ t (+ x y))) z)))
(if (<= x -3.7e+84)
t_1
(if (<= x -3e-43)
(/ (fma z x (* y (- z b))) (+ y (+ x t)))
(if (<= x 0.022) (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.7e+84) {
tmp = t_1;
} else if (x <= -3e-43) {
tmp = fma(z, x, (y * (z - b))) / (y + (x + t));
} else if (x <= 0.022) {
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.7e+84) tmp = t_1; elseif (x <= -3e-43) tmp = Float64(fma(z, x, Float64(y * Float64(z - b))) / Float64(y + Float64(x + t))); elseif (x <= 0.022) 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.7e+84], t$95$1, If[LessEqual[x, -3e-43], N[(N[(z * x + N[(y * N[(z - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.022], 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.7 \cdot 10^{+84}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-43}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, y \cdot \left(z - b\right)\right)}{y + \left(x + t\right)}\\
\mathbf{elif}\;x \leq 0.022:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.7e84 or 0.021999999999999999 < x Initial program 48.3%
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
Simplified58.6%
Taylor expanded in x around inf
Simplified83.1%
if -3.7e84 < x < -3.00000000000000003e-43Initial program 78.3%
Taylor expanded in a around 0
distribute-rgt-inN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f6465.2
Simplified65.2%
if -3.00000000000000003e-43 < x < 0.021999999999999999Initial program 65.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
Simplified75.9%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-lowering-+.f6485.9
Simplified85.9%
Final simplification82.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (+ y t) (/ a (+ t (+ x y))) z)))
(if (<= x -5.1e+19)
t_1
(if (<= x 0.055) (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 <= -5.1e+19) {
tmp = t_1;
} else if (x <= 0.055) {
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 <= -5.1e+19) tmp = t_1; elseif (x <= 0.055) 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, -5.1e+19], t$95$1, If[LessEqual[x, 0.055], 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 -5.1 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.055:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -5.1e19 or 0.0550000000000000003 < x Initial program 52.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
Simplified61.9%
Taylor expanded in x around inf
Simplified79.1%
if -5.1e19 < x < 0.0550000000000000003Initial program 66.7%
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
Simplified77.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-lowering-+.f6482.0
Simplified82.0%
Final simplification80.6%
(FPCore (x y z t a b) :precision binary64 (if (<= x -2.9e+195) (fma (+ y t) (/ a x) z) (if (<= x 1.45e+29) (fma y (/ (- z b) (+ y t)) a) (fma a (/ y (+ x y)) z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -2.9e+195) {
tmp = fma((y + t), (a / x), z);
} else if (x <= 1.45e+29) {
tmp = fma(y, ((z - b) / (y + t)), a);
} else {
tmp = fma(a, (y / (x + y)), z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -2.9e+195) tmp = fma(Float64(y + t), Float64(a / x), z); elseif (x <= 1.45e+29) tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); else tmp = fma(a, Float64(y / Float64(x + y)), z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -2.9e+195], N[(N[(y + t), $MachinePrecision] * N[(a / x), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[x, 1.45e+29], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(a * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+195}:\\
\;\;\;\;\mathsf{fma}\left(y + t, \frac{a}{x}, z\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{x + y}, z\right)\\
\end{array}
\end{array}
if x < -2.89999999999999992e195Initial program 47.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
Simplified51.1%
Taylor expanded in x around inf
Simplified87.9%
Taylor expanded in x around inf
/-lowering-/.f6484.1
Simplified84.1%
if -2.89999999999999992e195 < x < 1.45e29Initial program 63.5%
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
Simplified75.9%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-lowering-+.f6475.7
Simplified75.7%
if 1.45e29 < x Initial program 53.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
Simplified60.2%
Taylor expanded in x around inf
Simplified80.9%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6467.2
Simplified67.2%
Final simplification74.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (+ y t) (/ a x) z))) (if (<= x -9.4e+24) t_1 (if (<= x 4.5e+62) (- (+ z a) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((y + t), (a / x), z);
double tmp;
if (x <= -9.4e+24) {
tmp = t_1;
} else if (x <= 4.5e+62) {
tmp = (z + a) - b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(y + t), Float64(a / x), z) tmp = 0.0 if (x <= -9.4e+24) tmp = t_1; elseif (x <= 4.5e+62) tmp = Float64(Float64(z + a) - b); 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 / x), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[x, -9.4e+24], t$95$1, If[LessEqual[x, 4.5e+62], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y + t, \frac{a}{x}, z\right)\\
\mathbf{if}\;x \leq -9.4 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+62}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -9.3999999999999999e24 or 4.49999999999999999e62 < x Initial program 53.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
Simplified59.7%
Taylor expanded in x around inf
Simplified78.7%
Taylor expanded in x around inf
/-lowering-/.f6466.8
Simplified66.8%
if -9.3999999999999999e24 < x < 4.49999999999999999e62Initial program 64.5%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6462.7
Simplified62.7%
Final simplification64.4%
(FPCore (x y z t a b) :precision binary64 (if (<= x -6.8e+195) (fma t (/ a x) z) (if (<= x 1.12e+115) (- (+ z a) b) (fma y (/ a x) z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -6.8e+195) {
tmp = fma(t, (a / x), z);
} else if (x <= 1.12e+115) {
tmp = (z + a) - b;
} else {
tmp = fma(y, (a / x), z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -6.8e+195) tmp = fma(t, Float64(a / x), z); elseif (x <= 1.12e+115) tmp = Float64(Float64(z + a) - b); else tmp = fma(y, Float64(a / x), z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -6.8e+195], N[(t * N[(a / x), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[x, 1.12e+115], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(y * N[(a / x), $MachinePrecision] + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+195}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{a}{x}, z\right)\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{+115}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{a}{x}, z\right)\\
\end{array}
\end{array}
if x < -6.80000000000000021e195Initial program 47.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
Simplified51.1%
Taylor expanded in x around inf
Simplified87.9%
Taylor expanded in x around inf
/-lowering-/.f6484.1
Simplified84.1%
Taylor expanded in t around inf
Simplified76.7%
if -6.80000000000000021e195 < x < 1.12e115Initial program 63.9%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6459.5
Simplified59.5%
if 1.12e115 < x Initial program 46.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
Simplified51.6%
Taylor expanded in x around inf
Simplified84.6%
Taylor expanded in x around inf
/-lowering-/.f6474.1
Simplified74.1%
Taylor expanded in t around 0
Simplified68.8%
Final simplification62.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma t (/ a x) z))) (if (<= x -3.7e+200) t_1 (if (<= x 5.9e+63) (- (+ z a) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, (a / x), z);
double tmp;
if (x <= -3.7e+200) {
tmp = t_1;
} else if (x <= 5.9e+63) {
tmp = (z + a) - b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(t, Float64(a / x), z) tmp = 0.0 if (x <= -3.7e+200) tmp = t_1; elseif (x <= 5.9e+63) tmp = Float64(Float64(z + a) - b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * N[(a / x), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[x, -3.7e+200], t$95$1, If[LessEqual[x, 5.9e+63], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, \frac{a}{x}, z\right)\\
\mathbf{if}\;x \leq -3.7 \cdot 10^{+200}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{+63}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.7000000000000001e200 or 5.90000000000000029e63 < x Initial program 52.1%
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
Simplified83.6%
Taylor expanded in x around inf
/-lowering-/.f6474.5
Simplified74.5%
Taylor expanded in t around inf
Simplified68.0%
if -3.7000000000000001e200 < x < 5.90000000000000029e63Initial program 62.7%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6460.0
Simplified60.0%
Final simplification62.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (- (+ z a) b))) (if (<= y -6.5e-129) t_1 (if (<= y 20000000000.0) (+ z a) 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 <= -6.5e-129) {
tmp = t_1;
} else if (y <= 20000000000.0) {
tmp = z + a;
} 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 <= (-6.5d-129)) then
tmp = t_1
else if (y <= 20000000000.0d0) then
tmp = z + a
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 <= -6.5e-129) {
tmp = t_1;
} else if (y <= 20000000000.0) {
tmp = z + a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + a) - b tmp = 0 if y <= -6.5e-129: tmp = t_1 elif y <= 20000000000.0: tmp = z + a 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 <= -6.5e-129) tmp = t_1; elseif (y <= 20000000000.0) tmp = Float64(z + a); 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 <= -6.5e-129) tmp = t_1; elseif (y <= 20000000000.0) tmp = z + a; 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, -6.5e-129], t$95$1, If[LessEqual[y, 20000000000.0], N[(z + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{-129}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 20000000000:\\
\;\;\;\;z + a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.49999999999999952e-129 or 2e10 < y Initial program 46.8%
Taylor expanded in y around inf
--lowering--.f64N/A
+-lowering-+.f6474.1
Simplified74.1%
if -6.49999999999999952e-129 < y < 2e10Initial program 74.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
Simplified79.8%
Taylor expanded in x around inf
Simplified62.6%
Taylor expanded in t around inf
+-commutativeN/A
+-lowering-+.f6446.5
Simplified46.5%
Final simplification61.3%
(FPCore (x y z t a b) :precision binary64 (if (<= t -4.8e+100) a (if (<= t 4.4e+70) z a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -4.8e+100) {
tmp = a;
} else if (t <= 4.4e+70) {
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 (t <= (-4.8d+100)) then
tmp = a
else if (t <= 4.4d+70) 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 (t <= -4.8e+100) {
tmp = a;
} else if (t <= 4.4e+70) {
tmp = z;
} else {
tmp = a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -4.8e+100: tmp = a elif t <= 4.4e+70: tmp = z else: tmp = a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -4.8e+100) tmp = a; elseif (t <= 4.4e+70) tmp = z; else tmp = a; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -4.8e+100) tmp = a; elseif (t <= 4.4e+70) tmp = z; else tmp = a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -4.8e+100], a, If[LessEqual[t, 4.4e+70], z, a]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.8 \cdot 10^{+100}:\\
\;\;\;\;a\\
\mathbf{elif}\;t \leq 4.4 \cdot 10^{+70}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if t < -4.80000000000000023e100 or 4.40000000000000001e70 < t Initial program 57.3%
Taylor expanded in t around inf
Simplified57.2%
if -4.80000000000000023e100 < t < 4.40000000000000001e70Initial program 61.1%
Taylor expanded in x around inf
Simplified45.3%
(FPCore (x y z t a b) :precision binary64 (if (<= x 4.1e+186) (+ z a) z))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 4.1e+186) {
tmp = z + 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 <= 4.1d+186) then
tmp = z + 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 <= 4.1e+186) {
tmp = z + a;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= 4.1e+186: tmp = z + a else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= 4.1e+186) tmp = Float64(z + a); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= 4.1e+186) tmp = z + a; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, 4.1e+186], N[(z + a), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.1 \cdot 10^{+186}:\\
\;\;\;\;z + a\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < 4.1e186Initial program 61.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
Simplified72.0%
Taylor expanded in x around inf
Simplified61.9%
Taylor expanded in t around inf
+-commutativeN/A
+-lowering-+.f6453.6
Simplified53.6%
if 4.1e186 < x Initial program 40.4%
Taylor expanded in x around inf
Simplified64.2%
(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.9%
(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 2024195
(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)))