
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
(FPCore (x y z t a b c i) :precision binary64 (if (<= (+ (+ (* a b) (+ (* x y) (* z t))) (* c i)) INFINITY) (fma c i (+ (+ (* a b) (* x y)) (* z t))) (fma a b (* z t))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((((a * b) + ((x * y) + (z * t))) + (c * i)) <= ((double) INFINITY)) {
tmp = fma(c, i, (((a * b) + (x * y)) + (z * t)));
} else {
tmp = fma(a, b, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) + Float64(c * i)) <= Inf) tmp = fma(c, i, Float64(Float64(Float64(a * b) + Float64(x * y)) + Float64(z * t))); else tmp = fma(a, b, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], Infinity], N[(c * i + N[(N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) + c \cdot i \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(c, i, \left(a \cdot b + x \cdot y\right) + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, z \cdot t\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0Initial program 100.0%
+-commutative100.0%
fma-def100.0%
associate-+l+100.0%
fma-def100.0%
fma-def100.0%
Simplified100.0%
fma-udef100.0%
fma-udef100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
Applied egg-rr100.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 0.0%
Taylor expanded in x around 0 20.0%
*-commutative20.0%
fma-def40.0%
*-commutative40.0%
Applied egg-rr40.0%
Taylor expanded in c around 0 35.2%
fma-def55.2%
Simplified55.2%
Final simplification96.5%
(FPCore (x y z t a b c i) :precision binary64 (fma c i (fma x y (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(c, i, fma(x, y, fma(z, t, (a * b))));
}
function code(x, y, z, t, a, b, c, i) return fma(c, i, fma(x, y, fma(z, t, Float64(a * b)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i + N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)
\end{array}
Initial program 92.2%
+-commutative92.2%
fma-def93.7%
associate-+l+93.7%
fma-def94.9%
fma-def96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (<= (+ (+ (* a b) t_1) (* c i)) INFINITY)
(+ (+ (* a b) (* c i)) t_1)
(fma a b (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((((a * b) + t_1) + (c * i)) <= ((double) INFINITY)) {
tmp = ((a * b) + (c * i)) + t_1;
} else {
tmp = fma(a, b, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (Float64(Float64(Float64(a * b) + t_1) + Float64(c * i)) <= Inf) tmp = Float64(Float64(Float64(a * b) + Float64(c * i)) + t_1); else tmp = fma(a, b, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;\left(a \cdot b + t_1\right) + c \cdot i \leq \infty:\\
\;\;\;\;\left(a \cdot b + c \cdot i\right) + t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, z \cdot t\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0Initial program 100.0%
associate-+l+100.0%
fma-def100.0%
Simplified100.0%
fma-def100.0%
+-commutative100.0%
Applied egg-rr100.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 0.0%
Taylor expanded in x around 0 20.0%
*-commutative20.0%
fma-def40.0%
*-commutative40.0%
Applied egg-rr40.0%
Taylor expanded in c around 0 35.2%
fma-def55.2%
Simplified55.2%
Final simplification96.5%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (<= (+ (+ (* a b) t_1) (* c i)) INFINITY)
(+ (+ (* a b) (* c i)) t_1)
t_1)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((((a * b) + t_1) + (c * i)) <= ((double) INFINITY)) {
tmp = ((a * b) + (c * i)) + t_1;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((((a * b) + t_1) + (c * i)) <= Double.POSITIVE_INFINITY) {
tmp = ((a * b) + (c * i)) + t_1;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) + (z * t) tmp = 0 if (((a * b) + t_1) + (c * i)) <= math.inf: tmp = ((a * b) + (c * i)) + t_1 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (Float64(Float64(Float64(a * b) + t_1) + Float64(c * i)) <= Inf) tmp = Float64(Float64(Float64(a * b) + Float64(c * i)) + t_1); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) + (z * t); tmp = 0.0; if ((((a * b) + t_1) + (c * i)) <= Inf) tmp = ((a * b) + (c * i)) + t_1; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;\left(a \cdot b + t_1\right) + c \cdot i \leq \infty:\\
\;\;\;\;\left(a \cdot b + c \cdot i\right) + t_1\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0Initial program 100.0%
associate-+l+100.0%
fma-def100.0%
Simplified100.0%
fma-def100.0%
+-commutative100.0%
Applied egg-rr100.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 0.0%
Taylor expanded in a around 0 40.0%
Taylor expanded in c around 0 45.6%
Final simplification95.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t)))
(t_2 (+ (* a b) (* c i)))
(t_3 (+ (* a b) (* z t))))
(if (<= (* c i) -3.6e+57)
t_2
(if (<= (* c i) -6.4e-60)
t_1
(if (<= (* c i) -1e-275)
t_3
(if (<= (* c i) 1.06e-194)
t_1
(if (<= (* c i) 2.75e+45) t_3 t_2)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (c * i);
double t_3 = (a * b) + (z * t);
double tmp;
if ((c * i) <= -3.6e+57) {
tmp = t_2;
} else if ((c * i) <= -6.4e-60) {
tmp = t_1;
} else if ((c * i) <= -1e-275) {
tmp = t_3;
} else if ((c * i) <= 1.06e-194) {
tmp = t_1;
} else if ((c * i) <= 2.75e+45) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = (x * y) + (z * t)
t_2 = (a * b) + (c * i)
t_3 = (a * b) + (z * t)
if ((c * i) <= (-3.6d+57)) then
tmp = t_2
else if ((c * i) <= (-6.4d-60)) then
tmp = t_1
else if ((c * i) <= (-1d-275)) then
tmp = t_3
else if ((c * i) <= 1.06d-194) then
tmp = t_1
else if ((c * i) <= 2.75d+45) then
tmp = t_3
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 c, double i) {
double t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (c * i);
double t_3 = (a * b) + (z * t);
double tmp;
if ((c * i) <= -3.6e+57) {
tmp = t_2;
} else if ((c * i) <= -6.4e-60) {
tmp = t_1;
} else if ((c * i) <= -1e-275) {
tmp = t_3;
} else if ((c * i) <= 1.06e-194) {
tmp = t_1;
} else if ((c * i) <= 2.75e+45) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) + (z * t) t_2 = (a * b) + (c * i) t_3 = (a * b) + (z * t) tmp = 0 if (c * i) <= -3.6e+57: tmp = t_2 elif (c * i) <= -6.4e-60: tmp = t_1 elif (c * i) <= -1e-275: tmp = t_3 elif (c * i) <= 1.06e-194: tmp = t_1 elif (c * i) <= 2.75e+45: tmp = t_3 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) t_2 = Float64(Float64(a * b) + Float64(c * i)) t_3 = Float64(Float64(a * b) + Float64(z * t)) tmp = 0.0 if (Float64(c * i) <= -3.6e+57) tmp = t_2; elseif (Float64(c * i) <= -6.4e-60) tmp = t_1; elseif (Float64(c * i) <= -1e-275) tmp = t_3; elseif (Float64(c * i) <= 1.06e-194) tmp = t_1; elseif (Float64(c * i) <= 2.75e+45) tmp = t_3; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) + (z * t); t_2 = (a * b) + (c * i); t_3 = (a * b) + (z * t); tmp = 0.0; if ((c * i) <= -3.6e+57) tmp = t_2; elseif ((c * i) <= -6.4e-60) tmp = t_1; elseif ((c * i) <= -1e-275) tmp = t_3; elseif ((c * i) <= 1.06e-194) tmp = t_1; elseif ((c * i) <= 2.75e+45) tmp = t_3; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -3.6e+57], t$95$2, If[LessEqual[N[(c * i), $MachinePrecision], -6.4e-60], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], -1e-275], t$95$3, If[LessEqual[N[(c * i), $MachinePrecision], 1.06e-194], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 2.75e+45], t$95$3, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + c \cdot i\\
t_3 := a \cdot b + z \cdot t\\
\mathbf{if}\;c \cdot i \leq -3.6 \cdot 10^{+57}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \cdot i \leq -6.4 \cdot 10^{-60}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-275}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;c \cdot i \leq 1.06 \cdot 10^{-194}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq 2.75 \cdot 10^{+45}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 c i) < -3.6000000000000002e57 or 2.75e45 < (*.f64 c i) Initial program 90.2%
Taylor expanded in a around inf 79.5%
if -3.6000000000000002e57 < (*.f64 c i) < -6.4000000000000003e-60 or -9.99999999999999934e-276 < (*.f64 c i) < 1.06000000000000002e-194Initial program 93.0%
Taylor expanded in a around 0 78.4%
Taylor expanded in c around 0 76.7%
if -6.4000000000000003e-60 < (*.f64 c i) < -9.99999999999999934e-276 or 1.06000000000000002e-194 < (*.f64 c i) < 2.75e45Initial program 94.1%
Taylor expanded in x around 0 81.5%
*-commutative81.5%
fma-def83.8%
*-commutative83.8%
Applied egg-rr83.8%
Taylor expanded in c around 0 77.4%
Final simplification78.2%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) (- INFINITY))
(* a b)
(if (or (<= (* a b) -1.8e+54) (not (<= (* a b) 4.7e+57)))
(+ (* c i) (+ (* a b) (* z t)))
(+ (* c i) (+ (* x y) (* z t))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -((double) INFINITY)) {
tmp = a * b;
} else if (((a * b) <= -1.8e+54) || !((a * b) <= 4.7e+57)) {
tmp = (c * i) + ((a * b) + (z * t));
} else {
tmp = (c * i) + ((x * y) + (z * t));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -Double.POSITIVE_INFINITY) {
tmp = a * b;
} else if (((a * b) <= -1.8e+54) || !((a * b) <= 4.7e+57)) {
tmp = (c * i) + ((a * b) + (z * t));
} else {
tmp = (c * i) + ((x * y) + (z * t));
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -math.inf: tmp = a * b elif ((a * b) <= -1.8e+54) or not ((a * b) <= 4.7e+57): tmp = (c * i) + ((a * b) + (z * t)) else: tmp = (c * i) + ((x * y) + (z * t)) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= Float64(-Inf)) tmp = Float64(a * b); elseif ((Float64(a * b) <= -1.8e+54) || !(Float64(a * b) <= 4.7e+57)) tmp = Float64(Float64(c * i) + Float64(Float64(a * b) + Float64(z * t))); else tmp = Float64(Float64(c * i) + Float64(Float64(x * y) + Float64(z * t))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((a * b) <= -Inf) tmp = a * b; elseif (((a * b) <= -1.8e+54) || ~(((a * b) <= 4.7e+57))) tmp = (c * i) + ((a * b) + (z * t)); else tmp = (c * i) + ((x * y) + (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], (-Infinity)], N[(a * b), $MachinePrecision], If[Or[LessEqual[N[(a * b), $MachinePrecision], -1.8e+54], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4.7e+57]], $MachinePrecision]], N[(N[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * i), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -\infty:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1.8 \cdot 10^{+54} \lor \neg \left(a \cdot b \leq 4.7 \cdot 10^{+57}\right):\\
\;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -inf.0Initial program 72.7%
Taylor expanded in x around 0 72.7%
*-commutative72.7%
fma-def77.3%
*-commutative77.3%
Applied egg-rr77.3%
Taylor expanded in b around inf 90.9%
if -inf.0 < (*.f64 a b) < -1.8000000000000001e54 or 4.7000000000000003e57 < (*.f64 a b) Initial program 90.2%
Taylor expanded in x around 0 83.1%
if -1.8000000000000001e54 < (*.f64 a b) < 4.7000000000000003e57Initial program 96.9%
Taylor expanded in a around 0 93.0%
Final simplification88.9%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -3.5e+224)
(* a b)
(if (<= (* a b) 1.8e-46)
(* c i)
(if (<= (* a b) 1.22e+183) (* z t) (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -3.5e+224) {
tmp = a * b;
} else if ((a * b) <= 1.8e-46) {
tmp = c * i;
} else if ((a * b) <= 1.22e+183) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((a * b) <= (-3.5d+224)) then
tmp = a * b
else if ((a * b) <= 1.8d-46) then
tmp = c * i
else if ((a * b) <= 1.22d+183) 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 c, double i) {
double tmp;
if ((a * b) <= -3.5e+224) {
tmp = a * b;
} else if ((a * b) <= 1.8e-46) {
tmp = c * i;
} else if ((a * b) <= 1.22e+183) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -3.5e+224: tmp = a * b elif (a * b) <= 1.8e-46: tmp = c * i elif (a * b) <= 1.22e+183: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -3.5e+224) tmp = Float64(a * b); elseif (Float64(a * b) <= 1.8e-46) tmp = Float64(c * i); elseif (Float64(a * b) <= 1.22e+183) tmp = Float64(z * t); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((a * b) <= -3.5e+224) tmp = a * b; elseif ((a * b) <= 1.8e-46) tmp = c * i; elseif ((a * b) <= 1.22e+183) tmp = z * t; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -3.5e+224], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.8e-46], N[(c * i), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.22e+183], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3.5 \cdot 10^{+224}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 1.8 \cdot 10^{-46}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;a \cdot b \leq 1.22 \cdot 10^{+183}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -3.5e224 or 1.21999999999999991e183 < (*.f64 a b) Initial program 80.7%
Taylor expanded in x around 0 79.7%
*-commutative79.7%
fma-def84.9%
*-commutative84.9%
Applied egg-rr84.9%
Taylor expanded in b around inf 81.3%
if -3.5e224 < (*.f64 a b) < 1.8e-46Initial program 96.9%
Taylor expanded in c around inf 42.7%
if 1.8e-46 < (*.f64 a b) < 1.21999999999999991e183Initial program 97.7%
Taylor expanded in x around 0 80.5%
*-commutative80.5%
fma-def80.5%
*-commutative80.5%
Applied egg-rr80.5%
Taylor expanded in z around inf 46.7%
Final simplification55.2%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -2.6e+84) (not (<= (* c i) 1.2e+45))) (+ (* a b) (* c i)) (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((c * i) <= -2.6e+84) || !((c * i) <= 1.2e+45)) {
tmp = (a * b) + (c * i);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if (((c * i) <= (-2.6d+84)) .or. (.not. ((c * i) <= 1.2d+45))) then
tmp = (a * b) + (c * i)
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 c, double i) {
double tmp;
if (((c * i) <= -2.6e+84) || !((c * i) <= 1.2e+45)) {
tmp = (a * b) + (c * i);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((c * i) <= -2.6e+84) or not ((c * i) <= 1.2e+45): tmp = (a * b) + (c * i) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(c * i) <= -2.6e+84) || !(Float64(c * i) <= 1.2e+45)) tmp = Float64(Float64(a * b) + Float64(c * i)); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((c * i) <= -2.6e+84) || ~(((c * i) <= 1.2e+45))) tmp = (a * b) + (c * i); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -2.6e+84], N[Not[LessEqual[N[(c * i), $MachinePrecision], 1.2e+45]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2.6 \cdot 10^{+84} \lor \neg \left(c \cdot i \leq 1.2 \cdot 10^{+45}\right):\\
\;\;\;\;a \cdot b + c \cdot i\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 c i) < -2.6000000000000001e84 or 1.19999999999999995e45 < (*.f64 c i) Initial program 89.7%
Taylor expanded in a around inf 80.2%
if -2.6000000000000001e84 < (*.f64 c i) < 1.19999999999999995e45Initial program 93.9%
Taylor expanded in x around 0 74.3%
*-commutative74.3%
fma-def77.0%
*-commutative77.0%
Applied egg-rr77.0%
Taylor expanded in c around 0 70.7%
Final simplification74.7%
(FPCore (x y z t a b c i) :precision binary64 (if (<= y -1.3e-50) (+ (* x y) (* c i)) (if (<= y 8.5e+163) (+ (* c i) (+ (* a b) (* z t))) (+ (* x y) (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (y <= -1.3e-50) {
tmp = (x * y) + (c * i);
} else if (y <= 8.5e+163) {
tmp = (c * i) + ((a * b) + (z * t));
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if (y <= (-1.3d-50)) then
tmp = (x * y) + (c * i)
else if (y <= 8.5d+163) then
tmp = (c * i) + ((a * b) + (z * t))
else
tmp = (x * y) + (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 c, double i) {
double tmp;
if (y <= -1.3e-50) {
tmp = (x * y) + (c * i);
} else if (y <= 8.5e+163) {
tmp = (c * i) + ((a * b) + (z * t));
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if y <= -1.3e-50: tmp = (x * y) + (c * i) elif y <= 8.5e+163: tmp = (c * i) + ((a * b) + (z * t)) else: tmp = (x * y) + (z * t) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (y <= -1.3e-50) tmp = Float64(Float64(x * y) + Float64(c * i)); elseif (y <= 8.5e+163) tmp = Float64(Float64(c * i) + Float64(Float64(a * b) + Float64(z * t))); else tmp = Float64(Float64(x * y) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (y <= -1.3e-50) tmp = (x * y) + (c * i); elseif (y <= 8.5e+163) tmp = (c * i) + ((a * b) + (z * t)); else tmp = (x * y) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[y, -1.3e-50], N[(N[(x * y), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.5e+163], N[(N[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-50}:\\
\;\;\;\;x \cdot y + c \cdot i\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+163}:\\
\;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\end{array}
\end{array}
if y < -1.3000000000000001e-50Initial program 93.3%
Taylor expanded in x around inf 65.1%
if -1.3000000000000001e-50 < y < 8.5000000000000003e163Initial program 93.1%
Taylor expanded in x around 0 86.0%
if 8.5000000000000003e163 < y Initial program 79.9%
Taylor expanded in a around 0 82.4%
Taylor expanded in c around 0 65.6%
Final simplification78.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -4e+237) (* a b) (if (<= (* a b) 3.1e+89) (* c i) (* a b))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -4e+237) {
tmp = a * b;
} else if ((a * b) <= 3.1e+89) {
tmp = c * i;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((a * b) <= (-4d+237)) then
tmp = a * b
else if ((a * b) <= 3.1d+89) then
tmp = c * i
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 c, double i) {
double tmp;
if ((a * b) <= -4e+237) {
tmp = a * b;
} else if ((a * b) <= 3.1e+89) {
tmp = c * i;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -4e+237: tmp = a * b elif (a * b) <= 3.1e+89: tmp = c * i else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -4e+237) tmp = Float64(a * b); elseif (Float64(a * b) <= 3.1e+89) tmp = Float64(c * i); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((a * b) <= -4e+237) tmp = a * b; elseif ((a * b) <= 3.1e+89) tmp = c * i; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -4e+237], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.1e+89], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+237}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 3.1 \cdot 10^{+89}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -3.99999999999999976e237 or 3.1e89 < (*.f64 a b) Initial program 82.4%
Taylor expanded in x around 0 80.4%
*-commutative80.4%
fma-def84.9%
*-commutative84.9%
Applied egg-rr84.9%
Taylor expanded in b around inf 73.5%
if -3.99999999999999976e237 < (*.f64 a b) < 3.1e89Initial program 97.5%
Taylor expanded in c around inf 39.7%
Final simplification51.7%
(FPCore (x y z t a b c i) :precision binary64 (if (<= t 3.3e+202) (+ (* a b) (* c i)) (* z t)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (t <= 3.3e+202) {
tmp = (a * b) + (c * i);
} else {
tmp = z * t;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if (t <= 3.3d+202) then
tmp = (a * b) + (c * i)
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 c, double i) {
double tmp;
if (t <= 3.3e+202) {
tmp = (a * b) + (c * i);
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if t <= 3.3e+202: tmp = (a * b) + (c * i) else: tmp = z * t return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (t <= 3.3e+202) tmp = Float64(Float64(a * b) + Float64(c * i)); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (t <= 3.3e+202) tmp = (a * b) + (c * i); else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[t, 3.3e+202], N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.3 \cdot 10^{+202}:\\
\;\;\;\;a \cdot b + c \cdot i\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if t < 3.2999999999999999e202Initial program 93.1%
Taylor expanded in a around inf 60.3%
if 3.2999999999999999e202 < t Initial program 82.6%
Taylor expanded in x around 0 68.0%
*-commutative68.0%
fma-def72.4%
*-commutative72.4%
Applied egg-rr72.4%
Taylor expanded in z around inf 54.0%
Final simplification59.8%
(FPCore (x y z t a b c i) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
def code(x, y, z, t, a, b, c, i): return a * b
function code(x, y, z, t, a, b, c, i) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 92.2%
Taylor expanded in x around 0 77.2%
*-commutative77.2%
fma-def78.8%
*-commutative78.8%
Applied egg-rr78.8%
Taylor expanded in b around inf 32.9%
Final simplification32.9%
herbie shell --seed 2023230
(FPCore (x y z t a b c i)
:name "Linear.V4:$cdot from linear-1.19.1.3, C"
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))