
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * 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 = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\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)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * 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 = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (fma a b (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, b, fma(x, y, (z * t)));
}
function code(x, y, z, t, a, b) return fma(a, b, fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)
\end{array}
Initial program 98.0%
+-commutative98.0%
fma-define98.8%
fma-define99.2%
Simplified99.2%
(FPCore (x y z t a b) :precision binary64 (+ (fma x y (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, (z * t)) + (a * b);
}
function code(x, y, z, t, a, b) return Float64(fma(x, y, Float64(z * t)) + Float64(a * b)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b
\end{array}
Initial program 98.0%
fma-define98.4%
Simplified98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -8.6e+129)
(* a b)
(if (<= (* a b) -1.45e+87)
(* x y)
(if (<= (* a b) -6.8e+45)
(* a b)
(if (<= (* a b) -7.8e-108)
(* z t)
(if (<= (* a b) -3.4e-183)
(* x y)
(if (<= (* a b) 112000000000.0) (* z t) (* a b))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -8.6e+129) {
tmp = a * b;
} else if ((a * b) <= -1.45e+87) {
tmp = x * y;
} else if ((a * b) <= -6.8e+45) {
tmp = a * b;
} else if ((a * b) <= -7.8e-108) {
tmp = z * t;
} else if ((a * b) <= -3.4e-183) {
tmp = x * y;
} else if ((a * b) <= 112000000000.0) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * b) <= (-8.6d+129)) then
tmp = a * b
else if ((a * b) <= (-1.45d+87)) then
tmp = x * y
else if ((a * b) <= (-6.8d+45)) then
tmp = a * b
else if ((a * b) <= (-7.8d-108)) then
tmp = z * t
else if ((a * b) <= (-3.4d-183)) then
tmp = x * y
else if ((a * b) <= 112000000000.0d0) then
tmp = z * t
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -8.6e+129) {
tmp = a * b;
} else if ((a * b) <= -1.45e+87) {
tmp = x * y;
} else if ((a * b) <= -6.8e+45) {
tmp = a * b;
} else if ((a * b) <= -7.8e-108) {
tmp = z * t;
} else if ((a * b) <= -3.4e-183) {
tmp = x * y;
} else if ((a * b) <= 112000000000.0) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -8.6e+129: tmp = a * b elif (a * b) <= -1.45e+87: tmp = x * y elif (a * b) <= -6.8e+45: tmp = a * b elif (a * b) <= -7.8e-108: tmp = z * t elif (a * b) <= -3.4e-183: tmp = x * y elif (a * b) <= 112000000000.0: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -8.6e+129) tmp = Float64(a * b); elseif (Float64(a * b) <= -1.45e+87) tmp = Float64(x * y); elseif (Float64(a * b) <= -6.8e+45) tmp = Float64(a * b); elseif (Float64(a * b) <= -7.8e-108) tmp = Float64(z * t); elseif (Float64(a * b) <= -3.4e-183) tmp = Float64(x * y); elseif (Float64(a * b) <= 112000000000.0) tmp = Float64(z * t); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -8.6e+129) tmp = a * b; elseif ((a * b) <= -1.45e+87) tmp = x * y; elseif ((a * b) <= -6.8e+45) tmp = a * b; elseif ((a * b) <= -7.8e-108) tmp = z * t; elseif ((a * b) <= -3.4e-183) tmp = x * y; elseif ((a * b) <= 112000000000.0) tmp = z * t; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -8.6e+129], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.45e+87], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -6.8e+45], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -7.8e-108], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -3.4e-183], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 112000000000.0], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -8.6 \cdot 10^{+129}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1.45 \cdot 10^{+87}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq -6.8 \cdot 10^{+45}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -7.8 \cdot 10^{-108}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq -3.4 \cdot 10^{-183}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 112000000000:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -8.60000000000000042e129 or -1.4499999999999999e87 < (*.f64 a b) < -6.8e45 or 1.12e11 < (*.f64 a b) Initial program 96.5%
Taylor expanded in a around inf 72.3%
if -8.60000000000000042e129 < (*.f64 a b) < -1.4499999999999999e87 or -7.79999999999999989e-108 < (*.f64 a b) < -3.40000000000000014e-183Initial program 100.0%
Taylor expanded in x around inf 65.4%
if -6.8e45 < (*.f64 a b) < -7.79999999999999989e-108 or -3.40000000000000014e-183 < (*.f64 a b) < 1.12e11Initial program 99.1%
Taylor expanded in z around inf 59.4%
Final simplification65.7%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -7.5e+287)
(not
(or (<= (* x y) -5.8e+140)
(and (not (<= (* x y) -1.55e+122)) (<= (* x y) 1.2e+219)))))
(* x y)
(+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -7.5e+287) || !(((x * y) <= -5.8e+140) || (!((x * y) <= -1.55e+122) && ((x * y) <= 1.2e+219)))) {
tmp = x * y;
} else {
tmp = (a * b) + (z * 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 (((x * y) <= (-7.5d+287)) .or. (.not. ((x * y) <= (-5.8d+140)) .or. (.not. ((x * y) <= (-1.55d+122))) .and. ((x * y) <= 1.2d+219))) then
tmp = x * y
else
tmp = (a * b) + (z * 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 (((x * y) <= -7.5e+287) || !(((x * y) <= -5.8e+140) || (!((x * y) <= -1.55e+122) && ((x * y) <= 1.2e+219)))) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -7.5e+287) or not (((x * y) <= -5.8e+140) or (not ((x * y) <= -1.55e+122) and ((x * y) <= 1.2e+219))): tmp = x * y else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -7.5e+287) || !((Float64(x * y) <= -5.8e+140) || (!(Float64(x * y) <= -1.55e+122) && (Float64(x * y) <= 1.2e+219)))) tmp = Float64(x * y); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((x * y) <= -7.5e+287) || ~((((x * y) <= -5.8e+140) || (~(((x * y) <= -1.55e+122)) && ((x * y) <= 1.2e+219))))) tmp = x * y; else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -7.5e+287], N[Not[Or[LessEqual[N[(x * y), $MachinePrecision], -5.8e+140], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -1.55e+122]], $MachinePrecision], LessEqual[N[(x * y), $MachinePrecision], 1.2e+219]]]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -7.5 \cdot 10^{+287} \lor \neg \left(x \cdot y \leq -5.8 \cdot 10^{+140} \lor \neg \left(x \cdot y \leq -1.55 \cdot 10^{+122}\right) \land x \cdot y \leq 1.2 \cdot 10^{+219}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -7.4999999999999994e287 or -5.7999999999999998e140 < (*.f64 x y) < -1.54999999999999999e122 or 1.2e219 < (*.f64 x y) Initial program 90.7%
Taylor expanded in x around inf 92.5%
if -7.4999999999999994e287 < (*.f64 x y) < -5.7999999999999998e140 or -1.54999999999999999e122 < (*.f64 x y) < 1.2e219Initial program 99.5%
Taylor expanded in x around 0 83.8%
Final simplification85.2%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -1e+56) (* b (+ a (* x (/ y b)))) (if (<= (* a b) 2e+18) (+ (* x y) (* z t)) (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1e+56) {
tmp = b * (a + (x * (y / b)));
} else if ((a * b) <= 2e+18) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * 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 ((a * b) <= (-1d+56)) then
tmp = b * (a + (x * (y / b)))
else if ((a * b) <= 2d+18) then
tmp = (x * y) + (z * t)
else
tmp = (a * b) + (z * 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 ((a * b) <= -1e+56) {
tmp = b * (a + (x * (y / b)));
} else if ((a * b) <= 2e+18) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1e+56: tmp = b * (a + (x * (y / b))) elif (a * b) <= 2e+18: tmp = (x * y) + (z * t) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1e+56) tmp = Float64(b * Float64(a + Float64(x * Float64(y / b)))); elseif (Float64(a * b) <= 2e+18) tmp = Float64(Float64(x * y) + Float64(z * t)); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -1e+56) tmp = b * (a + (x * (y / b))); elseif ((a * b) <= 2e+18) tmp = (x * y) + (z * t); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1e+56], N[(b * N[(a + N[(x * N[(y / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+18], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+56}:\\
\;\;\;\;b \cdot \left(a + x \cdot \frac{y}{b}\right)\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+18}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.00000000000000009e56Initial program 94.8%
Taylor expanded in b around inf 93.2%
Taylor expanded in t around 0 88.2%
associate-*r/89.9%
Simplified89.9%
if -1.00000000000000009e56 < (*.f64 a b) < 2e18Initial program 99.2%
Taylor expanded in a around 0 90.8%
if 2e18 < (*.f64 a b) Initial program 98.5%
Taylor expanded in x around 0 92.5%
Final simplification91.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -5.8e+51) (+ (* a b) (* x y)) (if (<= (* a b) 2.1e+19) (+ (* x y) (* z t)) (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -5.8e+51) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 2.1e+19) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * 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 ((a * b) <= (-5.8d+51)) then
tmp = (a * b) + (x * y)
else if ((a * b) <= 2.1d+19) then
tmp = (x * y) + (z * t)
else
tmp = (a * b) + (z * 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 ((a * b) <= -5.8e+51) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 2.1e+19) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -5.8e+51: tmp = (a * b) + (x * y) elif (a * b) <= 2.1e+19: tmp = (x * y) + (z * t) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -5.8e+51) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(a * b) <= 2.1e+19) tmp = Float64(Float64(x * y) + Float64(z * t)); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -5.8e+51) tmp = (a * b) + (x * y); elseif ((a * b) <= 2.1e+19) tmp = (x * y) + (z * t); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -5.8e+51], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2.1e+19], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5.8 \cdot 10^{+51}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 2.1 \cdot 10^{+19}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -5.7999999999999997e51Initial program 94.8%
Taylor expanded in z around 0 86.4%
if -5.7999999999999997e51 < (*.f64 a b) < 2.1e19Initial program 99.2%
Taylor expanded in a around 0 90.8%
if 2.1e19 < (*.f64 a b) Initial program 98.5%
Taylor expanded in x around 0 92.5%
Final simplification90.3%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -1650000.0) (+ (* a b) (* x y)) (if (<= (* x y) 1.15e+220) (+ (* a b) (* z t)) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -1650000.0) {
tmp = (a * b) + (x * y);
} else if ((x * y) <= 1.15e+220) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
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 * y) <= (-1650000.0d0)) then
tmp = (a * b) + (x * y)
else if ((x * y) <= 1.15d+220) then
tmp = (a * b) + (z * t)
else
tmp = x * y
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 * y) <= -1650000.0) {
tmp = (a * b) + (x * y);
} else if ((x * y) <= 1.15e+220) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -1650000.0: tmp = (a * b) + (x * y) elif (x * y) <= 1.15e+220: tmp = (a * b) + (z * t) else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -1650000.0) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(x * y) <= 1.15e+220) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -1650000.0) tmp = (a * b) + (x * y); elseif ((x * y) <= 1.15e+220) tmp = (a * b) + (z * t); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -1650000.0], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.15e+220], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1650000:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.15 \cdot 10^{+220}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1.65e6Initial program 100.0%
Taylor expanded in z around 0 78.9%
if -1.65e6 < (*.f64 x y) < 1.14999999999999998e220Initial program 99.4%
Taylor expanded in x around 0 90.3%
if 1.14999999999999998e220 < (*.f64 x y) Initial program 81.8%
Taylor expanded in x around inf 90.9%
Final simplification87.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -6.8e+51) (not (<= (* a b) 74000000000.0))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -6.8e+51) || !((a * b) <= 74000000000.0)) {
tmp = a * b;
} else {
tmp = z * 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 (((a * b) <= (-6.8d+51)) .or. (.not. ((a * b) <= 74000000000.0d0))) then
tmp = a * b
else
tmp = z * 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 (((a * b) <= -6.8e+51) || !((a * b) <= 74000000000.0)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -6.8e+51) or not ((a * b) <= 74000000000.0): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -6.8e+51) || !(Float64(a * b) <= 74000000000.0)) tmp = Float64(a * b); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((a * b) <= -6.8e+51) || ~(((a * b) <= 74000000000.0))) tmp = a * b; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -6.8e+51], N[Not[LessEqual[N[(a * b), $MachinePrecision], 74000000000.0]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -6.8 \cdot 10^{+51} \lor \neg \left(a \cdot b \leq 74000000000\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -6.79999999999999969e51 or 7.4e10 < (*.f64 a b) Initial program 96.8%
Taylor expanded in a around inf 67.8%
if -6.79999999999999969e51 < (*.f64 a b) < 7.4e10Initial program 99.2%
Taylor expanded in z around inf 56.1%
Final simplification61.9%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (+ (* x y) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
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 * b) + ((x * y) + (z * t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
def code(x, y, z, t, a, b): return (a * b) + ((x * y) + (z * t))
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) end
function tmp = code(x, y, z, t, a, b) tmp = (a * b) + ((x * y) + (z * t)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \left(x \cdot y + z \cdot t\right)
\end{array}
Initial program 98.0%
Final simplification98.0%
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
return a * 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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
def code(x, y, z, t, a, b): return a * b
function code(x, y, z, t, a, b) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 98.0%
Taylor expanded in a around inf 38.6%
herbie shell --seed 2024087
(FPCore (x y z t a b)
:name "Linear.V3:$cdot from linear-1.19.1.3, B"
:precision binary64
(+ (+ (* x y) (* z t)) (* a b)))