
(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 14 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 (+ y x)))
(t_2 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_3 (fma t_1 a z)))
(if (<= t_2 (- INFINITY))
(fma (- z b) (/ y (+ t y)) a)
(if (<= t_2 2e+306)
t_2
(-
(fma (- (/ (fma t_1 b a) (+ y x)) (/ t_3 (+ y x))) t t_3)
(* t_1 b))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y / (y + x);
double t_2 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_3 = fma(t_1, a, z);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma((z - b), (y / (t + y)), a);
} else if (t_2 <= 2e+306) {
tmp = t_2;
} else {
tmp = fma(((fma(t_1, b, a) / (y + x)) - (t_3 / (y + x))), t, t_3) - (t_1 * b);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(y / Float64(y + x)) t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_3 = fma(t_1, a, z) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); elseif (t_2 <= 2e+306) tmp = t_2; else tmp = Float64(fma(Float64(Float64(fma(t_1, b, a) / Float64(y + x)) - Float64(t_3 / Float64(y + x))), t, t_3) - Float64(t_1 * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$3 = N[(t$95$1 * a + z), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$2, 2e+306], t$95$2, N[(N[(N[(N[(N[(t$95$1 * b + a), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(t$95$3 / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t + t$95$3), $MachinePrecision] - N[(t$95$1 * b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{y + x}\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_3 := \mathsf{fma}\left(t\_1, a, z\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(t\_1, b, a\right)}{y + x} - \frac{t\_3}{y + x}, t, t\_3\right) - t\_1 \cdot b\\
\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.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6412.0
Applied rewrites12.0%
Taylor expanded in a around 0
Applied rewrites79.4%
Applied rewrites84.2%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.00000000000000003e306Initial program 99.7%
if 2.00000000000000003e306 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 4.8%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites78.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 4e+274)))
(fma (- z b) (/ y (+ t y)) a)
t_1)))
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 tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 4e+274)) {
tmp = fma((z - b), (y / (t + y)), a);
} else {
tmp = t_1;
}
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)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 4e+274)) tmp = fma(Float64(z - b), Float64(y / Float64(t + y)), a); else tmp = t_1; 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]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 4e+274]], $MachinePrecision]], N[(N[(z - b), $MachinePrecision] * N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]
\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}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 4 \cdot 10^{+274}\right):\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\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)) < -inf.0 or 3.99999999999999969e274 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 8.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6413.8
Applied rewrites13.8%
Taylor expanded in a around 0
Applied rewrites76.7%
Applied rewrites79.5%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 3.99999999999999969e274Initial program 99.7%
Final simplification91.3%
(FPCore (x y z t a b)
:precision binary64
(if (<= x -3e+101)
(fma (/ a x) t z)
(if (<= x -4e+36)
(* a (/ t (+ t x)))
(if (<= x 1.55e+53) (- (+ a z) b) (- z (/ (* b y) x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -3e+101) {
tmp = fma((a / x), t, z);
} else if (x <= -4e+36) {
tmp = a * (t / (t + x));
} else if (x <= 1.55e+53) {
tmp = (a + z) - b;
} else {
tmp = z - ((b * y) / x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -3e+101) tmp = fma(Float64(a / x), t, z); elseif (x <= -4e+36) tmp = Float64(a * Float64(t / Float64(t + x))); elseif (x <= 1.55e+53) tmp = Float64(Float64(a + z) - b); else tmp = Float64(z - Float64(Float64(b * y) / x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -3e+101], N[(N[(a / x), $MachinePrecision] * t + z), $MachinePrecision], If[LessEqual[x, -4e+36], N[(a * N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e+53], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(z - N[(N[(b * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{x}, t, z\right)\\
\mathbf{elif}\;x \leq -4 \cdot 10^{+36}:\\
\;\;\;\;a \cdot \frac{t}{t + x}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+53}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;z - \frac{b \cdot y}{x}\\
\end{array}
\end{array}
if x < -2.99999999999999993e101Initial program 45.6%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites86.9%
Taylor expanded in y around 0
Applied rewrites54.9%
Taylor expanded in z around 0
Applied rewrites57.3%
if -2.99999999999999993e101 < x < -4.00000000000000017e36Initial program 52.2%
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-+.f6463.7
Applied rewrites63.7%
Taylor expanded in y around 0
Applied rewrites57.5%
if -4.00000000000000017e36 < x < 1.5500000000000001e53Initial program 64.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.5
Applied rewrites63.5%
if 1.5500000000000001e53 < x Initial program 69.7%
Taylor expanded in x around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites62.6%
Taylor expanded in b around inf
Applied rewrites73.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.1e+126) (not (<= x 2.8e+53))) (- z (* (/ (- b a) x) y)) (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 <= -1.1e+126) || !(x <= 2.8e+53)) {
tmp = z - (((b - a) / x) * y);
} else {
tmp = fma((z - b), (y / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -1.1e+126) || !(x <= 2.8e+53)) tmp = Float64(z - Float64(Float64(Float64(b - a) / x) * y)); 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, -1.1e+126], N[Not[LessEqual[x, 2.8e+53]], $MachinePrecision]], N[(z - N[(N[(N[(b - a), $MachinePrecision] / x), $MachinePrecision] * y), $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 -1.1 \cdot 10^{+126} \lor \neg \left(x \leq 2.8 \cdot 10^{+53}\right):\\
\;\;\;\;z - \frac{b - a}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -1.09999999999999999e126 or 2.8e53 < x Initial program 58.0%
Taylor expanded in x around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites59.2%
Taylor expanded in y around inf
Applied rewrites73.6%
if -1.09999999999999999e126 < x < 2.8e53Initial program 63.9%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6450.5
Applied rewrites50.5%
Taylor expanded in a around 0
Applied rewrites82.0%
Applied rewrites85.3%
Final simplification81.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -9e+125) (not (<= x 6.2e+45))) (- z (* (/ (- b a) x) y)) (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 <= -9e+125) || !(x <= 6.2e+45)) {
tmp = z - (((b - a) / x) * y);
} else {
tmp = fma(y, ((z - b) / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -9e+125) || !(x <= 6.2e+45)) tmp = Float64(z - Float64(Float64(Float64(b - a) / x) * y)); 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, -9e+125], N[Not[LessEqual[x, 6.2e+45]], $MachinePrecision]], N[(z - N[(N[(N[(b - a), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]), $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 -9 \cdot 10^{+125} \lor \neg \left(x \leq 6.2 \cdot 10^{+45}\right):\\
\;\;\;\;z - \frac{b - a}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -9.0000000000000001e125 or 6.19999999999999975e45 < x Initial program 57.9%
Taylor expanded in x around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites59.1%
Taylor expanded in y around inf
Applied rewrites73.2%
if -9.0000000000000001e125 < x < 6.19999999999999975e45Initial program 64.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6450.7
Applied rewrites50.7%
Taylor expanded in a around 0
Applied rewrites82.3%
Final simplification78.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (/ a x) t z)))
(if (<= x -3e+101)
t_1
(if (<= x -4e+36)
(* a (/ t (+ t x)))
(if (<= x 1.55e+53) (- (+ a z) b) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a / x), t, z);
double tmp;
if (x <= -3e+101) {
tmp = t_1;
} else if (x <= -4e+36) {
tmp = a * (t / (t + x));
} else if (x <= 1.55e+53) {
tmp = (a + z) - b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(a / x), t, z) tmp = 0.0 if (x <= -3e+101) tmp = t_1; elseif (x <= -4e+36) tmp = Float64(a * Float64(t / Float64(t + x))); elseif (x <= 1.55e+53) tmp = Float64(Float64(a + z) - b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a / x), $MachinePrecision] * t + z), $MachinePrecision]}, If[LessEqual[x, -3e+101], t$95$1, If[LessEqual[x, -4e+36], N[(a * N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e+53], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{a}{x}, t, z\right)\\
\mathbf{if}\;x \leq -3 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -4 \cdot 10^{+36}:\\
\;\;\;\;a \cdot \frac{t}{t + x}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+53}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.99999999999999993e101 or 1.5500000000000001e53 < x Initial program 58.8%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites86.9%
Taylor expanded in y around 0
Applied rewrites62.9%
Taylor expanded in z around 0
Applied rewrites64.8%
if -2.99999999999999993e101 < x < -4.00000000000000017e36Initial program 52.2%
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-+.f6463.7
Applied rewrites63.7%
Taylor expanded in y around 0
Applied rewrites57.5%
if -4.00000000000000017e36 < x < 1.5500000000000001e53Initial program 64.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.5
Applied rewrites63.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -1.4e+148) (not (<= t 1.85e+65))) (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 <= -1.4e+148) || !(t <= 1.85e+65)) {
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 <= -1.4e+148) || !(t <= 1.85e+65)) 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, -1.4e+148], N[Not[LessEqual[t, 1.85e+65]], $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 -1.4 \cdot 10^{+148} \lor \neg \left(t \leq 1.85 \cdot 10^{+65}\right):\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t}, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -1.3999999999999999e148 or 1.84999999999999997e65 < t Initial program 51.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-+.f6439.3
Applied rewrites39.3%
Taylor expanded in a around 0
Applied rewrites80.0%
Applied rewrites80.0%
Taylor expanded in y around 0
Applied rewrites69.0%
if -1.3999999999999999e148 < t < 1.84999999999999997e65Initial program 67.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.6
Applied rewrites63.6%
Final simplification65.5%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.4e+148) (fma (- z b) (/ y t) a) (if (<= t 1.85e+65) (- (+ a z) b) (fma (/ (- z b) t) y a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.4e+148) {
tmp = fma((z - b), (y / t), a);
} else if (t <= 1.85e+65) {
tmp = (a + z) - b;
} else {
tmp = fma(((z - b) / t), y, a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.4e+148) tmp = fma(Float64(z - b), Float64(y / t), a); elseif (t <= 1.85e+65) tmp = Float64(Float64(a + z) - b); else tmp = fma(Float64(Float64(z - b) / t), y, a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.4e+148], N[(N[(z - b), $MachinePrecision] * N[(y / t), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t, 1.85e+65], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(N[(N[(z - b), $MachinePrecision] / t), $MachinePrecision] * y + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(z - b, \frac{y}{t}, a\right)\\
\mathbf{elif}\;t \leq 1.85 \cdot 10^{+65}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - b}{t}, y, a\right)\\
\end{array}
\end{array}
if t < -1.3999999999999999e148Initial program 47.4%
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.9
Applied rewrites40.9%
Taylor expanded in a around 0
Applied rewrites86.4%
Applied rewrites86.6%
Taylor expanded in y around 0
Applied rewrites73.0%
if -1.3999999999999999e148 < t < 1.84999999999999997e65Initial program 67.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.6
Applied rewrites63.6%
if 1.84999999999999997e65 < t Initial program 53.9%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6438.4
Applied rewrites38.4%
Taylor expanded in y around 0
Applied rewrites66.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -4e+36) (not (<= x 1.55e+53))) (fma (/ a x) t z) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -4e+36) || !(x <= 1.55e+53)) {
tmp = fma((a / x), t, z);
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -4e+36) || !(x <= 1.55e+53)) tmp = fma(Float64(a / x), t, z); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -4e+36], N[Not[LessEqual[x, 1.55e+53]], $MachinePrecision]], N[(N[(a / x), $MachinePrecision] * t + z), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+36} \lor \neg \left(x \leq 1.55 \cdot 10^{+53}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{x}, t, z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if x < -4.00000000000000017e36 or 1.5500000000000001e53 < x Initial program 57.8%
Taylor expanded in t around 0
lower--.f64N/A
Applied rewrites79.8%
Taylor expanded in y around 0
Applied rewrites57.6%
Taylor expanded in z around 0
Applied rewrites59.3%
if -4.00000000000000017e36 < x < 1.5500000000000001e53Initial program 64.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.5
Applied rewrites63.5%
Final simplification61.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -5.2e+219) (not (<= t 5e+65))) (* a 1.0) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -5.2e+219) || !(t <= 5e+65)) {
tmp = a * 1.0;
} else {
tmp = (a + 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 ((t <= (-5.2d+219)) .or. (.not. (t <= 5d+65))) then
tmp = a * 1.0d0
else
tmp = (a + 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 ((t <= -5.2e+219) || !(t <= 5e+65)) {
tmp = a * 1.0;
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (t <= -5.2e+219) or not (t <= 5e+65): tmp = a * 1.0 else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -5.2e+219) || !(t <= 5e+65)) tmp = Float64(a * 1.0); else tmp = Float64(Float64(a + z) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((t <= -5.2e+219) || ~((t <= 5e+65))) tmp = a * 1.0; else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -5.2e+219], N[Not[LessEqual[t, 5e+65]], $MachinePrecision]], N[(a * 1.0), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.2 \cdot 10^{+219} \lor \neg \left(t \leq 5 \cdot 10^{+65}\right):\\
\;\;\;\;a \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -5.1999999999999999e219 or 4.99999999999999973e65 < t Initial program 52.9%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6447.4
Applied rewrites47.4%
Taylor expanded in y around 0
Applied rewrites56.5%
Taylor expanded in x around 0
Applied rewrites55.2%
if -5.1999999999999999e219 < t < 4.99999999999999973e65Initial program 65.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6461.2
Applied rewrites61.2%
Final simplification59.4%
(FPCore (x y z t a b) :precision binary64 (if (<= t 1.65e+209) (+ a z) (* a 1.0)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 1.65e+209) {
tmp = a + z;
} else {
tmp = a * 1.0;
}
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.65d+209) then
tmp = a + z
else
tmp = a * 1.0d0
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.65e+209) {
tmp = a + z;
} else {
tmp = a * 1.0;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= 1.65e+209: tmp = a + z else: tmp = a * 1.0 return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 1.65e+209) tmp = Float64(a + z); else tmp = Float64(a * 1.0); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= 1.65e+209) tmp = a + z; else tmp = a * 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 1.65e+209], N[(a + z), $MachinePrecision], N[(a * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.65 \cdot 10^{+209}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;a \cdot 1\\
\end{array}
\end{array}
if t < 1.6499999999999999e209Initial program 62.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.3
Applied rewrites55.3%
Taylor expanded in b around inf
Applied rewrites11.9%
Taylor expanded in b around 0
Applied rewrites53.2%
if 1.6499999999999999e209 < t Initial program 56.1%
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-+.f6452.6
Applied rewrites52.6%
Taylor expanded in y around 0
Applied rewrites70.9%
Taylor expanded in x around 0
Applied rewrites70.8%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.22e+244) (- a b) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.22e+244) {
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 (y <= (-1.22d+244)) 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 (y <= -1.22e+244) {
tmp = a - b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.22e+244: tmp = a - b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.22e+244) 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 (y <= -1.22e+244) tmp = a - b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.22e+244], N[(a - b), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.22 \cdot 10^{+244}:\\
\;\;\;\;a - b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if y < -1.22000000000000005e244Initial program 29.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6488.5
Applied rewrites88.5%
Taylor expanded in z around 0
Applied rewrites87.8%
if -1.22000000000000005e244 < y Initial program 63.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6452.3
Applied rewrites52.3%
Taylor expanded in b around inf
Applied rewrites9.8%
Taylor expanded in b around 0
Applied rewrites53.1%
(FPCore (x y z t a b) :precision binary64 (if (<= b 5e+221) (+ a z) (- b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= 5e+221) {
tmp = a + z;
} 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+221) then
tmp = a + z
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+221) {
tmp = a + z;
} else {
tmp = -b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= 5e+221: tmp = a + z else: tmp = -b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= 5e+221) tmp = Float64(a + z); else tmp = Float64(-b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= 5e+221) tmp = a + z; else tmp = -b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, 5e+221], N[(a + z), $MachinePrecision], (-b)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{+221}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;-b\\
\end{array}
\end{array}
if b < 5.0000000000000002e221Initial program 64.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6454.6
Applied rewrites54.6%
Taylor expanded in b around inf
Applied rewrites9.4%
Taylor expanded in b around 0
Applied rewrites55.1%
if 5.0000000000000002e221 < b Initial program 28.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6442.6
Applied rewrites42.6%
Taylor expanded in b around inf
Applied rewrites40.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 61.7%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6453.8
Applied rewrites53.8%
Taylor expanded in b around inf
Applied rewrites11.5%
(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 2024332
(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)))