
(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 11 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 (/ (- (+ (* (+ t y) a) (* z (+ y x))) (* b y)) (+ (+ t x) y))))
(if (<= t_1 (- INFINITY))
(fma y (/ (- z b) (+ t y)) a)
(if (<= t_1 2e+251) t_1 (- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((t + y) * a) + (z * (y + x))) - (b * y)) / ((t + x) + y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(y, ((z - b) / (t + y)), a);
} else if (t_1 <= 2e+251) {
tmp = t_1;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(t + y) * a) + Float64(z * Float64(y + x))) - Float64(b * y)) / Float64(Float64(t + x) + y)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); elseif (t_1 <= 2e+251) tmp = t_1; else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision] + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$1, 2e+251], t$95$1, N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(\left(t + y\right) \cdot a + z \cdot \left(y + x\right)\right) - b \cdot y}{\left(t + x\right) + y}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+251}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\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 5.6%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f647.1
Applied rewrites7.1%
Taylor expanded in a around 0
Applied rewrites79.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)) < 2.0000000000000001e251Initial program 99.7%
if 2.0000000000000001e251 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 9.1%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6481.0
Applied rewrites81.0%
Final simplification90.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ t x) y))
(t_2 (* (+ t y) a))
(t_3 (/ (- (+ t_2 (* z (+ y x))) (* b y)) t_1)))
(if (<= t_3 -1e+109)
(fma y (/ (- z b) (+ t y)) a)
(if (<= t_3 5e-225)
(/ (- (fma x z (* a t)) (* b y)) t_1)
(if (<= t_3 5e+26) (/ (fma (+ y x) z t_2) t_1) (- (+ a z) b))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t + x) + y;
double t_2 = (t + y) * a;
double t_3 = ((t_2 + (z * (y + x))) - (b * y)) / t_1;
double tmp;
if (t_3 <= -1e+109) {
tmp = fma(y, ((z - b) / (t + y)), a);
} else if (t_3 <= 5e-225) {
tmp = (fma(x, z, (a * t)) - (b * y)) / t_1;
} else if (t_3 <= 5e+26) {
tmp = fma((y + x), z, t_2) / t_1;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t + x) + y) t_2 = Float64(Float64(t + y) * a) t_3 = Float64(Float64(Float64(t_2 + Float64(z * Float64(y + x))) - Float64(b * y)) / t_1) tmp = 0.0 if (t_3 <= -1e+109) tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); elseif (t_3 <= 5e-225) tmp = Float64(Float64(fma(x, z, Float64(a * t)) - Float64(b * y)) / t_1); elseif (t_3 <= 5e+26) tmp = Float64(fma(Float64(y + x), z, t_2) / t_1); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$2 + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+109], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$3, 5e-225], N[(N[(N[(x * z + N[(a * t), $MachinePrecision]), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 5e+26], N[(N[(N[(y + x), $MachinePrecision] * z + t$95$2), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t + x\right) + y\\
t_2 := \left(t + y\right) \cdot a\\
t_3 := \frac{\left(t\_2 + z \cdot \left(y + x\right)\right) - b \cdot y}{t\_1}\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{+109}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-225}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, z, a \cdot t\right) - b \cdot y}{t\_1}\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y + x, z, t\_2\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\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)) < -9.99999999999999982e108Initial program 31.3%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6426.6
Applied rewrites26.6%
Taylor expanded in a around 0
Applied rewrites76.8%
if -9.99999999999999982e108 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5.0000000000000001e-225Initial program 99.6%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.1
Applied rewrites86.1%
if 5.0000000000000001e-225 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5.0000000000000001e26Initial program 99.8%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6492.1
Applied rewrites92.1%
if 5.0000000000000001e26 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 36.0%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Final simplification81.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ t x) y))
(t_2 (* (+ t y) a))
(t_3 (/ (- (+ t_2 (* z (+ y x))) (* b y)) t_1)))
(if (<= t_3 -2e+192)
(fma y (/ (- z b) (+ t y)) a)
(if (<= t_3 5e+26) (/ (fma (+ y x) z t_2) t_1) (- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t + x) + y;
double t_2 = (t + y) * a;
double t_3 = ((t_2 + (z * (y + x))) - (b * y)) / t_1;
double tmp;
if (t_3 <= -2e+192) {
tmp = fma(y, ((z - b) / (t + y)), a);
} else if (t_3 <= 5e+26) {
tmp = fma((y + x), z, t_2) / t_1;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t + x) + y) t_2 = Float64(Float64(t + y) * a) t_3 = Float64(Float64(Float64(t_2 + Float64(z * Float64(y + x))) - Float64(b * y)) / t_1) tmp = 0.0 if (t_3 <= -2e+192) tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); elseif (t_3 <= 5e+26) tmp = Float64(fma(Float64(y + x), z, t_2) / t_1); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$2 + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -2e+192], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$3, 5e+26], N[(N[(N[(y + x), $MachinePrecision] * z + t$95$2), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t + x\right) + y\\
t_2 := \left(t + y\right) \cdot a\\
t_3 := \frac{\left(t\_2 + z \cdot \left(y + x\right)\right) - b \cdot y}{t\_1}\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+192}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y + x, z, t\_2\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\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.00000000000000008e192Initial program 16.1%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6415.7
Applied rewrites15.7%
Taylor expanded in a around 0
Applied rewrites78.8%
if -2.00000000000000008e192 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5.0000000000000001e26Initial program 99.7%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6478.1
Applied rewrites78.1%
if 5.0000000000000001e26 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 36.0%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Final simplification78.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= x -4.2e+141)
(+ a z)
(if (<= x 2.9e+62)
(fma y (/ (- z b) (+ t y)) a)
(if (<= x 1e+238) (- (+ a z) b) (/ (- (* z x) (* b y)) (+ (+ t x) y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -4.2e+141) {
tmp = a + z;
} else if (x <= 2.9e+62) {
tmp = fma(y, ((z - b) / (t + y)), a);
} else if (x <= 1e+238) {
tmp = (a + z) - b;
} else {
tmp = ((z * x) - (b * y)) / ((t + x) + y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -4.2e+141) tmp = Float64(a + z); elseif (x <= 2.9e+62) tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); elseif (x <= 1e+238) tmp = Float64(Float64(a + z) - b); else tmp = Float64(Float64(Float64(z * x) - Float64(b * y)) / Float64(Float64(t + x) + y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -4.2e+141], N[(a + z), $MachinePrecision], If[LessEqual[x, 2.9e+62], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[x, 1e+238], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(N[(N[(z * x), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+141}:\\
\;\;\;\;a + z\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\mathbf{elif}\;x \leq 10^{+238}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x - b \cdot y}{\left(t + x\right) + y}\\
\end{array}
\end{array}
if x < -4.1999999999999997e141Initial program 44.2%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6456.5
Applied rewrites56.5%
Taylor expanded in b around 0
Applied rewrites64.6%
if -4.1999999999999997e141 < x < 2.89999999999999984e62Initial program 60.5%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6449.2
Applied rewrites49.2%
Taylor expanded in a around 0
Applied rewrites83.4%
if 2.89999999999999984e62 < x < 1e238Initial program 46.7%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6455.8
Applied rewrites55.8%
if 1e238 < x Initial program 67.8%
Taylor expanded in x around inf
lower-*.f6466.8
Applied rewrites66.8%
Final simplification76.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= x -4.2e+141)
(+ a z)
(if (<= x 2.9e+62)
(fma y (/ (- z b) (+ t y)) a)
(if (<= x 1.45e+242) (- (+ a z) b) (* (/ (- z) b) (- b))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -4.2e+141) {
tmp = a + z;
} else if (x <= 2.9e+62) {
tmp = fma(y, ((z - b) / (t + y)), a);
} else if (x <= 1.45e+242) {
tmp = (a + z) - b;
} else {
tmp = (-z / b) * -b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -4.2e+141) tmp = Float64(a + z); elseif (x <= 2.9e+62) tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); elseif (x <= 1.45e+242) tmp = Float64(Float64(a + z) - b); else tmp = Float64(Float64(Float64(-z) / b) * Float64(-b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -4.2e+141], N[(a + z), $MachinePrecision], If[LessEqual[x, 2.9e+62], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[x, 1.45e+242], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(N[((-z) / b), $MachinePrecision] * (-b)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+141}:\\
\;\;\;\;a + z\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+242}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{b} \cdot \left(-b\right)\\
\end{array}
\end{array}
if x < -4.1999999999999997e141Initial program 44.2%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6456.5
Applied rewrites56.5%
Taylor expanded in b around 0
Applied rewrites64.6%
if -4.1999999999999997e141 < x < 2.89999999999999984e62Initial program 60.5%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6449.2
Applied rewrites49.2%
Taylor expanded in a around 0
Applied rewrites83.4%
if 2.89999999999999984e62 < x < 1.44999999999999999e242Initial program 50.0%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6452.6
Applied rewrites52.6%
if 1.44999999999999999e242 < x Initial program 61.4%
Taylor expanded in b around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
Applied rewrites52.5%
Taylor expanded in t around 0
Applied rewrites88.8%
Taylor expanded in x around inf
Applied rewrites78.9%
Final simplification76.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (/ (- z b) t) y a))) (if (<= t -3.5e+176) t_1 (if (<= t 9.2e+142) (- (+ a z) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(((z - b) / t), y, a);
double tmp;
if (t <= -3.5e+176) {
tmp = t_1;
} else if (t <= 9.2e+142) {
tmp = (a + z) - b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(Float64(z - b) / t), y, a) tmp = 0.0 if (t <= -3.5e+176) tmp = t_1; elseif (t <= 9.2e+142) tmp = Float64(Float64(a + z) - b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(z - b), $MachinePrecision] / t), $MachinePrecision] * y + a), $MachinePrecision]}, If[LessEqual[t, -3.5e+176], t$95$1, If[LessEqual[t, 9.2e+142], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - b}{t}, y, a\right)\\
\mathbf{if}\;t \leq -3.5 \cdot 10^{+176}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9.2 \cdot 10^{+142}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.50000000000000003e176 or 9.20000000000000009e142 < t Initial program 44.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6435.5
Applied rewrites35.5%
Taylor expanded in a around 0
Applied rewrites78.2%
Taylor expanded in y around 0
Applied rewrites72.2%
if -3.50000000000000003e176 < t < 9.20000000000000009e142Initial program 61.3%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6466.8
Applied rewrites66.8%
Final simplification68.2%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.05e+206) (* (/ t (+ t x)) a) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.05e+206) {
tmp = (t / (t + x)) * a;
} else {
tmp = (a + z) - 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 (t <= (-1.05d+206)) then
tmp = (t / (t + x)) * a
else
tmp = (a + z) - 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 (t <= -1.05e+206) {
tmp = (t / (t + x)) * a;
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.05e+206: tmp = (t / (t + x)) * a else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.05e+206) tmp = Float64(Float64(t / Float64(t + x)) * a); else tmp = Float64(Float64(a + z) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.05e+206) tmp = (t / (t + x)) * a; else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.05e+206], N[(N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.05 \cdot 10^{+206}:\\
\;\;\;\;\frac{t}{t + x} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -1.04999999999999993e206Initial program 55.3%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in y around 0
Applied rewrites55.2%
if -1.04999999999999993e206 < t Initial program 57.1%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6465.7
Applied rewrites65.7%
Final simplification64.6%
(FPCore (x y z t a b) :precision binary64 (if (<= z -7.2e-100) (+ a z) (if (<= z 4700000000.0) (- a b) (+ a z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -7.2e-100) {
tmp = a + z;
} else if (z <= 4700000000.0) {
tmp = a - b;
} else {
tmp = a + 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 <= (-7.2d-100)) then
tmp = a + z
else if (z <= 4700000000.0d0) then
tmp = a - b
else
tmp = a + 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 <= -7.2e-100) {
tmp = a + z;
} else if (z <= 4700000000.0) {
tmp = a - b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if z <= -7.2e-100: tmp = a + z elif z <= 4700000000.0: tmp = a - b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -7.2e-100) tmp = Float64(a + z); elseif (z <= 4700000000.0) tmp = Float64(a - b); else tmp = Float64(a + z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (z <= -7.2e-100) tmp = a + z; elseif (z <= 4700000000.0) tmp = a - b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -7.2e-100], N[(a + z), $MachinePrecision], If[LessEqual[z, 4700000000.0], N[(a - b), $MachinePrecision], N[(a + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{-100}:\\
\;\;\;\;a + z\\
\mathbf{elif}\;z \leq 4700000000:\\
\;\;\;\;a - b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if z < -7.1999999999999997e-100 or 4.7e9 < z Initial program 49.1%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6464.2
Applied rewrites64.2%
Taylor expanded in b around 0
Applied rewrites63.5%
if -7.1999999999999997e-100 < z < 4.7e9Initial program 66.4%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6458.6
Applied rewrites58.6%
Taylor expanded in z around 0
Applied rewrites57.7%
Final simplification60.9%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.4e+206) (* 1.0 a) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.4e+206) {
tmp = 1.0 * a;
} else {
tmp = (a + z) - 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 (t <= (-1.4d+206)) then
tmp = 1.0d0 * a
else
tmp = (a + z) - 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 (t <= -1.4e+206) {
tmp = 1.0 * a;
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.4e+206: tmp = 1.0 * a else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.4e+206) tmp = Float64(1.0 * a); else tmp = Float64(Float64(a + z) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.4e+206) tmp = 1.0 * a; else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.4e+206], N[(1.0 * a), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{+206}:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -1.3999999999999999e206Initial program 55.3%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6439.8
Applied rewrites39.8%
Taylor expanded in a around inf
Applied rewrites58.4%
Taylor expanded in a around inf
Applied rewrites51.4%
if -1.3999999999999999e206 < t Initial program 57.1%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6465.7
Applied rewrites65.7%
Final simplification64.2%
(FPCore (x y z t a b) :precision binary64 (if (<= b 1.8e+252) (+ a z) (- b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= 1.8e+252) {
tmp = a + z;
} else {
tmp = -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 (b <= 1.8d+252) then
tmp = a + z
else
tmp = -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 (b <= 1.8e+252) {
tmp = a + z;
} else {
tmp = -b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= 1.8e+252: tmp = a + z else: tmp = -b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= 1.8e+252) tmp = Float64(a + z); else tmp = Float64(-b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= 1.8e+252) tmp = a + z; else tmp = -b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, 1.8e+252], N[(a + z), $MachinePrecision], (-b)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{+252}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;-b\\
\end{array}
\end{array}
if b < 1.7999999999999999e252Initial program 58.3%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6461.9
Applied rewrites61.9%
Taylor expanded in b around 0
Applied rewrites56.7%
if 1.7999999999999999e252 < b Initial program 32.8%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6457.8
Applied rewrites57.8%
Taylor expanded in b around inf
Applied rewrites51.9%
Final simplification56.5%
(FPCore (x y z t a b) :precision binary64 (- b))
double code(double x, double y, double z, double t, double a, double b) {
return -b;
}
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 = -b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return -b;
}
def code(x, y, z, t, a, b): return -b
function code(x, y, z, t, a, b) return Float64(-b) end
function tmp = code(x, y, z, t, a, b) tmp = -b; end
code[x_, y_, z_, t_, a_, b_] := (-b)
\begin{array}{l}
\\
-b
\end{array}
Initial program 56.9%
Taylor expanded in y around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f6461.7
Applied rewrites61.7%
Taylor expanded in b around inf
Applied rewrites14.1%
(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 2024240
(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)))