
(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 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_2 (* (/ y (+ y x)) b)))
(if (<= t_1 (- INFINITY))
(- (fma a (/ y (+ x y)) z) t_2)
(if (<= t_1 1e+218) t_1 (- (+ z a) t_2)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_2 = (y / (y + x)) * b;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(a, (y / (x + y)), z) - t_2;
} else if (t_1 <= 1e+218) {
tmp = t_1;
} else {
tmp = (z + a) - t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_2 = Float64(Float64(y / Float64(y + x)) * b) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(a, Float64(y / Float64(x + y)), z) - t_2); elseif (t_1 <= 1e+218) tmp = t_1; else tmp = Float64(Float64(z + a) - t_2); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(a * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] - t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 1e+218], t$95$1, N[(N[(z + a), $MachinePrecision] - t$95$2), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_2 := \frac{y}{y + x} \cdot b\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{x + y}, z\right) - t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+218}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(z + a\right) - t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 6.2%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites73.4%
Taylor expanded in t around 0
Applied rewrites75.8%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.00000000000000008e218Initial program 99.1%
if 1.00000000000000008e218 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.0%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites74.1%
Taylor expanded in y around inf
Applied rewrites82.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -750000000000.0) (not (<= x 9.6e+42))) (- (fma a (/ y (+ x y)) z) (* (/ y (+ y x)) b)) (fma (- z b) (/ y (+ t y)) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -750000000000.0) || !(x <= 9.6e+42)) {
tmp = fma(a, (y / (x + y)), z) - ((y / (y + x)) * b);
} else {
tmp = fma((z - b), (y / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -750000000000.0) || !(x <= 9.6e+42)) tmp = Float64(fma(a, Float64(y / Float64(x + y)), z) - Float64(Float64(y / Float64(y + x)) * b)); else tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -750000000000.0], N[Not[LessEqual[x, 9.6e+42]], $MachinePrecision]], N[(N[(a * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] - N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -750000000000 \lor \neg \left(x \leq 9.6 \cdot 10^{+42}\right):\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{x + y}, z\right) - \frac{y}{y + x} \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -7.5e11 or 9.5999999999999994e42 < x Initial program 60.3%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites80.9%
Taylor expanded in t around 0
Applied rewrites76.5%
if -7.5e11 < x < 9.5999999999999994e42Initial program 62.5%
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-+.f6455.5
Applied rewrites55.5%
Taylor expanded in a around 0
Applied rewrites87.4%
Applied rewrites91.9%
Final simplification85.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -14000.0) (not (<= x 4.1e+40))) (- (+ z a) (* (/ y (+ y x)) b)) (fma (- z b) (/ y (+ t y)) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -14000.0) || !(x <= 4.1e+40)) {
tmp = (z + a) - ((y / (y + x)) * b);
} else {
tmp = fma((z - b), (y / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -14000.0) || !(x <= 4.1e+40)) tmp = Float64(Float64(z + a) - Float64(Float64(y / Float64(y + x)) * b)); else tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -14000.0], N[Not[LessEqual[x, 4.1e+40]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -14000 \lor \neg \left(x \leq 4.1 \cdot 10^{+40}\right):\\
\;\;\;\;\left(z + a\right) - \frac{y}{y + x} \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -14000 or 4.1000000000000002e40 < x Initial program 60.8%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites79.0%
Taylor expanded in y around inf
Applied rewrites67.3%
if -14000 < x < 4.1000000000000002e40Initial program 62.1%
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-+.f6455.6
Applied rewrites55.6%
Taylor expanded in a around 0
Applied rewrites87.8%
Applied rewrites92.4%
Final simplification80.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ a z) b)))
(if (<= y -8e+103)
t_1
(if (<= y -3e-187)
(+ a z)
(if (<= y 1.9e-125) (* a (/ t (+ t x))) 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 <= -8e+103) {
tmp = t_1;
} else if (y <= -3e-187) {
tmp = a + z;
} else if (y <= 1.9e-125) {
tmp = a * (t / (t + x));
} 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 <= (-8d+103)) then
tmp = t_1
else if (y <= (-3d-187)) then
tmp = a + z
else if (y <= 1.9d-125) then
tmp = a * (t / (t + x))
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 <= -8e+103) {
tmp = t_1;
} else if (y <= -3e-187) {
tmp = a + z;
} else if (y <= 1.9e-125) {
tmp = a * (t / (t + x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a + z) - b tmp = 0 if y <= -8e+103: tmp = t_1 elif y <= -3e-187: tmp = a + z elif y <= 1.9e-125: tmp = a * (t / (t + x)) 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 <= -8e+103) tmp = t_1; elseif (y <= -3e-187) tmp = Float64(a + z); elseif (y <= 1.9e-125) tmp = Float64(a * Float64(t / Float64(t + x))); 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 <= -8e+103) tmp = t_1; elseif (y <= -3e-187) tmp = a + z; elseif (y <= 1.9e-125) tmp = a * (t / (t + x)); 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, -8e+103], t$95$1, If[LessEqual[y, -3e-187], N[(a + z), $MachinePrecision], If[LessEqual[y, 1.9e-125], N[(a * N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
\mathbf{if}\;y \leq -8 \cdot 10^{+103}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-187}:\\
\;\;\;\;a + z\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-125}:\\
\;\;\;\;a \cdot \frac{t}{t + x}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8e103 or 1.9000000000000001e-125 < y Initial program 47.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6472.7
Applied rewrites72.7%
if -8e103 < y < -3.00000000000000004e-187Initial program 73.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6446.5
Applied rewrites46.5%
Taylor expanded in z around 0
Applied rewrites32.9%
Taylor expanded in b around 0
Applied rewrites58.9%
if -3.00000000000000004e-187 < y < 1.9000000000000001e-125Initial program 82.7%
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%
Taylor expanded in y around 0
Applied rewrites64.3%
(FPCore (x y z t a b)
:precision binary64
(if (<= x -14000.0)
(- (+ z a) (* (/ y (+ y x)) b))
(if (<= x 4.1e+40)
(fma (- z b) (/ y (+ t y)) a)
(fma (/ (- y) (+ y x)) b (+ a z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -14000.0) {
tmp = (z + a) - ((y / (y + x)) * b);
} else if (x <= 4.1e+40) {
tmp = fma((z - b), (y / (t + y)), a);
} else {
tmp = fma((-y / (y + x)), b, (a + z));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -14000.0) tmp = Float64(Float64(z + a) - Float64(Float64(y / Float64(y + x)) * b)); elseif (x <= 4.1e+40) tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); else tmp = fma(Float64(Float64(-y) / Float64(y + x)), b, Float64(a + z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -14000.0], N[(N[(z + a), $MachinePrecision] - N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.1e+40], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(N[((-y) / N[(y + x), $MachinePrecision]), $MachinePrecision] * b + N[(a + z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -14000:\\
\;\;\;\;\left(z + a\right) - \frac{y}{y + x} \cdot b\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+40}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y}{y + x}, b, a + z\right)\\
\end{array}
\end{array}
if x < -14000Initial program 59.6%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites77.6%
Taylor expanded in y around inf
Applied rewrites65.2%
if -14000 < x < 4.1000000000000002e40Initial program 62.1%
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-+.f6455.6
Applied rewrites55.6%
Taylor expanded in a around 0
Applied rewrites87.8%
Applied rewrites92.4%
if 4.1000000000000002e40 < x Initial program 62.6%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites81.2%
Taylor expanded in y around inf
Applied rewrites70.2%
Applied rewrites70.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -2.4e+139) (not (<= x 2.5e+172))) (fma (/ (- a z) x) t z) (fma (- z b) (/ y (+ t y)) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -2.4e+139) || !(x <= 2.5e+172)) {
tmp = fma(((a - z) / x), t, z);
} else {
tmp = fma((z - b), (y / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -2.4e+139) || !(x <= 2.5e+172)) tmp = fma(Float64(Float64(a - z) / x), t, z); else tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -2.4e+139], N[Not[LessEqual[x, 2.5e+172]], $MachinePrecision]], N[(N[(N[(a - z), $MachinePrecision] / x), $MachinePrecision] * t + z), $MachinePrecision], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+139} \lor \neg \left(x \leq 2.5 \cdot 10^{+172}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{a - z}{x}, t, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -2.40000000000000008e139 or 2.5e172 < x Initial program 59.4%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites80.2%
Taylor expanded in y around 0
Applied rewrites59.6%
if -2.40000000000000008e139 < x < 2.5e172Initial program 62.1%
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.1
Applied rewrites49.1%
Taylor expanded in a around 0
Applied rewrites79.7%
Applied rewrites83.3%
Final simplification78.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.4e+133) (not (<= x 2.5e+172))) (fma (/ (- a z) x) t z) (fma y (/ (- z b) (+ t y)) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -1.4e+133) || !(x <= 2.5e+172)) {
tmp = fma(((a - z) / x), t, z);
} else {
tmp = fma(y, ((z - b) / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -1.4e+133) || !(x <= 2.5e+172)) tmp = fma(Float64(Float64(a - z) / x), t, z); else tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -1.4e+133], N[Not[LessEqual[x, 2.5e+172]], $MachinePrecision]], N[(N[(N[(a - z), $MachinePrecision] / x), $MachinePrecision] * t + z), $MachinePrecision], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+133} \lor \neg \left(x \leq 2.5 \cdot 10^{+172}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{a - z}{x}, t, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -1.40000000000000008e133 or 2.5e172 < x Initial program 59.1%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites80.9%
Taylor expanded in y around 0
Applied rewrites59.3%
if -1.40000000000000008e133 < x < 2.5e172Initial program 62.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-+.f6449.6
Applied rewrites49.6%
Taylor expanded in a around 0
Applied rewrites80.0%
Final simplification75.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -3.6e+181) (not (<= t 8.8e+207))) (fma (- z b) (/ y t) a) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -3.6e+181) || !(t <= 8.8e+207)) {
tmp = fma((z - b), (y / t), a);
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -3.6e+181) || !(t <= 8.8e+207)) tmp = fma(Float64(z - b), Float64(y / 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.6e+181], N[Not[LessEqual[t, 8.8e+207]], $MachinePrecision]], N[(N[(z - b), $MachinePrecision] * N[(y / t), $MachinePrecision] + a), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.6 \cdot 10^{+181} \lor \neg \left(t \leq 8.8 \cdot 10^{+207}\right):\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -3.59999999999999985e181 or 8.80000000000000034e207 < t Initial program 46.6%
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-+.f6440.5
Applied rewrites40.5%
Taylor expanded in a around 0
Applied rewrites80.1%
Applied rewrites80.1%
Taylor expanded in y around 0
Applied rewrites78.3%
if -3.59999999999999985e181 < t < 8.80000000000000034e207Initial program 64.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6464.9
Applied rewrites64.9%
Final simplification67.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -8e+103) (not (<= y 2.1e-50))) (- (+ a z) b) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -8e+103) || !(y <= 2.1e-50)) {
tmp = (a + z) - 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 ((y <= (-8d+103)) .or. (.not. (y <= 2.1d-50))) then
tmp = (a + z) - 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 ((y <= -8e+103) || !(y <= 2.1e-50)) {
tmp = (a + z) - b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -8e+103) or not (y <= 2.1e-50): tmp = (a + z) - b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -8e+103) || !(y <= 2.1e-50)) tmp = Float64(Float64(a + z) - b); else tmp = Float64(a + z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -8e+103) || ~((y <= 2.1e-50))) tmp = (a + z) - b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -8e+103], N[Not[LessEqual[y, 2.1e-50]], $MachinePrecision]], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+103} \lor \neg \left(y \leq 2.1 \cdot 10^{-50}\right):\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if y < -8e103 or 2.1000000000000001e-50 < y Initial program 46.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6475.2
Applied rewrites75.2%
if -8e103 < y < 2.1000000000000001e-50Initial program 77.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6441.1
Applied rewrites41.1%
Taylor expanded in z around 0
Applied rewrites34.8%
Taylor expanded in b around 0
Applied rewrites55.9%
Final simplification65.7%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.04e+263) (- a b) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.04e+263) {
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 (b <= (-1.04d+263)) 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 (b <= -1.04e+263) {
tmp = a - b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= -1.04e+263: tmp = a - b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.04e+263) 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 (b <= -1.04e+263) tmp = a - b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.04e+263], N[(a - b), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.04 \cdot 10^{+263}:\\
\;\;\;\;a - b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if b < -1.04e263Initial program 23.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.6
Applied rewrites59.6%
Taylor expanded in z around 0
Applied rewrites59.6%
if -1.04e263 < b Initial program 64.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6458.3
Applied rewrites58.3%
Taylor expanded in z around 0
Applied rewrites39.8%
Taylor expanded in b around 0
Applied rewrites57.8%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.08e+263) (- b) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.08e+263) {
tmp = -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 (b <= (-1.08d+263)) then
tmp = -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 (b <= -1.08e+263) {
tmp = -b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= -1.08e+263: tmp = -b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.08e+263) tmp = Float64(-b); else tmp = Float64(a + z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= -1.08e+263) tmp = -b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.08e+263], (-b), N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.08 \cdot 10^{+263}:\\
\;\;\;\;-b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if b < -1.08e263Initial program 23.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.6
Applied rewrites59.6%
Taylor expanded in b around inf
Applied rewrites54.4%
if -1.08e263 < b Initial program 64.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6458.3
Applied rewrites58.3%
Taylor expanded in z around 0
Applied rewrites39.8%
Taylor expanded in b around 0
Applied rewrites57.8%
(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 61.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6458.4
Applied rewrites58.4%
Taylor expanded in b around inf
Applied rewrites14.7%
(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 2024339
(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)))