
(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 x y (fma a b (* c i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(z, t, fma(x, y, fma(a, b, (c * i))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(x, y, fma(a, b, Float64(c * i)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(x * y + N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, c \cdot i\right)\right)\right)
\end{array}
Initial program 96.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
lower-fma.f64N/A
lift-*.f64N/A
lower-fma.f6497.3
Applied rewrites97.3%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -4.2e+95)
(* a b)
(if (<= (* a b) -2.3e-298)
(* x y)
(if (<= (* a b) 9.5e-35)
(* z t)
(if (<= (* a b) 1.35e+135) (* x y) (* 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) <= -4.2e+95) {
tmp = a * b;
} else if ((a * b) <= -2.3e-298) {
tmp = x * y;
} else if ((a * b) <= 9.5e-35) {
tmp = z * t;
} else if ((a * b) <= 1.35e+135) {
tmp = x * y;
} 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) <= (-4.2d+95)) then
tmp = a * b
else if ((a * b) <= (-2.3d-298)) then
tmp = x * y
else if ((a * b) <= 9.5d-35) then
tmp = z * t
else if ((a * b) <= 1.35d+135) then
tmp = x * y
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) <= -4.2e+95) {
tmp = a * b;
} else if ((a * b) <= -2.3e-298) {
tmp = x * y;
} else if ((a * b) <= 9.5e-35) {
tmp = z * t;
} else if ((a * b) <= 1.35e+135) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -4.2e+95: tmp = a * b elif (a * b) <= -2.3e-298: tmp = x * y elif (a * b) <= 9.5e-35: tmp = z * t elif (a * b) <= 1.35e+135: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -4.2e+95) tmp = Float64(a * b); elseif (Float64(a * b) <= -2.3e-298) tmp = Float64(x * y); elseif (Float64(a * b) <= 9.5e-35) tmp = Float64(z * t); elseif (Float64(a * b) <= 1.35e+135) tmp = Float64(x * y); 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) <= -4.2e+95) tmp = a * b; elseif ((a * b) <= -2.3e-298) tmp = x * y; elseif ((a * b) <= 9.5e-35) tmp = z * t; elseif ((a * b) <= 1.35e+135) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -4.2e+95], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -2.3e-298], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 9.5e-35], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.35e+135], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4.2 \cdot 10^{+95}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -2.3 \cdot 10^{-298}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{-35}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 1.35 \cdot 10^{+135}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -4.2e95 or 1.34999999999999992e135 < (*.f64 a b) Initial program 92.4%
Taylor expanded in a around inf
lower-*.f6476.7
Applied rewrites76.7%
if -4.2e95 < (*.f64 a b) < -2.3000000000000001e-298 or 9.5000000000000003e-35 < (*.f64 a b) < 1.34999999999999992e135Initial program 96.3%
Taylor expanded in x around inf
lower-*.f6442.2
Applied rewrites42.2%
if -2.3000000000000001e-298 < (*.f64 a b) < 9.5000000000000003e-35Initial program 100.0%
Taylor expanded in z around inf
lower-*.f6447.3
Applied rewrites47.3%
Final simplification54.2%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (fma z t (* x y))) (t_2 (+ (* x y) (* z t)))) (if (<= t_2 -1e+158) t_1 (if (<= t_2 1e+208) (fma i c (* a b)) 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, (x * y));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -1e+158) {
tmp = t_1;
} else if (t_2 <= 1e+208) {
tmp = fma(i, c, (a * b));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(z, t, Float64(x * y)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -1e+158) tmp = t_1; elseif (t_2 <= 1e+208) tmp = fma(i, c, Float64(a * b)); 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[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+158], t$95$1, If[LessEqual[t$95$2, 1e+208], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, t, x \cdot y\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+158}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+208}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -9.99999999999999953e157 or 9.9999999999999998e207 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 92.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
lower-fma.f64N/A
lift-*.f64N/A
lower-fma.f6495.3
Applied rewrites95.3%
Taylor expanded in x around inf
lower-*.f6482.0
Applied rewrites82.0%
if -9.99999999999999953e157 < (+.f64 (*.f64 x y) (*.f64 z t)) < 9.9999999999999998e207Initial program 99.2%
Taylor expanded in a around inf
lower-*.f6471.1
Applied rewrites71.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6471.8
Applied rewrites71.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma x y (* a b))))
(if (<= (* x y) -2e-14)
t_1
(if (<= (* x y) 1e-219)
(fma z t (* a b))
(if (<= (* x y) 2e+115) (fma z t (* c i)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(x, y, (a * b));
double tmp;
if ((x * y) <= -2e-14) {
tmp = t_1;
} else if ((x * y) <= 1e-219) {
tmp = fma(z, t, (a * b));
} else if ((x * y) <= 2e+115) {
tmp = fma(z, t, (c * i));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(x, y, Float64(a * b)) tmp = 0.0 if (Float64(x * y) <= -2e-14) tmp = t_1; elseif (Float64(x * y) <= 1e-219) tmp = fma(z, t, Float64(a * b)); elseif (Float64(x * y) <= 2e+115) tmp = fma(z, t, Float64(c * i)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(x * y + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2e-14], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e-219], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+115], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, y, a \cdot b\right)\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 10^{-219}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -2e-14 or 2e115 < (*.f64 x y) Initial program 93.0%
Taylor expanded in c around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6483.4
Applied rewrites83.4%
Taylor expanded in a around inf
Applied rewrites75.5%
if -2e-14 < (*.f64 x y) < 1e-219Initial program 98.8%
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
lower-fma.f64N/A
lift-*.f64N/A
lower-fma.f6498.9
Applied rewrites98.9%
Taylor expanded in a around inf
lower-*.f6478.0
Applied rewrites78.0%
if 1e-219 < (*.f64 x y) < 2e115Initial program 98.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
lower-fma.f64N/A
lift-*.f64N/A
lower-fma.f6498.1
Applied rewrites98.1%
Taylor expanded in c around inf
lower-*.f6476.6
Applied rewrites76.6%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -5e+187) (fma z t (* c i)) (if (<= (* c i) 2e+285) (fma x y (fma a b (* z t))) (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) <= -5e+187) {
tmp = fma(z, t, (c * i));
} else if ((c * i) <= 2e+285) {
tmp = fma(x, y, fma(a, b, (z * t)));
} 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) <= -5e+187) tmp = fma(z, t, Float64(c * i)); elseif (Float64(c * i) <= 2e+285) tmp = fma(x, y, fma(a, b, Float64(z * t))); 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], -5e+187], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+285], N[(x * y + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+187}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+285}:\\
\;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -5.0000000000000001e187Initial program 83.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
lower-fma.f64N/A
lift-*.f64N/A
lower-fma.f6488.0
Applied rewrites88.0%
Taylor expanded in c around inf
lower-*.f6480.0
Applied rewrites80.0%
if -5.0000000000000001e187 < (*.f64 c i) < 2e285Initial program 98.6%
Taylor expanded in c around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6490.1
Applied rewrites90.1%
if 2e285 < (*.f64 c i) Initial program 82.4%
Taylor expanded in a around inf
lower-*.f6494.1
Applied rewrites94.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6494.1
Applied rewrites94.1%
Final simplification89.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma x y (* a b))))
(if (<= (* x y) -2e-14)
t_1
(if (<= (* x y) 5e+171) (fma z t (* a b)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(x, y, (a * b));
double tmp;
if ((x * y) <= -2e-14) {
tmp = t_1;
} else if ((x * y) <= 5e+171) {
tmp = fma(z, t, (a * b));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(x, y, Float64(a * b)) tmp = 0.0 if (Float64(x * y) <= -2e-14) tmp = t_1; elseif (Float64(x * y) <= 5e+171) tmp = fma(z, t, Float64(a * b)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(x * y + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2e-14], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 5e+171], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, y, a \cdot b\right)\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+171}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -2e-14 or 5.0000000000000004e171 < (*.f64 x y) Initial program 92.5%
Taylor expanded in c around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6482.1
Applied rewrites82.1%
Taylor expanded in a around inf
Applied rewrites76.4%
if -2e-14 < (*.f64 x y) < 5.0000000000000004e171Initial program 98.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
lower-fma.f64N/A
lift-*.f64N/A
lower-fma.f6498.7
Applied rewrites98.7%
Taylor expanded in a around inf
lower-*.f6470.4
Applied rewrites70.4%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -2e+153) (* z t) (if (<= (* z t) 2e+239) (fma x y (* 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 ((z * t) <= -2e+153) {
tmp = z * t;
} else if ((z * t) <= 2e+239) {
tmp = fma(x, y, (a * b));
} else {
tmp = z * t;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -2e+153) tmp = Float64(z * t); elseif (Float64(z * t) <= 2e+239) tmp = fma(x, y, Float64(a * b)); else tmp = Float64(z * t); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+153], N[(z * t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+239], N[(x * y + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+153}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+239}:\\
\;\;\;\;\mathsf{fma}\left(x, y, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 z t) < -2e153 or 1.99999999999999998e239 < (*.f64 z t) Initial program 98.3%
Taylor expanded in z around inf
lower-*.f6480.7
Applied rewrites80.7%
if -2e153 < (*.f64 z t) < 1.99999999999999998e239Initial program 95.4%
Taylor expanded in c around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in a around inf
Applied rewrites66.4%
Final simplification69.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -2.8e+61) (* a b) (if (<= (* a b) 3.6e+95) (* 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) <= -2.8e+61) {
tmp = a * b;
} else if ((a * b) <= 3.6e+95) {
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) <= (-2.8d+61)) then
tmp = a * b
else if ((a * b) <= 3.6d+95) 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) <= -2.8e+61) {
tmp = a * b;
} else if ((a * b) <= 3.6e+95) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -2.8e+61: tmp = a * b elif (a * b) <= 3.6e+95: 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) <= -2.8e+61) tmp = Float64(a * b); elseif (Float64(a * b) <= 3.6e+95) 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) <= -2.8e+61) tmp = a * b; elseif ((a * b) <= 3.6e+95) 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], -2.8e+61], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.6e+95], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2.8 \cdot 10^{+61}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 3.6 \cdot 10^{+95}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -2.8000000000000001e61 or 3.59999999999999978e95 < (*.f64 a b) Initial program 92.8%
Taylor expanded in a around inf
lower-*.f6466.4
Applied rewrites66.4%
if -2.8000000000000001e61 < (*.f64 a b) < 3.59999999999999978e95Initial program 98.1%
Taylor expanded in z around inf
lower-*.f6435.1
Applied rewrites35.1%
Final simplification47.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -1.45e+52) (* a b) (if (<= (* a b) 1.75e+29) (* 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) <= -1.45e+52) {
tmp = a * b;
} else if ((a * b) <= 1.75e+29) {
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) <= (-1.45d+52)) then
tmp = a * b
else if ((a * b) <= 1.75d+29) 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) <= -1.45e+52) {
tmp = a * b;
} else if ((a * b) <= 1.75e+29) {
tmp = c * i;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -1.45e+52: tmp = a * b elif (a * b) <= 1.75e+29: 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) <= -1.45e+52) tmp = Float64(a * b); elseif (Float64(a * b) <= 1.75e+29) 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) <= -1.45e+52) tmp = a * b; elseif ((a * b) <= 1.75e+29) 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], -1.45e+52], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.75e+29], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.45 \cdot 10^{+52}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 1.75 \cdot 10^{+29}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -1.45e52 or 1.74999999999999989e29 < (*.f64 a b) Initial program 93.7%
Taylor expanded in a around inf
lower-*.f6460.6
Applied rewrites60.6%
if -1.45e52 < (*.f64 a b) < 1.74999999999999989e29Initial program 97.9%
Taylor expanded in c around inf
lower-*.f6431.2
Applied rewrites31.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 96.1%
Taylor expanded in a around inf
lower-*.f6429.1
Applied rewrites29.1%
herbie shell --seed 2024221
(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)))