
(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 10 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 (fma z t (fma y x (fma i c (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(z, t, fma(y, x, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(y, x, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)
\end{array}
Initial program 94.1%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6497.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.2
Applied rewrites97.2%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -5e+150)
(* t z)
(if (<= (* z t) -3e-72)
(* i c)
(if (<= (* z t) 1e-61)
(* b a)
(if (<= (* z t) 1.6e+71) (* i c) (* t z))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+150) {
tmp = t * z;
} else if ((z * t) <= -3e-72) {
tmp = i * c;
} else if ((z * t) <= 1e-61) {
tmp = b * a;
} else if ((z * t) <= 1.6e+71) {
tmp = i * c;
} else {
tmp = t * z;
}
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 ((z * t) <= (-5d+150)) then
tmp = t * z
else if ((z * t) <= (-3d-72)) then
tmp = i * c
else if ((z * t) <= 1d-61) then
tmp = b * a
else if ((z * t) <= 1.6d+71) then
tmp = i * c
else
tmp = t * z
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 ((z * t) <= -5e+150) {
tmp = t * z;
} else if ((z * t) <= -3e-72) {
tmp = i * c;
} else if ((z * t) <= 1e-61) {
tmp = b * a;
} else if ((z * t) <= 1.6e+71) {
tmp = i * c;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -5e+150: tmp = t * z elif (z * t) <= -3e-72: tmp = i * c elif (z * t) <= 1e-61: tmp = b * a elif (z * t) <= 1.6e+71: tmp = i * c else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+150) tmp = Float64(t * z); elseif (Float64(z * t) <= -3e-72) tmp = Float64(i * c); elseif (Float64(z * t) <= 1e-61) tmp = Float64(b * a); elseif (Float64(z * t) <= 1.6e+71) tmp = Float64(i * c); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((z * t) <= -5e+150) tmp = t * z; elseif ((z * t) <= -3e-72) tmp = i * c; elseif ((z * t) <= 1e-61) tmp = b * a; elseif ((z * t) <= 1.6e+71) tmp = i * c; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+150], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -3e-72], N[(i * c), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e-61], N[(b * a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1.6e+71], N[(i * c), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+150}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -3 \cdot 10^{-72}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;z \cdot t \leq 10^{-61}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;z \cdot t \leq 1.6 \cdot 10^{+71}:\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -5.00000000000000009e150 or 1.60000000000000012e71 < (*.f64 z t) Initial program 88.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6487.7
Applied rewrites87.7%
Taylor expanded in c around 0
Applied rewrites79.3%
Taylor expanded in z around 0
Applied rewrites17.4%
Taylor expanded in z around inf
lower-*.f6472.1
Applied rewrites72.1%
if -5.00000000000000009e150 < (*.f64 z t) < -3e-72 or 1e-61 < (*.f64 z t) < 1.60000000000000012e71Initial program 96.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6442.4
Applied rewrites42.4%
if -3e-72 < (*.f64 z t) < 1e-61Initial program 96.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in c around 0
Applied rewrites43.1%
Taylor expanded in z around 0
Applied rewrites42.3%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -5e+132)
(* y x)
(if (<= (* x y) -1e-263)
(fma b a (* c i))
(if (<= (* x y) 2e+146) (fma a b (* t z)) (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -5e+132) {
tmp = y * x;
} else if ((x * y) <= -1e-263) {
tmp = fma(b, a, (c * i));
} else if ((x * y) <= 2e+146) {
tmp = fma(a, b, (t * z));
} else {
tmp = y * x;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -5e+132) tmp = Float64(y * x); elseif (Float64(x * y) <= -1e-263) tmp = fma(b, a, Float64(c * i)); elseif (Float64(x * y) <= 2e+146) tmp = fma(a, b, Float64(t * z)); else tmp = Float64(y * x); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+132], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1e-263], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+146], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+132}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-263}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+146}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000001e132 or 1.99999999999999987e146 < (*.f64 x y) Initial program 87.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6430.3
Applied rewrites30.3%
Taylor expanded in c around 0
Applied rewrites22.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6476.5
Applied rewrites76.5%
if -5.0000000000000001e132 < (*.f64 x y) < -1e-263Initial program 94.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6476.7
Applied rewrites76.7%
Taylor expanded in x around 0
Applied rewrites69.2%
if -1e-263 < (*.f64 x y) < 1.99999999999999987e146Initial program 97.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in c around 0
Applied rewrites67.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+70) (not (<= (* z t) 2e+70))) (fma b a (fma i c (* t z))) (fma b a (fma i c (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+70) || !((z * t) <= 2e+70)) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(b, a, fma(i, c, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -2e+70) || !(Float64(z * t) <= 2e+70)) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(b, a, fma(i, c, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+70], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+70]], $MachinePrecision]], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+70} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+70}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000015e70 or 2.00000000000000015e70 < (*.f64 z t) Initial program 88.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6488.1
Applied rewrites88.1%
if -2.00000000000000015e70 < (*.f64 z t) < 2.00000000000000015e70Initial program 97.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.4
Applied rewrites94.4%
Final simplification92.2%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -5e+132) (not (<= (* x y) 4e+230))) (* y x) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -5e+132) || !((x * y) <= 4e+230)) {
tmp = y * x;
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -5e+132) || !(Float64(x * y) <= 4e+230)) tmp = Float64(y * x); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+132], N[Not[LessEqual[N[(x * y), $MachinePrecision], 4e+230]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+132} \lor \neg \left(x \cdot y \leq 4 \cdot 10^{+230}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000001e132 or 4.0000000000000004e230 < (*.f64 x y) Initial program 88.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6426.5
Applied rewrites26.5%
Taylor expanded in c around 0
Applied rewrites20.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6480.7
Applied rewrites80.7%
if -5.0000000000000001e132 < (*.f64 x y) < 4.0000000000000004e230Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6489.6
Applied rewrites89.6%
Final simplification87.6%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -1e+26)
(fma i c (fma t z (* y x)))
(if (<= (* z t) 2e+70)
(fma b a (fma i c (* y x)))
(fma b a (fma i c (* t z))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -1e+26) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else if ((z * t) <= 2e+70) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+26) tmp = fma(i, c, fma(t, z, Float64(y * x))); elseif (Float64(z * t) <= 2e+70) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+26], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+70], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+70}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.00000000000000005e26Initial program 90.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
if -1.00000000000000005e26 < (*.f64 z t) < 2.00000000000000015e70Initial program 96.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
if 2.00000000000000015e70 < (*.f64 z t) Initial program 88.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6486.7
Applied rewrites86.7%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -5e+132) (not (<= (* x y) 2e+146))) (* y x) (fma a b (* t z))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -5e+132) || !((x * y) <= 2e+146)) {
tmp = y * x;
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -5e+132) || !(Float64(x * y) <= 2e+146)) tmp = Float64(y * x); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+132], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+146]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+132} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+146}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000001e132 or 1.99999999999999987e146 < (*.f64 x y) Initial program 87.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6430.3
Applied rewrites30.3%
Taylor expanded in c around 0
Applied rewrites22.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6476.5
Applied rewrites76.5%
if -5.0000000000000001e132 < (*.f64 x y) < 1.99999999999999987e146Initial program 96.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6490.3
Applied rewrites90.3%
Taylor expanded in c around 0
Applied rewrites63.1%
Final simplification66.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -2e+22) (fma i c (* t z)) (if (<= (* z t) 1.6e+71) (fma b a (* c i)) (fma a b (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -2e+22) {
tmp = fma(i, c, (t * z));
} else if ((z * t) <= 1.6e+71) {
tmp = fma(b, a, (c * i));
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -2e+22) tmp = fma(i, c, Float64(t * z)); elseif (Float64(z * t) <= 1.6e+71) tmp = fma(b, a, Float64(c * i)); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+22], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1.6e+71], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{elif}\;z \cdot t \leq 1.6 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -2e22Initial program 91.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.3
Applied rewrites91.3%
Taylor expanded in x around 0
Applied rewrites77.8%
if -2e22 < (*.f64 z t) < 1.60000000000000012e71Initial program 96.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.3
Applied rewrites95.3%
Taylor expanded in x around 0
Applied rewrites66.2%
if 1.60000000000000012e71 < (*.f64 z t) Initial program 88.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6486.4
Applied rewrites86.4%
Taylor expanded in c around 0
Applied rewrites79.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -5e+115) (not (<= (* a b) 1e+95))) (* b a) (* i c)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -5e+115) || !((a * b) <= 1e+95)) {
tmp = b * a;
} else {
tmp = i * c;
}
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) <= (-5d+115)) .or. (.not. ((a * b) <= 1d+95))) then
tmp = b * a
else
tmp = i * c
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) <= -5e+115) || !((a * b) <= 1e+95)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -5e+115) or not ((a * b) <= 1e+95): tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -5e+115) || !(Float64(a * b) <= 1e+95)) tmp = Float64(b * a); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((a * b) <= -5e+115) || ~(((a * b) <= 1e+95))) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+115], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+95]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+115} \lor \neg \left(a \cdot b \leq 10^{+95}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000008e115 or 1.00000000000000002e95 < (*.f64 a b) Initial program 87.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6483.8
Applied rewrites83.8%
Taylor expanded in c around 0
Applied rewrites79.9%
Taylor expanded in z around 0
Applied rewrites68.4%
if -5.00000000000000008e115 < (*.f64 a b) < 1.00000000000000002e95Initial program 97.6%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
Final simplification47.1%
(FPCore (x y z t a b c i) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
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 = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
def code(x, y, z, t, a, b, c, i): return b * a
function code(x, y, z, t, a, b, c, i) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 94.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in c around 0
Applied rewrites52.6%
Taylor expanded in z around 0
Applied rewrites29.6%
herbie shell --seed 2024317
(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)))