
(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 (fma z t (fma y x (fma i c (* a b)))))
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, (a * b))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(y, x, fma(i, c, Float64(a * b)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(y * x + N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, a \cdot b\right)\right)\right)
\end{array}
Initial program 94.9%
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.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Final simplification97.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* t z) -4.5e+90)
(* t z)
(if (<= (* t z) -3.8e+24)
(* x y)
(if (<= (* t z) -4e-319)
(* c i)
(if (<= (* t z) 2e+178) (* 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 ((t * z) <= -4.5e+90) {
tmp = t * z;
} else if ((t * z) <= -3.8e+24) {
tmp = x * y;
} else if ((t * z) <= -4e-319) {
tmp = c * i;
} else if ((t * z) <= 2e+178) {
tmp = a * b;
} 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 ((t * z) <= (-4.5d+90)) then
tmp = t * z
else if ((t * z) <= (-3.8d+24)) then
tmp = x * y
else if ((t * z) <= (-4d-319)) then
tmp = c * i
else if ((t * z) <= 2d+178) then
tmp = a * b
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 ((t * z) <= -4.5e+90) {
tmp = t * z;
} else if ((t * z) <= -3.8e+24) {
tmp = x * y;
} else if ((t * z) <= -4e-319) {
tmp = c * i;
} else if ((t * z) <= 2e+178) {
tmp = a * b;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (t * z) <= -4.5e+90: tmp = t * z elif (t * z) <= -3.8e+24: tmp = x * y elif (t * z) <= -4e-319: tmp = c * i elif (t * z) <= 2e+178: tmp = a * b else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(t * z) <= -4.5e+90) tmp = Float64(t * z); elseif (Float64(t * z) <= -3.8e+24) tmp = Float64(x * y); elseif (Float64(t * z) <= -4e-319) tmp = Float64(c * i); elseif (Float64(t * z) <= 2e+178) tmp = Float64(a * b); 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 ((t * z) <= -4.5e+90) tmp = t * z; elseif ((t * z) <= -3.8e+24) tmp = x * y; elseif ((t * z) <= -4e-319) tmp = c * i; elseif ((t * z) <= 2e+178) tmp = a * b; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(t * z), $MachinePrecision], -4.5e+90], N[(t * z), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], -3.8e+24], N[(x * y), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], -4e-319], N[(c * i), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], 2e+178], N[(a * b), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \cdot z \leq -4.5 \cdot 10^{+90}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t \cdot z \leq -3.8 \cdot 10^{+24}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t \cdot z \leq -4 \cdot 10^{-319}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+178}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -4.5e90 or 2.0000000000000001e178 < (*.f64 z t) Initial program 90.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
if -4.5e90 < (*.f64 z t) < -3.80000000000000015e24Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6444.2
Applied rewrites44.2%
if -3.80000000000000015e24 < (*.f64 z t) < -4.0000049e-319Initial program 95.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6450.1
Applied rewrites50.1%
if -4.0000049e-319 < (*.f64 z t) < 2.0000000000000001e178Initial program 96.7%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6444.8
Applied rewrites44.8%
Final simplification52.1%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -4e+130)
(* a b)
(if (<= (* a b) -2.0)
(* c i)
(if (<= (* a b) 2e-193)
(* x y)
(if (<= (* a b) 5e+48) (* 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+130) {
tmp = a * b;
} else if ((a * b) <= -2.0) {
tmp = c * i;
} else if ((a * b) <= 2e-193) {
tmp = x * y;
} else if ((a * b) <= 5e+48) {
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+130)) then
tmp = a * b
else if ((a * b) <= (-2.0d0)) then
tmp = c * i
else if ((a * b) <= 2d-193) then
tmp = x * y
else if ((a * b) <= 5d+48) 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+130) {
tmp = a * b;
} else if ((a * b) <= -2.0) {
tmp = c * i;
} else if ((a * b) <= 2e-193) {
tmp = x * y;
} else if ((a * b) <= 5e+48) {
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+130: tmp = a * b elif (a * b) <= -2.0: tmp = c * i elif (a * b) <= 2e-193: tmp = x * y elif (a * b) <= 5e+48: 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+130) tmp = Float64(a * b); elseif (Float64(a * b) <= -2.0) tmp = Float64(c * i); elseif (Float64(a * b) <= 2e-193) tmp = Float64(x * y); elseif (Float64(a * b) <= 5e+48) 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+130) tmp = a * b; elseif ((a * b) <= -2.0) tmp = c * i; elseif ((a * b) <= 2e-193) tmp = x * y; elseif ((a * b) <= 5e+48) 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+130], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -2.0], N[(c * i), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e-193], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5e+48], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+130}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -2:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-193}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+48}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -4.0000000000000002e130 or 4.99999999999999973e48 < (*.f64 a b) Initial program 93.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6468.7
Applied rewrites68.7%
if -4.0000000000000002e130 < (*.f64 a b) < -2 or 2.0000000000000001e-193 < (*.f64 a b) < 4.99999999999999973e48Initial program 97.3%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6444.6
Applied rewrites44.6%
if -2 < (*.f64 a b) < 2.0000000000000001e-193Initial program 94.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6440.5
Applied rewrites40.5%
Final simplification51.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* t z))))
(if (or (<= t_1 -1e+166) (not (<= t_1 2e+178)))
(fma z t (* x y))
(fma i c (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (t * z);
double tmp;
if ((t_1 <= -1e+166) || !(t_1 <= 2e+178)) {
tmp = fma(z, t, (x * y));
} else {
tmp = fma(i, c, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(t * z)) tmp = 0.0 if ((t_1 <= -1e+166) || !(t_1 <= 2e+178)) tmp = fma(z, t, Float64(x * y)); else tmp = fma(i, c, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+166], N[Not[LessEqual[t$95$1, 2e+178]], $MachinePrecision]], N[(z * t + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + t \cdot z\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+166} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+178}\right):\\
\;\;\;\;\mathsf{fma}\left(z, t, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999994e165 or 2.0000000000000001e178 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 88.6%
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.f6494.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6494.3
Applied rewrites94.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6483.7
Applied rewrites83.7%
if -9.9999999999999994e165 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2.0000000000000001e178Initial program 99.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6477.8
Applied rewrites77.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.4
Applied rewrites78.4%
Final simplification80.6%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma z t (* a b))))
(if (<= (* a b) -1e+117)
t_1
(if (<= (* a b) -5e-158)
(fma i c (* x y))
(if (<= (* a b) 4e+18) (fma i c (* t z)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(z, t, (a * b));
double tmp;
if ((a * b) <= -1e+117) {
tmp = t_1;
} else if ((a * b) <= -5e-158) {
tmp = fma(i, c, (x * y));
} else if ((a * b) <= 4e+18) {
tmp = fma(i, c, (t * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(z, t, Float64(a * b)) tmp = 0.0 if (Float64(a * b) <= -1e+117) tmp = t_1; elseif (Float64(a * b) <= -5e-158) tmp = fma(i, c, Float64(x * y)); elseif (Float64(a * b) <= 4e+18) tmp = fma(i, c, Float64(t * z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1e+117], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], -5e-158], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4e+18], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, t, a \cdot b\right)\\
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-158}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -1.00000000000000005e117 or 4e18 < (*.f64 a b) Initial program 93.9%
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.f6495.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.9
Applied rewrites95.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6481.3
Applied rewrites81.3%
if -1.00000000000000005e117 < (*.f64 a b) < -4.99999999999999972e-158Initial program 94.8%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6447.9
Applied rewrites47.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6447.9
Applied rewrites47.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
if -4.99999999999999972e-158 < (*.f64 a b) < 4e18Initial program 96.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.8
Applied rewrites70.8%
Final simplification74.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* a b))))
(if (<= (* a b) -0.05)
t_1
(if (<= (* a b) -5e-158)
(fma i c (* x y))
(if (<= (* a b) 5e+48) (fma i c (* t z)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, (a * b));
double tmp;
if ((a * b) <= -0.05) {
tmp = t_1;
} else if ((a * b) <= -5e-158) {
tmp = fma(i, c, (x * y));
} else if ((a * b) <= 5e+48) {
tmp = fma(i, c, (t * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(a * b)) tmp = 0.0 if (Float64(a * b) <= -0.05) tmp = t_1; elseif (Float64(a * b) <= -5e-158) tmp = fma(i, c, Float64(x * y)); elseif (Float64(a * b) <= 5e+48) tmp = fma(i, c, Float64(t * z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -0.05], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], -5e-158], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5e+48], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{if}\;a \cdot b \leq -0.05:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-158}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -0.050000000000000003 or 4.99999999999999973e48 < (*.f64 a b) Initial program 94.1%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6473.7
Applied rewrites73.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.5
Applied rewrites74.5%
if -0.050000000000000003 < (*.f64 a b) < -4.99999999999999972e-158Initial program 93.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6437.9
Applied rewrites37.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6437.9
Applied rewrites37.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6473.5
Applied rewrites73.5%
if -4.99999999999999972e-158 < (*.f64 a b) < 4.99999999999999973e48Initial program 96.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6469.4
Applied rewrites69.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.4
Applied rewrites70.4%
Final simplification72.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma y x (* t z))))
(if (or (<= (* a b) -4e+130) (not (<= (* a b) 4e+18)))
(fma b a t_1)
(fma i c t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(y, x, (t * z));
double tmp;
if (((a * b) <= -4e+130) || !((a * b) <= 4e+18)) {
tmp = fma(b, a, t_1);
} else {
tmp = fma(i, c, t_1);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(y, x, Float64(t * z)) tmp = 0.0 if ((Float64(a * b) <= -4e+130) || !(Float64(a * b) <= 4e+18)) tmp = fma(b, a, t_1); else tmp = fma(i, c, t_1); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(a * b), $MachinePrecision], -4e+130], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4e+18]], $MachinePrecision]], N[(b * a + t$95$1), $MachinePrecision], N[(i * c + t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, x, t \cdot z\right)\\
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+130} \lor \neg \left(a \cdot b \leq 4 \cdot 10^{+18}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t\_1\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -4.0000000000000002e130 or 4e18 < (*.f64 a b) Initial program 93.8%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.2
Applied rewrites91.2%
if -4.0000000000000002e130 < (*.f64 a b) < 4e18Initial program 95.6%
Taylor expanded in b around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.2
Applied rewrites90.2%
Final simplification90.6%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+57) (fma i c (* x y)) (if (<= (* c i) 1e+93) (fma b a (fma y x (* t z))) (fma i c (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+57) {
tmp = fma(i, c, (x * y));
} else if ((c * i) <= 1e+93) {
tmp = fma(b, a, fma(y, x, (t * z)));
} else {
tmp = fma(i, c, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+57) tmp = fma(i, c, Float64(x * y)); elseif (Float64(c * i) <= 1e+93) tmp = fma(b, a, fma(y, x, Float64(t * z))); else tmp = fma(i, c, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+57], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+93], N[(b * a + N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{elif}\;c \cdot i \leq 10^{+93}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(y, x, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -1.00000000000000005e57Initial program 91.8%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6467.8
Applied rewrites67.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if -1.00000000000000005e57 < (*.f64 c i) < 1.00000000000000004e93Initial program 98.6%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.9
Applied rewrites94.9%
if 1.00000000000000004e93 < (*.f64 c i) Initial program 87.7%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6481.4
Applied rewrites81.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6483.1
Applied rewrites83.1%
Final simplification87.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* t z) -5e+171) (not (<= (* t z) 2e+178))) (fma i c (* t z)) (fma i c (* a b))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((t * z) <= -5e+171) || !((t * z) <= 2e+178)) {
tmp = fma(i, c, (t * z));
} else {
tmp = fma(i, c, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(t * z) <= -5e+171) || !(Float64(t * z) <= 2e+178)) tmp = fma(i, c, Float64(t * z)); else tmp = fma(i, c, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(t * z), $MachinePrecision], -5e+171], N[Not[LessEqual[N[(t * z), $MachinePrecision], 2e+178]], $MachinePrecision]], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \cdot z \leq -5 \cdot 10^{+171} \lor \neg \left(t \cdot z \leq 2 \cdot 10^{+178}\right):\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000004e171 or 2.0000000000000001e178 < (*.f64 z t) Initial program 89.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6479.8
Applied rewrites79.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6483.3
Applied rewrites83.3%
if -5.0000000000000004e171 < (*.f64 z t) < 2.0000000000000001e178Initial program 96.4%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6465.2
Applied rewrites65.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6465.7
Applied rewrites65.7%
Final simplification69.7%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -1e+192) (not (<= (* x y) 4e+164))) (* x y) (fma i c (* a b))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -1e+192) || !((x * y) <= 4e+164)) {
tmp = x * y;
} else {
tmp = fma(i, c, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -1e+192) || !(Float64(x * y) <= 4e+164)) tmp = Float64(x * y); else tmp = fma(i, c, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1e+192], N[Not[LessEqual[N[(x * y), $MachinePrecision], 4e+164]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+192} \lor \neg \left(x \cdot y \leq 4 \cdot 10^{+164}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000004e192 or 4e164 < (*.f64 x y) Initial program 83.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.1
Applied rewrites79.1%
if -1.00000000000000004e192 < (*.f64 x y) < 4e164Initial program 98.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6464.8
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6465.4
Applied rewrites65.4%
Final simplification68.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -4e+130) (not (<= (* a b) 5e+48))) (* a b) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -4e+130) || !((a * b) <= 5e+48)) {
tmp = a * b;
} else {
tmp = c * i;
}
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+130)) .or. (.not. ((a * b) <= 5d+48))) then
tmp = a * b
else
tmp = c * i
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+130) || !((a * b) <= 5e+48)) {
tmp = a * b;
} else {
tmp = c * i;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -4e+130) or not ((a * b) <= 5e+48): tmp = a * b else: tmp = c * i return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -4e+130) || !(Float64(a * b) <= 5e+48)) tmp = Float64(a * b); else tmp = Float64(c * i); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((a * b) <= -4e+130) || ~(((a * b) <= 5e+48))) tmp = a * b; else tmp = c * i; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -4e+130], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+48]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(c * i), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+130} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+48}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;c \cdot i\\
\end{array}
\end{array}
if (*.f64 a b) < -4.0000000000000002e130 or 4.99999999999999973e48 < (*.f64 a b) Initial program 93.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6468.7
Applied rewrites68.7%
if -4.0000000000000002e130 < (*.f64 a b) < 4.99999999999999973e48Initial program 95.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6436.7
Applied rewrites36.7%
Final simplification48.2%
(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 94.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6430.2
Applied rewrites30.2%
Final simplification30.2%
herbie shell --seed 2024271
(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)))