
(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 11 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 x y (fma a b (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, fma(a, b, (z * t)));
}
function code(x, y, z, t, a, b) return fma(x, y, fma(a, b, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right)
\end{array}
Initial program 97.2%
associate-+l+97.2%
fma-def98.8%
+-commutative98.8%
fma-def99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (fma a b (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(a, b, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(a, b, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, z \cdot t\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around 0 57.1%
fma-def71.4%
Simplified71.4%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + fma(x, y, (z * t));
}
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)
\end{array}
Initial program 97.2%
fma-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t a b) :precision binary64 (fma x y (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, ((a * b) + (z * t)));
}
function code(x, y, z, t, a, b) return fma(x, y, Float64(Float64(a * b) + Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, a \cdot b + z \cdot t\right)
\end{array}
Initial program 97.2%
associate-+l+97.2%
fma-def98.8%
+-commutative98.8%
fma-def99.2%
Simplified99.2%
fma-udef98.8%
+-commutative98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -6e+66)
(* a b)
(if (<= (* a b) -4.8e-155)
(* z t)
(if (<= (* a b) -1e-284)
(* x y)
(if (<= (* a b) 1.25e-282)
(* z t)
(if (<= (* a b) 8.8e-163)
(* x y)
(if (<= (* a b) 1.2e-109)
(* z t)
(if (<= (* a b) 6e-13)
(* x y)
(if (<= (* a b) 2050000.0) (* z t) (* a b))))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -6e+66) {
tmp = a * b;
} else if ((a * b) <= -4.8e-155) {
tmp = z * t;
} else if ((a * b) <= -1e-284) {
tmp = x * y;
} else if ((a * b) <= 1.25e-282) {
tmp = z * t;
} else if ((a * b) <= 8.8e-163) {
tmp = x * y;
} else if ((a * b) <= 1.2e-109) {
tmp = z * t;
} else if ((a * b) <= 6e-13) {
tmp = x * y;
} else if ((a * b) <= 2050000.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) <= (-6d+66)) then
tmp = a * b
else if ((a * b) <= (-4.8d-155)) then
tmp = z * t
else if ((a * b) <= (-1d-284)) then
tmp = x * y
else if ((a * b) <= 1.25d-282) then
tmp = z * t
else if ((a * b) <= 8.8d-163) then
tmp = x * y
else if ((a * b) <= 1.2d-109) then
tmp = z * t
else if ((a * b) <= 6d-13) then
tmp = x * y
else if ((a * b) <= 2050000.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) <= -6e+66) {
tmp = a * b;
} else if ((a * b) <= -4.8e-155) {
tmp = z * t;
} else if ((a * b) <= -1e-284) {
tmp = x * y;
} else if ((a * b) <= 1.25e-282) {
tmp = z * t;
} else if ((a * b) <= 8.8e-163) {
tmp = x * y;
} else if ((a * b) <= 1.2e-109) {
tmp = z * t;
} else if ((a * b) <= 6e-13) {
tmp = x * y;
} else if ((a * b) <= 2050000.0) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -6e+66: tmp = a * b elif (a * b) <= -4.8e-155: tmp = z * t elif (a * b) <= -1e-284: tmp = x * y elif (a * b) <= 1.25e-282: tmp = z * t elif (a * b) <= 8.8e-163: tmp = x * y elif (a * b) <= 1.2e-109: tmp = z * t elif (a * b) <= 6e-13: tmp = x * y elif (a * b) <= 2050000.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) <= -6e+66) tmp = Float64(a * b); elseif (Float64(a * b) <= -4.8e-155) tmp = Float64(z * t); elseif (Float64(a * b) <= -1e-284) tmp = Float64(x * y); elseif (Float64(a * b) <= 1.25e-282) tmp = Float64(z * t); elseif (Float64(a * b) <= 8.8e-163) tmp = Float64(x * y); elseif (Float64(a * b) <= 1.2e-109) tmp = Float64(z * t); elseif (Float64(a * b) <= 6e-13) tmp = Float64(x * y); elseif (Float64(a * b) <= 2050000.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) <= -6e+66) tmp = a * b; elseif ((a * b) <= -4.8e-155) tmp = z * t; elseif ((a * b) <= -1e-284) tmp = x * y; elseif ((a * b) <= 1.25e-282) tmp = z * t; elseif ((a * b) <= 8.8e-163) tmp = x * y; elseif ((a * b) <= 1.2e-109) tmp = z * t; elseif ((a * b) <= 6e-13) tmp = x * y; elseif ((a * b) <= 2050000.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], -6e+66], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -4.8e-155], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1e-284], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.25e-282], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 8.8e-163], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.2e-109], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 6e-13], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2050000.0], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -6 \cdot 10^{+66}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -4.8 \cdot 10^{-155}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-284}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 1.25 \cdot 10^{-282}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 8.8 \cdot 10^{-163}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 1.2 \cdot 10^{-109}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 6 \cdot 10^{-13}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 2050000:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -6.00000000000000005e66 or 2.05e6 < (*.f64 a b) Initial program 95.9%
Taylor expanded in a around inf 71.8%
if -6.00000000000000005e66 < (*.f64 a b) < -4.8e-155 or -1.00000000000000004e-284 < (*.f64 a b) < 1.25e-282 or 8.80000000000000044e-163 < (*.f64 a b) < 1.19999999999999994e-109 or 5.99999999999999968e-13 < (*.f64 a b) < 2.05e6Initial program 97.4%
Taylor expanded in z around inf 68.5%
if -4.8e-155 < (*.f64 a b) < -1.00000000000000004e-284 or 1.25e-282 < (*.f64 a b) < 8.80000000000000044e-163 or 1.19999999999999994e-109 < (*.f64 a b) < 5.99999999999999968e-13Initial program 99.9%
Taylor expanded in x around inf 62.1%
Final simplification68.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + ((x * y) + (z * t)) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + ((x * y) + (z * t)); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around 0 57.1%
Final simplification98.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -1.55e+131) (not (<= (* x y) 7.5e+160))) (* 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) <= -1.55e+131) || !((x * y) <= 7.5e+160)) {
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) <= (-1.55d+131)) .or. (.not. ((x * y) <= 7.5d+160))) 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) <= -1.55e+131) || !((x * y) <= 7.5e+160)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -1.55e+131) or not ((x * y) <= 7.5e+160): 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) <= -1.55e+131) || !(Float64(x * y) <= 7.5e+160)) 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) <= -1.55e+131) || ~(((x * y) <= 7.5e+160))) 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], -1.55e+131], N[Not[LessEqual[N[(x * y), $MachinePrecision], 7.5e+160]], $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 -1.55 \cdot 10^{+131} \lor \neg \left(x \cdot y \leq 7.5 \cdot 10^{+160}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.55000000000000008e131 or 7.50000000000000028e160 < (*.f64 x y) Initial program 92.3%
Taylor expanded in x around inf 74.6%
if -1.55000000000000008e131 < (*.f64 x y) < 7.50000000000000028e160Initial program 98.9%
Taylor expanded in x around 0 86.5%
Final simplification83.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -8.5e+130) (not (<= (* x y) 28000000000.0))) (+ (* 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 (((x * y) <= -8.5e+130) || !((x * y) <= 28000000000.0)) {
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 (((x * y) <= (-8.5d+130)) .or. (.not. ((x * y) <= 28000000000.0d0))) 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 (((x * y) <= -8.5e+130) || !((x * y) <= 28000000000.0)) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -8.5e+130) or not ((x * y) <= 28000000000.0): 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(x * y) <= -8.5e+130) || !(Float64(x * y) <= 28000000000.0)) 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 (((x * y) <= -8.5e+130) || ~(((x * y) <= 28000000000.0))) tmp = (x * y) + (z * t); 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], -8.5e+130], N[Not[LessEqual[N[(x * y), $MachinePrecision], 28000000000.0]], $MachinePrecision]], 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}\;x \cdot y \leq -8.5 \cdot 10^{+130} \lor \neg \left(x \cdot y \leq 28000000000\right):\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -8.49999999999999965e130 or 2.8e10 < (*.f64 x y) Initial program 94.6%
Taylor expanded in a around 0 83.5%
if -8.49999999999999965e130 < (*.f64 x y) < 2.8e10Initial program 98.7%
Taylor expanded in x around 0 90.6%
Final simplification88.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -1.25e+64) (not (<= (* a b) 2.4e-111))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -1.25e+64) || !((a * b) <= 2.4e-111)) {
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) <= (-1.25d+64)) .or. (.not. ((a * b) <= 2.4d-111))) 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) <= -1.25e+64) || !((a * b) <= 2.4e-111)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -1.25e+64) or not ((a * b) <= 2.4e-111): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -1.25e+64) || !(Float64(a * b) <= 2.4e-111)) 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) <= -1.25e+64) || ~(((a * b) <= 2.4e-111))) 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], -1.25e+64], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2.4e-111]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.25 \cdot 10^{+64} \lor \neg \left(a \cdot b \leq 2.4 \cdot 10^{-111}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.25e64 or 2.4000000000000001e-111 < (*.f64 a b) Initial program 96.4%
Taylor expanded in a around inf 66.6%
if -1.25e64 < (*.f64 a b) < 2.4000000000000001e-111Initial program 98.2%
Taylor expanded in z around inf 54.9%
Final simplification61.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.3e+31) (not (<= z 1.46e-140))) (+ (* a b) (* z t)) (+ (* a b) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.3e+31) || !(z <= 1.46e-140)) {
tmp = (a * b) + (z * t);
} else {
tmp = (a * b) + (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 ((z <= (-1.3d+31)) .or. (.not. (z <= 1.46d-140))) then
tmp = (a * b) + (z * t)
else
tmp = (a * b) + (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 ((z <= -1.3e+31) || !(z <= 1.46e-140)) {
tmp = (a * b) + (z * t);
} else {
tmp = (a * b) + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -1.3e+31) or not (z <= 1.46e-140): tmp = (a * b) + (z * t) else: tmp = (a * b) + (x * y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.3e+31) || !(z <= 1.46e-140)) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(Float64(a * b) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z <= -1.3e+31) || ~((z <= 1.46e-140))) tmp = (a * b) + (z * t); else tmp = (a * b) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.3e+31], N[Not[LessEqual[z, 1.46e-140]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+31} \lor \neg \left(z \leq 1.46 \cdot 10^{-140}\right):\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\end{array}
\end{array}
if z < -1.3e31 or 1.45999999999999991e-140 < z Initial program 96.1%
Taylor expanded in x around 0 78.6%
if -1.3e31 < z < 1.45999999999999991e-140Initial program 99.0%
Taylor expanded in z around 0 88.4%
Final simplification82.4%
(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 97.2%
Taylor expanded in a around inf 39.6%
Final simplification39.6%
herbie shell --seed 2024024
(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)))