
(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 (/ (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b)) (+ y (+ x t))))) (if (or (<= t_1 -1e+246) (not (<= t_1 2e+292))) (- (+ z a) b) t_1)))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((z * (x + y)) + ((y + t) * a)) - (y * b)) / (y + (x + t));
double tmp;
if ((t_1 <= -1e+246) || !(t_1 <= 2e+292)) {
tmp = (z + a) - 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 = (((z * (x + y)) + ((y + t) * a)) - (y * b)) / (y + (x + t))
if ((t_1 <= (-1d+246)) .or. (.not. (t_1 <= 2d+292))) then
tmp = (z + a) - 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 = (((z * (x + y)) + ((y + t) * a)) - (y * b)) / (y + (x + t));
double tmp;
if ((t_1 <= -1e+246) || !(t_1 <= 2e+292)) {
tmp = (z + a) - b;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (((z * (x + y)) + ((y + t) * a)) - (y * b)) / (y + (x + t)) tmp = 0 if (t_1 <= -1e+246) or not (t_1 <= 2e+292): tmp = (z + a) - b else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(z * Float64(x + y)) + Float64(Float64(y + t) * a)) - Float64(y * b)) / Float64(y + Float64(x + t))) tmp = 0.0 if ((t_1 <= -1e+246) || !(t_1 <= 2e+292)) tmp = Float64(Float64(z + a) - b); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (((z * (x + y)) + ((y + t) * a)) - (y * b)) / (y + (x + t)); tmp = 0.0; if ((t_1 <= -1e+246) || ~((t_1 <= 2e+292))) tmp = (z + a) - b; else tmp = t_1; 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[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+246], N[Not[LessEqual[t$95$1, 2e+292]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+246} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+292}\right):\\
\;\;\;\;\left(z + a\right) - b\\
\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)) < -1.00000000000000007e246 or 2e292 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 10.7%
Taylor expanded in y around inf 75.0%
if -1.00000000000000007e246 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2e292Initial program 99.8%
Final simplification89.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -2.5e+47) (not (<= y 4.6e-27))) (- (+ z a) b) (* z (+ (/ x (+ x t)) (* (/ a z) (/ t (+ x t)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -2.5e+47) || !(y <= 4.6e-27)) {
tmp = (z + a) - b;
} else {
tmp = z * ((x / (x + t)) + ((a / z) * (t / (x + t))));
}
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 <= (-2.5d+47)) .or. (.not. (y <= 4.6d-27))) then
tmp = (z + a) - b
else
tmp = z * ((x / (x + t)) + ((a / z) * (t / (x + t))))
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 <= -2.5e+47) || !(y <= 4.6e-27)) {
tmp = (z + a) - b;
} else {
tmp = z * ((x / (x + t)) + ((a / z) * (t / (x + t))));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -2.5e+47) or not (y <= 4.6e-27): tmp = (z + a) - b else: tmp = z * ((x / (x + t)) + ((a / z) * (t / (x + t)))) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -2.5e+47) || !(y <= 4.6e-27)) tmp = Float64(Float64(z + a) - b); else tmp = Float64(z * Float64(Float64(x / Float64(x + t)) + Float64(Float64(a / z) * Float64(t / Float64(x + t))))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -2.5e+47) || ~((y <= 4.6e-27))) tmp = (z + a) - b; else tmp = z * ((x / (x + t)) + ((a / z) * (t / (x + t)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -2.5e+47], N[Not[LessEqual[y, 4.6e-27]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(z * N[(N[(x / N[(x + t), $MachinePrecision]), $MachinePrecision] + N[(N[(a / z), $MachinePrecision] * N[(t / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+47} \lor \neg \left(y \leq 4.6 \cdot 10^{-27}\right):\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{x}{x + t} + \frac{a}{z} \cdot \frac{t}{x + t}\right)\\
\end{array}
\end{array}
if y < -2.50000000000000011e47 or 4.5999999999999999e-27 < y Initial program 40.6%
Taylor expanded in y around inf 77.3%
if -2.50000000000000011e47 < y < 4.5999999999999999e-27Initial program 81.8%
Taylor expanded in z around inf 83.5%
associate--l+83.5%
+-commutative83.5%
+-commutative83.5%
times-frac84.3%
+-commutative84.3%
times-frac75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in y around 0 65.0%
times-frac67.3%
Simplified67.3%
Final simplification72.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ z a) b)))
(if (<= y -1.3e-19)
t_1
(if (<= y 7.7e-118)
(/ (+ (* t a) (* x z)) (+ x t))
(if (<= y 8.2e+20) (+ z (/ (* y (- a b)) (+ x y))) 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 <= -1.3e-19) {
tmp = t_1;
} else if (y <= 7.7e-118) {
tmp = ((t * a) + (x * z)) / (x + t);
} else if (y <= 8.2e+20) {
tmp = z + ((y * (a - b)) / (x + y));
} 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 <= (-1.3d-19)) then
tmp = t_1
else if (y <= 7.7d-118) then
tmp = ((t * a) + (x * z)) / (x + t)
else if (y <= 8.2d+20) then
tmp = z + ((y * (a - b)) / (x + y))
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 <= -1.3e-19) {
tmp = t_1;
} else if (y <= 7.7e-118) {
tmp = ((t * a) + (x * z)) / (x + t);
} else if (y <= 8.2e+20) {
tmp = z + ((y * (a - b)) / (x + y));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + a) - b tmp = 0 if y <= -1.3e-19: tmp = t_1 elif y <= 7.7e-118: tmp = ((t * a) + (x * z)) / (x + t) elif y <= 8.2e+20: tmp = z + ((y * (a - b)) / (x + y)) 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 <= -1.3e-19) tmp = t_1; elseif (y <= 7.7e-118) tmp = Float64(Float64(Float64(t * a) + Float64(x * z)) / Float64(x + t)); elseif (y <= 8.2e+20) tmp = Float64(z + Float64(Float64(y * Float64(a - b)) / Float64(x + y))); 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 <= -1.3e-19) tmp = t_1; elseif (y <= 7.7e-118) tmp = ((t * a) + (x * z)) / (x + t); elseif (y <= 8.2e+20) tmp = z + ((y * (a - b)) / (x + y)); 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, -1.3e-19], t$95$1, If[LessEqual[y, 7.7e-118], N[(N[(N[(t * a), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(x + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+20], N[(z + N[(N[(y * N[(a - b), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 7.7 \cdot 10^{-118}:\\
\;\;\;\;\frac{t \cdot a + x \cdot z}{x + t}\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+20}:\\
\;\;\;\;z + \frac{y \cdot \left(a - b\right)}{x + y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.30000000000000006e-19 or 8.2e20 < y Initial program 40.8%
Taylor expanded in y around inf 76.1%
if -1.30000000000000006e-19 < y < 7.6999999999999996e-118Initial program 85.8%
Taylor expanded in y around 0 66.6%
if 7.6999999999999996e-118 < y < 8.2e20Initial program 68.8%
Taylor expanded in t around 0 57.6%
Taylor expanded in a around 0 71.8%
associate--l+71.8%
div-sub71.7%
distribute-rgt-out--71.8%
+-commutative71.8%
Simplified71.8%
Final simplification71.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ z a) b)))
(if (<= y -1.1e-15)
t_1
(if (<= y 5.2e-231)
(* a (/ (+ y t) (+ y (+ x t))))
(if (<= y 8.2e+20) (+ z (/ (* y (- a b)) (+ x y))) 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 <= -1.1e-15) {
tmp = t_1;
} else if (y <= 5.2e-231) {
tmp = a * ((y + t) / (y + (x + t)));
} else if (y <= 8.2e+20) {
tmp = z + ((y * (a - b)) / (x + y));
} 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 <= (-1.1d-15)) then
tmp = t_1
else if (y <= 5.2d-231) then
tmp = a * ((y + t) / (y + (x + t)))
else if (y <= 8.2d+20) then
tmp = z + ((y * (a - b)) / (x + y))
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 <= -1.1e-15) {
tmp = t_1;
} else if (y <= 5.2e-231) {
tmp = a * ((y + t) / (y + (x + t)));
} else if (y <= 8.2e+20) {
tmp = z + ((y * (a - b)) / (x + y));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + a) - b tmp = 0 if y <= -1.1e-15: tmp = t_1 elif y <= 5.2e-231: tmp = a * ((y + t) / (y + (x + t))) elif y <= 8.2e+20: tmp = z + ((y * (a - b)) / (x + y)) 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 <= -1.1e-15) tmp = t_1; elseif (y <= 5.2e-231) tmp = Float64(a * Float64(Float64(y + t) / Float64(y + Float64(x + t)))); elseif (y <= 8.2e+20) tmp = Float64(z + Float64(Float64(y * Float64(a - b)) / Float64(x + y))); 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 <= -1.1e-15) tmp = t_1; elseif (y <= 5.2e-231) tmp = a * ((y + t) / (y + (x + t))); elseif (y <= 8.2e+20) tmp = z + ((y * (a - b)) / (x + y)); 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, -1.1e-15], t$95$1, If[LessEqual[y, 5.2e-231], N[(a * N[(N[(y + t), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+20], N[(z + N[(N[(y * N[(a - b), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -1.1 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-231}:\\
\;\;\;\;a \cdot \frac{y + t}{y + \left(x + t\right)}\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+20}:\\
\;\;\;\;z + \frac{y \cdot \left(a - b\right)}{x + y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.09999999999999993e-15 or 8.2e20 < y Initial program 40.3%
Taylor expanded in y around inf 76.0%
if -1.09999999999999993e-15 < y < 5.20000000000000006e-231Initial program 84.6%
Taylor expanded in a around inf 47.2%
associate-/l*54.0%
associate-+r+54.0%
Simplified54.0%
if 5.20000000000000006e-231 < y < 8.2e20Initial program 78.8%
Taylor expanded in t around 0 57.9%
Taylor expanded in a around 0 67.6%
associate--l+67.6%
div-sub67.6%
distribute-rgt-out--67.6%
+-commutative67.6%
Simplified67.6%
Final simplification67.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ y (+ x t))) (t_2 (- (+ z a) b)))
(if (<= y -3.2e-15)
t_2
(if (<= y 1.85e-169)
(* a (/ (+ y t) t_1))
(if (<= y 2.05e-30) (* z (/ (+ x y) t_1)) t_2)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (x + t);
double t_2 = (z + a) - b;
double tmp;
if (y <= -3.2e-15) {
tmp = t_2;
} else if (y <= 1.85e-169) {
tmp = a * ((y + t) / t_1);
} else if (y <= 2.05e-30) {
tmp = z * ((x + y) / 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 = y + (x + t)
t_2 = (z + a) - b
if (y <= (-3.2d-15)) then
tmp = t_2
else if (y <= 1.85d-169) then
tmp = a * ((y + t) / t_1)
else if (y <= 2.05d-30) then
tmp = z * ((x + y) / 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 = y + (x + t);
double t_2 = (z + a) - b;
double tmp;
if (y <= -3.2e-15) {
tmp = t_2;
} else if (y <= 1.85e-169) {
tmp = a * ((y + t) / t_1);
} else if (y <= 2.05e-30) {
tmp = z * ((x + y) / t_1);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = y + (x + t) t_2 = (z + a) - b tmp = 0 if y <= -3.2e-15: tmp = t_2 elif y <= 1.85e-169: tmp = a * ((y + t) / t_1) elif y <= 2.05e-30: tmp = z * ((x + y) / t_1) else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(y + Float64(x + t)) t_2 = Float64(Float64(z + a) - b) tmp = 0.0 if (y <= -3.2e-15) tmp = t_2; elseif (y <= 1.85e-169) tmp = Float64(a * Float64(Float64(y + t) / t_1)); elseif (y <= 2.05e-30) tmp = Float64(z * Float64(Float64(x + y) / t_1)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = y + (x + t); t_2 = (z + a) - b; tmp = 0.0; if (y <= -3.2e-15) tmp = t_2; elseif (y <= 1.85e-169) tmp = a * ((y + t) / t_1); elseif (y <= 2.05e-30) tmp = z * ((x + y) / t_1); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -3.2e-15], t$95$2, If[LessEqual[y, 1.85e-169], N[(a * N[(N[(y + t), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.05e-30], N[(z * N[(N[(x + y), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y + \left(x + t\right)\\
t_2 := \left(z + a\right) - b\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{-15}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-169}:\\
\;\;\;\;a \cdot \frac{y + t}{t\_1}\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-30}:\\
\;\;\;\;z \cdot \frac{x + y}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y < -3.1999999999999999e-15 or 2.0500000000000002e-30 < y Initial program 42.3%
Taylor expanded in y around inf 75.6%
if -3.1999999999999999e-15 < y < 1.8499999999999999e-169Initial program 85.8%
Taylor expanded in a around inf 46.8%
associate-/l*53.6%
associate-+r+53.6%
Simplified53.6%
if 1.8499999999999999e-169 < y < 2.0500000000000002e-30Initial program 70.9%
Taylor expanded in z around inf 41.0%
associate-/l*60.3%
+-commutative60.3%
associate-+r+60.3%
Simplified60.3%
Final simplification65.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -8.5e-16) (not (<= y 8.5e-150))) (- (+ z a) b) (* a (/ (+ y t) (+ y (+ x t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -8.5e-16) || !(y <= 8.5e-150)) {
tmp = (z + a) - b;
} else {
tmp = a * ((y + t) / (y + (x + t)));
}
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 <= (-8.5d-16)) .or. (.not. (y <= 8.5d-150))) then
tmp = (z + a) - b
else
tmp = a * ((y + t) / (y + (x + t)))
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 <= -8.5e-16) || !(y <= 8.5e-150)) {
tmp = (z + a) - b;
} else {
tmp = a * ((y + t) / (y + (x + t)));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -8.5e-16) or not (y <= 8.5e-150): tmp = (z + a) - b else: tmp = a * ((y + t) / (y + (x + t))) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -8.5e-16) || !(y <= 8.5e-150)) tmp = Float64(Float64(z + a) - b); else tmp = Float64(a * Float64(Float64(y + t) / Float64(y + Float64(x + t)))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -8.5e-16) || ~((y <= 8.5e-150))) tmp = (z + a) - b; else tmp = a * ((y + t) / (y + (x + t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -8.5e-16], N[Not[LessEqual[y, 8.5e-150]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(a * N[(N[(y + t), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-16} \lor \neg \left(y \leq 8.5 \cdot 10^{-150}\right):\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{y + t}{y + \left(x + t\right)}\\
\end{array}
\end{array}
if y < -8.5000000000000001e-16 or 8.4999999999999997e-150 < y Initial program 47.0%
Taylor expanded in y around inf 70.2%
if -8.5000000000000001e-16 < y < 8.4999999999999997e-150Initial program 85.3%
Taylor expanded in a around inf 46.5%
associate-/l*53.1%
associate-+r+53.1%
Simplified53.1%
Final simplification63.7%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.5e+119) (* a (/ t (+ x t))) (- (+ z a) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.5e+119) {
tmp = a * (t / (x + t));
} else {
tmp = (z + 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 (t <= (-1.5d+119)) then
tmp = a * (t / (x + t))
else
tmp = (z + 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 (t <= -1.5e+119) {
tmp = a * (t / (x + t));
} else {
tmp = (z + a) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.5e+119: tmp = a * (t / (x + t)) else: tmp = (z + a) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.5e+119) tmp = Float64(a * Float64(t / Float64(x + t))); else tmp = Float64(Float64(z + a) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.5e+119) tmp = a * (t / (x + t)); else tmp = (z + a) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.5e+119], N[(a * N[(t / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.5 \cdot 10^{+119}:\\
\;\;\;\;a \cdot \frac{t}{x + t}\\
\mathbf{else}:\\
\;\;\;\;\left(z + a\right) - b\\
\end{array}
\end{array}
if t < -1.50000000000000001e119Initial program 53.2%
Taylor expanded in y around 0 47.4%
Taylor expanded in a around inf 40.0%
associate-/l*63.5%
+-commutative63.5%
Simplified63.5%
if -1.50000000000000001e119 < t Initial program 63.2%
Taylor expanded in y around inf 61.5%
Final simplification61.8%
(FPCore (x y z t a b) :precision binary64 (if (<= x -1.65e+58) z (if (<= x 1.35e-43) a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -1.65e+58) {
tmp = z;
} else if (x <= 1.35e-43) {
tmp = a;
} else {
tmp = 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 (x <= (-1.65d+58)) then
tmp = z
else if (x <= 1.35d-43) then
tmp = a
else
tmp = 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 (x <= -1.65e+58) {
tmp = z;
} else if (x <= 1.35e-43) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -1.65e+58: tmp = z elif x <= 1.35e-43: tmp = a else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -1.65e+58) tmp = z; elseif (x <= 1.35e-43) tmp = a; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -1.65e+58) tmp = z; elseif (x <= 1.35e-43) tmp = a; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -1.65e+58], z, If[LessEqual[x, 1.35e-43], a, z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{+58}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-43}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -1.64999999999999991e58 or 1.34999999999999996e-43 < x Initial program 53.6%
Taylor expanded in x around inf 47.4%
if -1.64999999999999991e58 < x < 1.34999999999999996e-43Initial program 69.8%
Taylor expanded in t around inf 48.8%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.45e+124) a (- (+ z a) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.45e+124) {
tmp = a;
} else {
tmp = (z + 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 (t <= (-1.45d+124)) then
tmp = a
else
tmp = (z + 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 (t <= -1.45e+124) {
tmp = a;
} else {
tmp = (z + a) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.45e+124: tmp = a else: tmp = (z + a) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.45e+124) tmp = a; else tmp = Float64(Float64(z + a) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.45e+124) tmp = a; else tmp = (z + a) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.45e+124], a, N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{+124}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(z + a\right) - b\\
\end{array}
\end{array}
if t < -1.45000000000000011e124Initial program 53.2%
Taylor expanded in t around inf 57.2%
if -1.45000000000000011e124 < t Initial program 63.2%
Taylor expanded in y around inf 61.5%
Final simplification60.8%
(FPCore (x y z t a b) :precision binary64 a)
double code(double x, double y, double z, double t, double a, double b) {
return a;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a;
}
def code(x, y, z, t, a, b): return a
function code(x, y, z, t, a, b) return a end
function tmp = code(x, y, z, t, a, b) tmp = a; end
code[x_, y_, z_, t_, a_, b_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 61.5%
Taylor expanded in t around inf 31.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ x t) y))
(t_2 (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))
(t_3 (/ t_2 t_1))
(t_4 (- (+ z a) b)))
(if (< t_3 -3.5813117084150564e+153)
t_4
(if (< t_3 1.2285964308315609e+82) (/ 1.0 (/ t_1 t_2)) t_4))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b);
double t_3 = t_2 / t_1;
double t_4 = (z + a) - b;
double tmp;
if (t_3 < -3.5813117084150564e+153) {
tmp = t_4;
} else if (t_3 < 1.2285964308315609e+82) {
tmp = 1.0 / (t_1 / t_2);
} else {
tmp = t_4;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_1 = (x + t) + y
t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b)
t_3 = t_2 / t_1
t_4 = (z + a) - b
if (t_3 < (-3.5813117084150564d+153)) then
tmp = t_4
else if (t_3 < 1.2285964308315609d+82) then
tmp = 1.0d0 / (t_1 / t_2)
else
tmp = t_4
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b);
double t_3 = t_2 / t_1;
double t_4 = (z + a) - b;
double tmp;
if (t_3 < -3.5813117084150564e+153) {
tmp = t_4;
} else if (t_3 < 1.2285964308315609e+82) {
tmp = 1.0 / (t_1 / t_2);
} else {
tmp = t_4;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x + t) + y t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b) t_3 = t_2 / t_1 t_4 = (z + a) - b tmp = 0 if t_3 < -3.5813117084150564e+153: tmp = t_4 elif t_3 < 1.2285964308315609e+82: tmp = 1.0 / (t_1 / t_2) else: tmp = t_4 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + t) + y) t_2 = Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) t_3 = Float64(t_2 / t_1) t_4 = Float64(Float64(z + a) - b) tmp = 0.0 if (t_3 < -3.5813117084150564e+153) tmp = t_4; elseif (t_3 < 1.2285964308315609e+82) tmp = Float64(1.0 / Float64(t_1 / t_2)); else tmp = t_4; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x + t) + y; t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b); t_3 = t_2 / t_1; t_4 = (z + a) - b; tmp = 0.0; if (t_3 < -3.5813117084150564e+153) tmp = t_4; elseif (t_3 < 1.2285964308315609e+82) tmp = 1.0 / (t_1 / t_2); else tmp = t_4; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[Less[t$95$3, -3.5813117084150564e+153], t$95$4, If[Less[t$95$3, 1.2285964308315609e+82], N[(1.0 / N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + t\right) + y\\
t_2 := \left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\\
t_3 := \frac{t\_2}{t\_1}\\
t_4 := \left(z + a\right) - b\\
\mathbf{if}\;t\_3 < -3.5813117084150564 \cdot 10^{+153}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_3 < 1.2285964308315609 \cdot 10^{+82}:\\
\;\;\;\;\frac{1}{\frac{t\_1}{t\_2}}\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
herbie shell --seed 2024118
(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)))