
(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 (+ t (+ x y)))
(t_2 (+ y (+ x t)))
(t_3
(*
a
(fma
y
(/ b (* a (- (- y) (+ x t))))
(fma (/ (+ x y) t_2) (/ z a) (/ (+ y t) t_2))))))
(if (<= a -1.9e+22)
t_3
(if (<= a 3.3e-63)
(fma z (+ (/ x t_1) (/ y t_1)) (/ (fma a (+ y t) (* b (- y))) t_1))
t_3))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = t + (x + y);
double t_2 = y + (x + t);
double t_3 = a * fma(y, (b / (a * (-y - (x + t)))), fma(((x + y) / t_2), (z / a), ((y + t) / t_2)));
double tmp;
if (a <= -1.9e+22) {
tmp = t_3;
} else if (a <= 3.3e-63) {
tmp = fma(z, ((x / t_1) + (y / t_1)), (fma(a, (y + t), (b * -y)) / t_1));
} else {
tmp = t_3;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(t + Float64(x + y)) t_2 = Float64(y + Float64(x + t)) t_3 = Float64(a * fma(y, Float64(b / Float64(a * Float64(Float64(-y) - Float64(x + t)))), fma(Float64(Float64(x + y) / t_2), Float64(z / a), Float64(Float64(y + t) / t_2)))) tmp = 0.0 if (a <= -1.9e+22) tmp = t_3; elseif (a <= 3.3e-63) tmp = fma(z, Float64(Float64(x / t_1) + Float64(y / t_1)), Float64(fma(a, Float64(y + t), Float64(b * Float64(-y))) / t_1)); else tmp = t_3; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(a * N[(y * N[(b / N[(a * N[((-y) - N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x + y), $MachinePrecision] / t$95$2), $MachinePrecision] * N[(z / a), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.9e+22], t$95$3, If[LessEqual[a, 3.3e-63], N[(z * N[(N[(x / t$95$1), $MachinePrecision] + N[(y / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(a * N[(y + t), $MachinePrecision] + N[(b * (-y)), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t + \left(x + y\right)\\
t_2 := y + \left(x + t\right)\\
t_3 := a \cdot \mathsf{fma}\left(y, \frac{b}{a \cdot \left(\left(-y\right) - \left(x + t\right)\right)}, \mathsf{fma}\left(\frac{x + y}{t\_2}, \frac{z}{a}, \frac{y + t}{t\_2}\right)\right)\\
\mathbf{if}\;a \leq -1.9 \cdot 10^{+22}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{-63}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{x}{t\_1} + \frac{y}{t\_1}, \frac{\mathsf{fma}\left(a, y + t, b \cdot \left(-y\right)\right)}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if a < -1.9000000000000002e22 or 3.29999999999999994e-63 < a Initial program 46.5%
Taylor expanded in z around 0
associate--l+N/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-subN/A
lower-/.f64N/A
Applied rewrites53.9%
Taylor expanded in a around inf
Applied rewrites86.1%
Applied rewrites97.0%
Applied rewrites97.3%
if -1.9000000000000002e22 < a < 3.29999999999999994e-63Initial program 77.1%
Taylor expanded in z around 0
associate--l+N/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-subN/A
lower-/.f64N/A
Applied rewrites88.7%
Final simplification93.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* z (+ x y)) (* a (+ y t))) (* y b)) (+ y (+ x t))))
(t_2 (- (+ a z) b)))
(if (<= t_1 -4e+288) t_2 (if (<= t_1 2e+257) t_1 t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t));
double t_2 = (a + z) - b;
double tmp;
if (t_1 <= -4e+288) {
tmp = t_2;
} else if (t_1 <= 2e+257) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: tmp
t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t))
t_2 = (a + z) - b
if (t_1 <= (-4d+288)) then
tmp = t_2
else if (t_1 <= 2d+257) then
tmp = t_1
else
tmp = t_2
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 * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t));
double t_2 = (a + z) - b;
double tmp;
if (t_1 <= -4e+288) {
tmp = t_2;
} else if (t_1 <= 2e+257) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t)) t_2 = (a + z) - b tmp = 0 if t_1 <= -4e+288: tmp = t_2 elif t_1 <= 2e+257: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(z * Float64(x + y)) + Float64(a * Float64(y + t))) - Float64(y * b)) / Float64(y + Float64(x + t))) t_2 = Float64(Float64(a + z) - b) tmp = 0.0 if (t_1 <= -4e+288) tmp = t_2; elseif (t_1 <= 2e+257) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t)); t_2 = (a + z) - b; tmp = 0.0; if (t_1 <= -4e+288) tmp = t_2; elseif (t_1 <= 2e+257) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(a * N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+288], t$95$2, If[LessEqual[t$95$1, 2e+257], t$95$1, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z \cdot \left(x + y\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{y + \left(x + t\right)}\\
t_2 := \left(a + z\right) - b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+288}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+257}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -4e288 or 2.00000000000000006e257 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 9.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6471.9
Applied rewrites71.9%
if -4e288 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.00000000000000006e257Initial program 99.1%
Final simplification87.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* z (+ x y)) (* a (+ y t))) (* y b)) (+ y (+ x t))))
(t_2 (- (+ a z) b)))
(if (<= t_1 -4e+150)
t_2
(if (<= t_1 1e+85) (/ (fma a t (* x z)) (+ x t)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t));
double t_2 = (a + z) - b;
double tmp;
if (t_1 <= -4e+150) {
tmp = t_2;
} else if (t_1 <= 1e+85) {
tmp = fma(a, t, (x * z)) / (x + t);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(z * Float64(x + y)) + Float64(a * Float64(y + t))) - Float64(y * b)) / Float64(y + Float64(x + t))) t_2 = Float64(Float64(a + z) - b) tmp = 0.0 if (t_1 <= -4e+150) tmp = t_2; elseif (t_1 <= 1e+85) tmp = Float64(fma(a, t, Float64(x * z)) / Float64(x + t)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(a * N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+150], t$95$2, If[LessEqual[t$95$1, 1e+85], N[(N[(a * t + N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(x + t), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z \cdot \left(x + y\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{y + \left(x + t\right)}\\
t_2 := \left(a + z\right) - b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+150}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+85}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, x \cdot z\right)}{x + t}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -3.99999999999999992e150 or 1e85 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 36.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6472.3
Applied rewrites72.3%
if -3.99999999999999992e150 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1e85Initial program 98.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6469.8
Applied rewrites69.8%
Final simplification71.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (/ a (+ x t)) t (* x (/ z (+ x t))))))
(if (<= x -2.7e+154)
t_1
(if (<= x -1.1e-127)
(- (+ a z) b)
(if (<= x 0.205)
(+ a (fma y (/ z (+ y t)) (/ (* b (- y)) (+ y t))))
t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a / (x + t)), t, (x * (z / (x + t))));
double tmp;
if (x <= -2.7e+154) {
tmp = t_1;
} else if (x <= -1.1e-127) {
tmp = (a + z) - b;
} else if (x <= 0.205) {
tmp = a + fma(y, (z / (y + t)), ((b * -y) / (y + t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(a / Float64(x + t)), t, Float64(x * Float64(z / Float64(x + t)))) tmp = 0.0 if (x <= -2.7e+154) tmp = t_1; elseif (x <= -1.1e-127) tmp = Float64(Float64(a + z) - b); elseif (x <= 0.205) tmp = Float64(a + fma(y, Float64(z / Float64(y + t)), Float64(Float64(b * Float64(-y)) / Float64(y + t)))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a / N[(x + t), $MachinePrecision]), $MachinePrecision] * t + N[(x * N[(z / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e+154], t$95$1, If[LessEqual[x, -1.1e-127], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], If[LessEqual[x, 0.205], N[(a + N[(y * N[(z / N[(y + t), $MachinePrecision]), $MachinePrecision] + N[(N[(b * (-y)), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{a}{x + t}, t, x \cdot \frac{z}{x + t}\right)\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-127}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{elif}\;x \leq 0.205:\\
\;\;\;\;a + \mathsf{fma}\left(y, \frac{z}{y + t}, \frac{b \cdot \left(-y\right)}{y + t}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.70000000000000006e154 or 0.204999999999999988 < x Initial program 50.3%
Taylor expanded in z around 0
associate--l+N/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-subN/A
lower-/.f64N/A
Applied rewrites68.2%
Taylor expanded in y around 0
Applied rewrites56.9%
Applied rewrites69.7%
if -2.70000000000000006e154 < x < -1.1000000000000001e-127Initial program 62.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6470.9
Applied rewrites70.9%
if -1.1000000000000001e-127 < x < 0.204999999999999988Initial program 68.8%
Taylor expanded in z around 0
associate--l+N/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-subN/A
lower-/.f64N/A
Applied rewrites72.6%
Taylor expanded in x around 0
Applied rewrites81.4%
Final simplification74.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* a (/ t (+ x t))))) (if (<= t -2.4e+92) t_1 (if (<= t 7.2e+195) (- (+ a z) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * (t / (x + t));
double tmp;
if (t <= -2.4e+92) {
tmp = t_1;
} else if (t <= 7.2e+195) {
tmp = (a + z) - b;
} 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 * (t / (x + t))
if (t <= (-2.4d+92)) then
tmp = t_1
else if (t <= 7.2d+195) then
tmp = (a + z) - b
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 * (t / (x + t));
double tmp;
if (t <= -2.4e+92) {
tmp = t_1;
} else if (t <= 7.2e+195) {
tmp = (a + z) - b;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = a * (t / (x + t)) tmp = 0 if t <= -2.4e+92: tmp = t_1 elif t <= 7.2e+195: tmp = (a + z) - b else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(a * Float64(t / Float64(x + t))) tmp = 0.0 if (t <= -2.4e+92) tmp = t_1; elseif (t <= 7.2e+195) tmp = Float64(Float64(a + z) - b); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = a * (t / (x + t)); tmp = 0.0; if (t <= -2.4e+92) tmp = t_1; elseif (t <= 7.2e+195) tmp = (a + z) - b; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(t / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2.4e+92], t$95$1, If[LessEqual[t, 7.2e+195], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \frac{t}{x + t}\\
\mathbf{if}\;t \leq -2.4 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7.2 \cdot 10^{+195}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.40000000000000005e92 or 7.1999999999999997e195 < t Initial program 60.3%
Taylor expanded in z around 0
associate--l+N/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-subN/A
lower-/.f64N/A
Applied rewrites59.2%
Taylor expanded in a around inf
Applied rewrites59.7%
Taylor expanded in y around 0
Applied rewrites59.2%
if -2.40000000000000005e92 < t < 7.1999999999999997e195Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6466.1
Applied rewrites66.1%
Final simplification64.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (- (+ a z) b))) (if (<= y -8e+129) t_1 (if (<= y 1.45e-11) (+ 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 <= -8e+129) {
tmp = t_1;
} else if (y <= 1.45e-11) {
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 <= (-8d+129)) then
tmp = t_1
else if (y <= 1.45d-11) 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 <= -8e+129) {
tmp = t_1;
} else if (y <= 1.45e-11) {
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 <= -8e+129: tmp = t_1 elif y <= 1.45e-11: 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 <= -8e+129) tmp = t_1; elseif (y <= 1.45e-11) 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 <= -8e+129) tmp = t_1; elseif (y <= 1.45e-11) 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, -8e+129], t$95$1, If[LessEqual[y, 1.45e-11], N[(a + z), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
\mathbf{if}\;y \leq -8 \cdot 10^{+129}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{-11}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8e129 or 1.45e-11 < y Initial program 39.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6475.3
Applied rewrites75.3%
if -8e129 < y < 1.45e-11Initial program 76.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6443.2
Applied rewrites43.2%
Taylor expanded in b around 0
Applied rewrites52.9%
(FPCore (x y z t a b) :precision binary64 (if (<= t -2.65e+103) (* a 1.0) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -2.65e+103) {
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.65d+103)) 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.65e+103) {
tmp = a * 1.0;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -2.65e+103: tmp = a * 1.0 else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -2.65e+103) 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.65e+103) tmp = a * 1.0; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -2.65e+103], N[(a * 1.0), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.65 \cdot 10^{+103}:\\
\;\;\;\;a \cdot 1\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if t < -2.64999999999999985e103Initial program 64.5%
Taylor expanded in z around 0
associate--l+N/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-subN/A
lower-/.f64N/A
Applied rewrites62.1%
Taylor expanded in a around inf
Applied rewrites88.6%
Taylor expanded in t around inf
Applied rewrites48.9%
if -2.64999999999999985e103 < t Initial program 59.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.7
Applied rewrites60.7%
Taylor expanded in b around 0
Applied rewrites57.7%
(FPCore (x y z t a b) :precision binary64 (if (<= t -7.8e+204) (- a b) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -7.8e+204) {
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 (t <= (-7.8d+204)) 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 (t <= -7.8e+204) {
tmp = a - b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -7.8e+204: tmp = a - b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -7.8e+204) 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 (t <= -7.8e+204) tmp = a - b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -7.8e+204], N[(a - b), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.8 \cdot 10^{+204}:\\
\;\;\;\;a - b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if t < -7.80000000000000033e204Initial program 42.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6422.4
Applied rewrites22.4%
Taylor expanded in z around 0
Applied rewrites42.6%
if -7.80000000000000033e204 < t Initial program 62.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.4
Applied rewrites59.4%
Taylor expanded in b around 0
Applied rewrites56.7%
(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 60.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6456.5
Applied rewrites56.5%
Taylor expanded in b around 0
Applied rewrites53.7%
(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 60.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6456.5
Applied rewrites56.5%
Taylor expanded in b around inf
Applied rewrites12.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 2024220
(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)))