
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
def code(x, y, z, t, a, b): return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) end
function tmp = code(x, y, z, t, a, b) tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (+ y t) a))
(t_2 (+ y (+ x t)))
(t_3 (/ (- (+ (* (+ x y) z) t_1) (* y b)) t_2)))
(if (<= t_3 (- INFINITY))
(fma (+ y t) (/ a (+ (+ x y) t)) (- z b))
(if (<= t_3 5e+265)
(/ (fma (+ x y) z (- t_1 (* y b))) t_2)
(fma y (/ (- z b) (+ y t)) a)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y + t) * a;
double t_2 = y + (x + t);
double t_3 = ((((x + y) * z) + t_1) - (y * b)) / t_2;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = fma((y + t), (a / ((x + y) + t)), (z - b));
} else if (t_3 <= 5e+265) {
tmp = fma((x + y), z, (t_1 - (y * b))) / t_2;
} else {
tmp = fma(y, ((z - b) / (y + t)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y + t) * a) t_2 = Float64(y + Float64(x + t)) t_3 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + t_1) - Float64(y * b)) / t_2) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = fma(Float64(y + t), Float64(a / Float64(Float64(x + y) + t)), Float64(z - b)); elseif (t_3 <= 5e+265) tmp = Float64(fma(Float64(x + y), z, Float64(t_1 - Float64(y * b))) / t_2); else tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(y + t), $MachinePrecision] * N[(a / N[(N[(x + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(z - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5e+265], N[(N[(N[(x + y), $MachinePrecision] * z + N[(t$95$1 - N[(y * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y + t\right) \cdot a\\
t_2 := y + \left(x + t\right)\\
t_3 := \frac{\left(\left(x + y\right) \cdot z + t\_1\right) - y \cdot b}{t\_2}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y + t, \frac{a}{\left(x + y\right) + t}, z - b\right)\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+265}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x + y, z, t\_1 - y \cdot b\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 6.4%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites50.4%
Taylor expanded in y around inf
Applied rewrites83.6%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5.0000000000000002e265Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lower--.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
if 5.0000000000000002e265 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 6.4%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites33.3%
Taylor expanded in x around 0
Applied rewrites78.6%
Final simplification91.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- z (* y (/ (- b a) x)))))
(if (<= x -1.75e+208)
t_1
(if (<= x -9.6e-21)
(fma a (/ t (+ x t)) (* x (/ z (+ x t))))
(if (<= x 2.8e+146) (fma y (/ (- z b) (+ y t)) a) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z - (y * ((b - a) / x));
double tmp;
if (x <= -1.75e+208) {
tmp = t_1;
} else if (x <= -9.6e-21) {
tmp = fma(a, (t / (x + t)), (x * (z / (x + t))));
} else if (x <= 2.8e+146) {
tmp = fma(y, ((z - b) / (y + t)), a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z - Float64(y * Float64(Float64(b - a) / x))) tmp = 0.0 if (x <= -1.75e+208) tmp = t_1; elseif (x <= -9.6e-21) tmp = fma(a, Float64(t / Float64(x + t)), Float64(x * Float64(z / Float64(x + t)))); elseif (x <= 2.8e+146) tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z - N[(y * N[(N[(b - a), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.75e+208], t$95$1, If[LessEqual[x, -9.6e-21], N[(a * N[(t / N[(x + t), $MachinePrecision]), $MachinePrecision] + N[(x * N[(z / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e+146], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z - y \cdot \frac{b - a}{x}\\
\mathbf{if}\;x \leq -1.75 \cdot 10^{+208}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -9.6 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{x + t}, x \cdot \frac{z}{x + t}\right)\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+146}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.75000000000000008e208 or 2.8000000000000001e146 < x Initial program 35.5%
Taylor expanded in x around -inf
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites53.0%
Taylor expanded in y around inf
Applied rewrites85.2%
if -1.75000000000000008e208 < x < -9.5999999999999997e-21Initial program 60.4%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites80.6%
Taylor expanded in y around 0
Applied rewrites76.3%
if -9.5999999999999997e-21 < x < 2.8000000000000001e146Initial program 61.5%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites71.7%
Taylor expanded in x around 0
Applied rewrites83.9%
Final simplification82.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- z (* y (/ (- b a) x)))))
(if (<= x -2.8e+186)
t_1
(if (<= x 2.8e+146) (fma y (/ (- z b) (+ y t)) a) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z - (y * ((b - a) / x));
double tmp;
if (x <= -2.8e+186) {
tmp = t_1;
} else if (x <= 2.8e+146) {
tmp = fma(y, ((z - b) / (y + t)), a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z - Float64(y * Float64(Float64(b - a) / x))) tmp = 0.0 if (x <= -2.8e+186) tmp = t_1; elseif (x <= 2.8e+146) tmp = fma(y, Float64(Float64(z - b) / Float64(y + t)), a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z - N[(y * N[(N[(b - a), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8e+186], t$95$1, If[LessEqual[x, 2.8e+146], N[(y * N[(N[(z - b), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z - y \cdot \frac{b - a}{x}\\
\mathbf{if}\;x \leq -2.8 \cdot 10^{+186}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+146}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{y + t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.80000000000000018e186 or 2.8000000000000001e146 < x Initial program 38.5%
Taylor expanded in x around -inf
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites53.0%
Taylor expanded in y around inf
Applied rewrites83.6%
if -2.80000000000000018e186 < x < 2.8000000000000001e146Initial program 60.9%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites73.9%
Taylor expanded in x around 0
Applied rewrites80.1%
Final simplification80.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (- b) (/ y (+ y t)) a))) (if (<= t -2.2e+125) t_1 (if (<= t 9000000000.0) (- (+ z a) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(-b, (y / (y + t)), a);
double tmp;
if (t <= -2.2e+125) {
tmp = t_1;
} else if (t <= 9000000000.0) {
tmp = (z + a) - b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(-b), Float64(y / Float64(y + t)), a) tmp = 0.0 if (t <= -2.2e+125) tmp = t_1; elseif (t <= 9000000000.0) tmp = Float64(Float64(z + a) - b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[((-b) * N[(y / N[(y + t), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]}, If[LessEqual[t, -2.2e+125], t$95$1, If[LessEqual[t, 9000000000.0], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-b, \frac{y}{y + t}, a\right)\\
\mathbf{if}\;t \leq -2.2 \cdot 10^{+125}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9000000000:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.19999999999999991e125 or 9e9 < t Initial program 49.8%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites72.2%
Taylor expanded in x around 0
Applied rewrites82.8%
Taylor expanded in z around 0
Applied rewrites77.1%
if -2.19999999999999991e125 < t < 9e9Initial program 61.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6470.9
Applied rewrites70.9%
Final simplification73.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma y (/ (- z b) t) a))) (if (<= t -2.9e+173) t_1 (if (<= t 9.2e+117) (- (+ z a) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(y, ((z - b) / t), a);
double tmp;
if (t <= -2.9e+173) {
tmp = t_1;
} else if (t <= 9.2e+117) {
tmp = (z + a) - b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(y, Float64(Float64(z - b) / t), a) tmp = 0.0 if (t <= -2.9e+173) tmp = t_1; elseif (t <= 9.2e+117) tmp = Float64(Float64(z + a) - b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y * N[(N[(z - b), $MachinePrecision] / t), $MachinePrecision] + a), $MachinePrecision]}, If[LessEqual[t, -2.9e+173], t$95$1, If[LessEqual[t, 9.2e+117], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z - b}{t}, a\right)\\
\mathbf{if}\;t \leq -2.9 \cdot 10^{+173}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9.2 \cdot 10^{+117}:\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.90000000000000007e173 or 9.19999999999999951e117 < t Initial program 40.7%
Taylor expanded in b around 0
mul-1-negN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-/l*N/A
sub-negN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites70.5%
Taylor expanded in x around 0
Applied rewrites88.5%
Taylor expanded in t around inf
Applied rewrites80.1%
if -2.90000000000000007e173 < t < 9.19999999999999951e117Initial program 62.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6468.5
Applied rewrites68.5%
Final simplification71.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (- (+ z a) b))) (if (<= y -2.6e+29) t_1 (if (<= y 8.2e+32) (+ z a) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + a) - b;
double tmp;
if (y <= -2.6e+29) {
tmp = t_1;
} else if (y <= 8.2e+32) {
tmp = z + a;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (z + a) - b
if (y <= (-2.6d+29)) then
tmp = t_1
else if (y <= 8.2d+32) then
tmp = z + a
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + a) - b;
double tmp;
if (y <= -2.6e+29) {
tmp = t_1;
} else if (y <= 8.2e+32) {
tmp = z + a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + a) - b tmp = 0 if y <= -2.6e+29: tmp = t_1 elif y <= 8.2e+32: tmp = z + a else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z + a) - b) tmp = 0.0 if (y <= -2.6e+29) tmp = t_1; elseif (y <= 8.2e+32) tmp = Float64(z + a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z + a) - b; tmp = 0.0; if (y <= -2.6e+29) tmp = t_1; elseif (y <= 8.2e+32) tmp = z + a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -2.6e+29], t$95$1, If[LessEqual[y, 8.2e+32], N[(z + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -2.6 \cdot 10^{+29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+32}:\\
\;\;\;\;z + a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.6e29 or 8.19999999999999961e32 < y Initial program 39.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6475.2
Applied rewrites75.2%
if -2.6e29 < y < 8.19999999999999961e32Initial program 74.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6449.0
Applied rewrites49.0%
Taylor expanded in b around 0
Applied rewrites59.6%
Final simplification67.2%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.28e+147) (- a b) (if (<= b 2.6e+150) (+ z a) (- z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.28e+147) {
tmp = a - b;
} else if (b <= 2.6e+150) {
tmp = z + a;
} else {
tmp = 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 (b <= (-1.28d+147)) then
tmp = a - b
else if (b <= 2.6d+150) then
tmp = z + a
else
tmp = 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 (b <= -1.28e+147) {
tmp = a - b;
} else if (b <= 2.6e+150) {
tmp = z + a;
} else {
tmp = z - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= -1.28e+147: tmp = a - b elif b <= 2.6e+150: tmp = z + a else: tmp = z - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.28e+147) tmp = Float64(a - b); elseif (b <= 2.6e+150) tmp = Float64(z + a); else tmp = Float64(z - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= -1.28e+147) tmp = a - b; elseif (b <= 2.6e+150) tmp = z + a; else tmp = z - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.28e+147], N[(a - b), $MachinePrecision], If[LessEqual[b, 2.6e+150], N[(z + a), $MachinePrecision], N[(z - b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.28 \cdot 10^{+147}:\\
\;\;\;\;a - b\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{+150}:\\
\;\;\;\;z + a\\
\mathbf{else}:\\
\;\;\;\;z - b\\
\end{array}
\end{array}
if b < -1.28e147Initial program 44.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6440.5
Applied rewrites40.5%
Taylor expanded in z around 0
Applied rewrites44.3%
if -1.28e147 < b < 2.60000000000000006e150Initial program 61.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6468.0
Applied rewrites68.0%
Taylor expanded in b around 0
Applied rewrites67.0%
if 2.60000000000000006e150 < b Initial program 41.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in a around 0
Applied rewrites47.1%
Final simplification61.8%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.28e+147) (- a b) (if (<= b 2.62e+213) (+ z a) (- a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.28e+147) {
tmp = a - b;
} else if (b <= 2.62e+213) {
tmp = z + a;
} else {
tmp = a - 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.28d+147)) then
tmp = a - b
else if (b <= 2.62d+213) then
tmp = z + a
else
tmp = a - 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.28e+147) {
tmp = a - b;
} else if (b <= 2.62e+213) {
tmp = z + a;
} else {
tmp = a - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= -1.28e+147: tmp = a - b elif b <= 2.62e+213: tmp = z + a else: tmp = a - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.28e+147) tmp = Float64(a - b); elseif (b <= 2.62e+213) tmp = Float64(z + a); else tmp = Float64(a - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= -1.28e+147) tmp = a - b; elseif (b <= 2.62e+213) tmp = z + a; else tmp = a - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.28e+147], N[(a - b), $MachinePrecision], If[LessEqual[b, 2.62e+213], N[(z + a), $MachinePrecision], N[(a - b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.28 \cdot 10^{+147}:\\
\;\;\;\;a - b\\
\mathbf{elif}\;b \leq 2.62 \cdot 10^{+213}:\\
\;\;\;\;z + a\\
\mathbf{else}:\\
\;\;\;\;a - b\\
\end{array}
\end{array}
if b < -1.28e147 or 2.6199999999999999e213 < b Initial program 46.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6441.8
Applied rewrites41.8%
Taylor expanded in z around 0
Applied rewrites44.4%
if -1.28e147 < b < 2.6199999999999999e213Initial program 59.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6467.0
Applied rewrites67.0%
Taylor expanded in b around 0
Applied rewrites65.6%
Final simplification61.2%
(FPCore (x y z t a b) :precision binary64 (if (<= b 5e+213) (+ z a) (- b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= 5e+213) {
tmp = z + a;
} 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 <= 5d+213) then
tmp = z + a
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 <= 5e+213) {
tmp = z + a;
} else {
tmp = -b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= 5e+213: tmp = z + a else: tmp = -b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= 5e+213) tmp = Float64(z + a); else tmp = Float64(-b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= 5e+213) tmp = z + a; else tmp = -b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, 5e+213], N[(z + a), $MachinePrecision], (-b)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{+213}:\\
\;\;\;\;z + a\\
\mathbf{else}:\\
\;\;\;\;-b\\
\end{array}
\end{array}
if b < 4.9999999999999998e213Initial program 57.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.1
Applied rewrites63.1%
Taylor expanded in b around 0
Applied rewrites59.7%
if 4.9999999999999998e213 < b Initial program 49.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6444.6
Applied rewrites44.6%
Taylor expanded in b around inf
Applied rewrites41.8%
Final simplification58.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 57.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6461.8
Applied rewrites61.8%
Taylor expanded in b around inf
Applied rewrites14.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 2024232
(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)))