
(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 13 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 (- (+ a z) b))
(t_2 (+ (+ x t) y))
(t_3 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) t_2)))
(if (<= t_3 -5e+307)
(fma (- z b) (/ y (+ t y)) a)
(if (<= t_3 2e+287) (/ (fma t_1 y (fma a t (* z x))) t_2) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a + z) - b;
double t_2 = (x + t) + y;
double t_3 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / t_2;
double tmp;
if (t_3 <= -5e+307) {
tmp = fma((z - b), (y / (t + y)), a);
} else if (t_3 <= 2e+287) {
tmp = fma(t_1, y, fma(a, t, (z * x))) / t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + z) - b) t_2 = Float64(Float64(x + t) + y) t_3 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / t_2) tmp = 0.0 if (t_3 <= -5e+307) tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); elseif (t_3 <= 2e+287) tmp = Float64(fma(t_1, y, fma(a, t, Float64(z * x))) / t_2); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e+307], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$3, 2e+287], N[(N[(t$95$1 * y + N[(a * t + N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
t_2 := \left(x + t\right) + y\\
t_3 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{t\_2}\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_1, y, \mathsf{fma}\left(a, t, z \cdot x\right)\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -5e307Initial program 8.3%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6414.5
Applied rewrites14.5%
Taylor expanded in a around 0
Applied rewrites85.3%
Applied rewrites88.8%
if -5e307 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.0000000000000002e287Initial program 99.8%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
if 2.0000000000000002e287 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 5.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6483.3
Applied rewrites83.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -2.3e-122) (not (<= y 1.4e-145))) (fma (- z b) (/ y (+ t y)) a) (/ (fma (+ y x) z (* (+ t y) a)) (+ (+ y x) t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -2.3e-122) || !(y <= 1.4e-145)) {
tmp = fma((z - b), (y / (t + y)), a);
} else {
tmp = fma((y + x), z, ((t + y) * a)) / ((y + x) + t);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -2.3e-122) || !(y <= 1.4e-145)) tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); else tmp = Float64(fma(Float64(y + x), z, Float64(Float64(t + y) * a)) / Float64(Float64(y + x) + t)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -2.3e-122], N[Not[LessEqual[y, 1.4e-145]], $MachinePrecision]], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] * z + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-122} \lor \neg \left(y \leq 1.4 \cdot 10^{-145}\right):\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y + x, z, \left(t + y\right) \cdot a\right)}{\left(y + x\right) + t}\\
\end{array}
\end{array}
if y < -2.30000000000000007e-122 or 1.4000000000000001e-145 < y Initial program 56.8%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6449.7
Applied rewrites49.7%
Taylor expanded in a around 0
Applied rewrites85.1%
Applied rewrites86.3%
if -2.30000000000000007e-122 < y < 1.4000000000000001e-145Initial program 82.3%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6474.1
Applied rewrites74.1%
Final simplification83.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -1.55e+44) (not (<= t 10500000000.0))) (fma y (/ (- b) (+ t y)) a) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -1.55e+44) || !(t <= 10500000000.0)) {
tmp = fma(y, (-b / (t + y)), a);
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -1.55e+44) || !(t <= 10500000000.0)) tmp = fma(y, Float64(Float64(-b) / Float64(t + y)), a); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -1.55e+44], N[Not[LessEqual[t, 10500000000.0]], $MachinePrecision]], N[(y * N[((-b) / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.55 \cdot 10^{+44} \lor \neg \left(t \leq 10500000000\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-b}{t + y}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -1.54999999999999998e44 or 1.05e10 < t Initial program 61.2%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6451.6
Applied rewrites51.6%
Taylor expanded in a around 0
Applied rewrites83.6%
Taylor expanded in z around 0
Applied rewrites72.2%
if -1.54999999999999998e44 < t < 1.05e10Initial program 66.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6469.1
Applied rewrites69.1%
Final simplification70.5%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.55e+44) (fma y (/ (- b) (+ t y)) a) (if (<= t 10500000000.0) (- (+ a z) b) (fma (- b) (/ y (+ t y)) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.55e+44) {
tmp = fma(y, (-b / (t + y)), a);
} else if (t <= 10500000000.0) {
tmp = (a + z) - b;
} else {
tmp = fma(-b, (y / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.55e+44) tmp = fma(y, Float64(Float64(-b) / Float64(t + y)), a); elseif (t <= 10500000000.0) tmp = Float64(Float64(a + z) - b); else tmp = fma(Float64(-b), Float64(y / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.55e+44], N[(y * N[((-b) / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t, 10500000000.0], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[((-b) * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.55 \cdot 10^{+44}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-b}{t + y}, a\right)\\
\mathbf{elif}\;t \leq 10500000000:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-b, \frac{y}{t + y}, a\right)\\
\end{array}
\end{array}
if t < -1.54999999999999998e44Initial program 64.9%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6457.7
Applied rewrites57.7%
Taylor expanded in a around 0
Applied rewrites84.3%
Taylor expanded in z around 0
Applied rewrites70.0%
if -1.54999999999999998e44 < t < 1.05e10Initial program 66.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6469.1
Applied rewrites69.1%
if 1.05e10 < t Initial program 58.9%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6447.7
Applied rewrites47.7%
Taylor expanded in a around 0
Applied rewrites83.1%
Applied rewrites83.1%
Taylor expanded in z around 0
Applied rewrites73.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -3.5e+44) (not (<= t 1.65e+152))) (fma y (/ (- z b) t) a) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -3.5e+44) || !(t <= 1.65e+152)) {
tmp = fma(y, ((z - b) / t), a);
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -3.5e+44) || !(t <= 1.65e+152)) tmp = fma(y, Float64(Float64(z - b) / t), a); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -3.5e+44], N[Not[LessEqual[t, 1.65e+152]], $MachinePrecision]], N[(y * N[(N[(z - b), $MachinePrecision] / t), $MachinePrecision] + a), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.5 \cdot 10^{+44} \lor \neg \left(t \leq 1.65 \cdot 10^{+152}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -3.4999999999999999e44 or 1.6500000000000001e152 < t Initial program 60.7%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6454.4
Applied rewrites54.4%
Taylor expanded in t around inf
Applied rewrites74.4%
if -3.4999999999999999e44 < t < 1.6500000000000001e152Initial program 65.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6466.0
Applied rewrites66.0%
Final simplification68.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ a z) b)))
(if (<= y -30500000.0)
t_1
(if (<= y -4.5e-176)
(fma (/ (- b) t) y a)
(if (<= y 4.8e+70) (+ a 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 <= -30500000.0) {
tmp = t_1;
} else if (y <= -4.5e-176) {
tmp = fma((-b / t), y, a);
} else if (y <= 4.8e+70) {
tmp = a + z;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + z) - b) tmp = 0.0 if (y <= -30500000.0) tmp = t_1; elseif (y <= -4.5e-176) tmp = fma(Float64(Float64(-b) / t), y, a); elseif (y <= 4.8e+70) tmp = Float64(a + z); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -30500000.0], t$95$1, If[LessEqual[y, -4.5e-176], N[(N[((-b) / t), $MachinePrecision] * y + a), $MachinePrecision], If[LessEqual[y, 4.8e+70], N[(a + z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
\mathbf{if}\;y \leq -30500000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-176}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-b}{t}, y, a\right)\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+70}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.05e7 or 4.79999999999999974e70 < y Initial program 43.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6481.1
Applied rewrites81.1%
if -3.05e7 < y < -4.5e-176Initial program 77.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6453.3
Applied rewrites53.3%
Taylor expanded in a around 0
Applied rewrites67.1%
Taylor expanded in y around 0
Applied rewrites64.2%
Taylor expanded in z around 0
Applied rewrites61.4%
if -4.5e-176 < y < 4.79999999999999974e70Initial program 81.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6442.2
Applied rewrites42.2%
Taylor expanded in b around inf
Applied rewrites3.5%
Taylor expanded in b around 0
Applied rewrites58.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ a z) b)))
(if (<= y -13000000.0)
t_1
(if (<= y -6.5e-46)
(* a (/ t (+ t x)))
(if (<= y 4.8e+70) (+ a 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 <= -13000000.0) {
tmp = t_1;
} else if (y <= -6.5e-46) {
tmp = a * (t / (t + x));
} else if (y <= 4.8e+70) {
tmp = a + z;
} 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 = (a + z) - b
if (y <= (-13000000.0d0)) then
tmp = t_1
else if (y <= (-6.5d-46)) then
tmp = a * (t / (t + x))
else if (y <= 4.8d+70) then
tmp = a + z
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 = (a + z) - b;
double tmp;
if (y <= -13000000.0) {
tmp = t_1;
} else if (y <= -6.5e-46) {
tmp = a * (t / (t + x));
} else if (y <= 4.8e+70) {
tmp = a + z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a + z) - b tmp = 0 if y <= -13000000.0: tmp = t_1 elif y <= -6.5e-46: tmp = a * (t / (t + x)) elif y <= 4.8e+70: tmp = a + z else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + z) - b) tmp = 0.0 if (y <= -13000000.0) tmp = t_1; elseif (y <= -6.5e-46) tmp = Float64(a * Float64(t / Float64(t + x))); elseif (y <= 4.8e+70) tmp = Float64(a + z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a + z) - b; tmp = 0.0; if (y <= -13000000.0) tmp = t_1; elseif (y <= -6.5e-46) tmp = a * (t / (t + x)); elseif (y <= 4.8e+70) tmp = a + z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -13000000.0], t$95$1, If[LessEqual[y, -6.5e-46], N[(a * N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+70], N[(a + z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
\mathbf{if}\;y \leq -13000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-46}:\\
\;\;\;\;a \cdot \frac{t}{t + x}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+70}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.3e7 or 4.79999999999999974e70 < y Initial program 43.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6481.1
Applied rewrites81.1%
if -1.3e7 < y < -6.49999999999999966e-46Initial program 77.9%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6456.4
Applied rewrites56.4%
Taylor expanded in y around 0
Applied rewrites70.2%
if -6.49999999999999966e-46 < y < 4.79999999999999974e70Initial program 80.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6441.7
Applied rewrites41.7%
Taylor expanded in b around inf
Applied rewrites3.3%
Taylor expanded in b around 0
Applied rewrites55.1%
(FPCore (x y z t a b) :precision binary64 (if (<= x 1.65e+149) (fma (- z b) (/ y (+ t y)) a) (- z (/ (* (- b a) y) x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 1.65e+149) {
tmp = fma((z - b), (y / (t + y)), a);
} else {
tmp = z - (((b - a) * y) / x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= 1.65e+149) tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); else tmp = Float64(z - Float64(Float64(Float64(b - a) * y) / x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, 1.65e+149], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(z - N[(N[(N[(b - a), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\mathbf{else}:\\
\;\;\;\;z - \frac{\left(b - a\right) \cdot y}{x}\\
\end{array}
\end{array}
if x < 1.65e149Initial program 64.3%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6452.5
Applied rewrites52.5%
Taylor expanded in a around 0
Applied rewrites79.4%
Applied rewrites81.9%
if 1.65e149 < x Initial program 59.6%
Taylor expanded in x around -inf
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites71.0%
Taylor expanded in y around inf
Applied rewrites67.1%
(FPCore (x y z t a b) :precision binary64 (if (<= x 1.65e+149) (fma y (/ (- z b) (+ t y)) a) (- z (/ (* (- b a) y) x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 1.65e+149) {
tmp = fma(y, ((z - b) / (t + y)), a);
} else {
tmp = z - (((b - a) * y) / x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= 1.65e+149) tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); else tmp = Float64(z - Float64(Float64(Float64(b - a) * y) / x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, 1.65e+149], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(z - N[(N[(N[(b - a), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\mathbf{else}:\\
\;\;\;\;z - \frac{\left(b - a\right) \cdot y}{x}\\
\end{array}
\end{array}
if x < 1.65e149Initial program 64.3%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6452.5
Applied rewrites52.5%
Taylor expanded in a around 0
Applied rewrites79.4%
if 1.65e149 < x Initial program 59.6%
Taylor expanded in x around -inf
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites71.0%
Taylor expanded in y around inf
Applied rewrites67.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ a z) b)))
(if (<= y -13000000.0)
t_1
(if (<= y -6.6e-49) (* a 1.0) (if (<= y 4.8e+70) (+ a 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 <= -13000000.0) {
tmp = t_1;
} else if (y <= -6.6e-49) {
tmp = a * 1.0;
} else if (y <= 4.8e+70) {
tmp = a + z;
} 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 = (a + z) - b
if (y <= (-13000000.0d0)) then
tmp = t_1
else if (y <= (-6.6d-49)) then
tmp = a * 1.0d0
else if (y <= 4.8d+70) then
tmp = a + z
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 = (a + z) - b;
double tmp;
if (y <= -13000000.0) {
tmp = t_1;
} else if (y <= -6.6e-49) {
tmp = a * 1.0;
} else if (y <= 4.8e+70) {
tmp = a + z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a + z) - b tmp = 0 if y <= -13000000.0: tmp = t_1 elif y <= -6.6e-49: tmp = a * 1.0 elif y <= 4.8e+70: tmp = a + z else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + z) - b) tmp = 0.0 if (y <= -13000000.0) tmp = t_1; elseif (y <= -6.6e-49) tmp = Float64(a * 1.0); elseif (y <= 4.8e+70) tmp = Float64(a + z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a + z) - b; tmp = 0.0; if (y <= -13000000.0) tmp = t_1; elseif (y <= -6.6e-49) tmp = a * 1.0; elseif (y <= 4.8e+70) tmp = a + z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -13000000.0], t$95$1, If[LessEqual[y, -6.6e-49], N[(a * 1.0), $MachinePrecision], If[LessEqual[y, 4.8e+70], N[(a + z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
\mathbf{if}\;y \leq -13000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -6.6 \cdot 10^{-49}:\\
\;\;\;\;a \cdot 1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+70}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.3e7 or 4.79999999999999974e70 < y Initial program 43.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6481.1
Applied rewrites81.1%
if -1.3e7 < y < -6.6e-49Initial program 79.3%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6459.4
Applied rewrites59.4%
Applied rewrites72.2%
Taylor expanded in x around 0
Applied rewrites65.3%
if -6.6e-49 < y < 4.79999999999999974e70Initial program 80.7%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6442.0
Applied rewrites42.0%
Taylor expanded in b around inf
Applied rewrites3.3%
Taylor expanded in b around 0
Applied rewrites55.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -2.6e+154) (not (<= t 4e+184))) (* a 1.0) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -2.6e+154) || !(t <= 4e+184)) {
tmp = a * 1.0;
} 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 ((t <= (-2.6d+154)) .or. (.not. (t <= 4d+184))) then
tmp = a * 1.0d0
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 ((t <= -2.6e+154) || !(t <= 4e+184)) {
tmp = a * 1.0;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (t <= -2.6e+154) or not (t <= 4e+184): tmp = a * 1.0 else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -2.6e+154) || !(t <= 4e+184)) tmp = Float64(a * 1.0); else tmp = Float64(a + z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((t <= -2.6e+154) || ~((t <= 4e+184))) tmp = a * 1.0; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -2.6e+154], N[Not[LessEqual[t, 4e+184]], $MachinePrecision]], N[(a * 1.0), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.6 \cdot 10^{+154} \lor \neg \left(t \leq 4 \cdot 10^{+184}\right):\\
\;\;\;\;a \cdot 1\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if t < -2.59999999999999989e154 or 4.00000000000000007e184 < t Initial program 53.4%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6454.5
Applied rewrites54.5%
Applied rewrites65.4%
Taylor expanded in x around 0
Applied rewrites61.1%
if -2.59999999999999989e154 < t < 4.00000000000000007e184Initial program 66.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.6
Applied rewrites63.6%
Taylor expanded in b around inf
Applied rewrites10.5%
Taylor expanded in b around 0
Applied rewrites63.6%
Final simplification63.0%
(FPCore (x y z t a b) :precision binary64 (+ a z))
double code(double x, double y, double z, double t, double a, double b) {
return a + z;
}
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 + z
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a + z;
}
def code(x, y, z, t, a, b): return a + z
function code(x, y, z, t, a, b) return Float64(a + z) end
function tmp = code(x, y, z, t, a, b) tmp = a + z; end
code[x_, y_, z_, t_, a_, b_] := N[(a + z), $MachinePrecision]
\begin{array}{l}
\\
a + z
\end{array}
Initial program 63.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.2
Applied rewrites59.2%
Taylor expanded in b around inf
Applied rewrites10.0%
Taylor expanded in b around 0
Applied rewrites59.3%
(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 63.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.2
Applied rewrites59.2%
Taylor expanded in b around inf
Applied rewrites10.0%
(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 2024314
(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)))