
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (fma x y (fma z t (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, fma(z, t, (a * b)));
}
function code(x, y, z, t, a, b) return fma(x, y, fma(z, t, Float64(a * b))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)
\end{array}
Initial program 97.2%
associate-+l+97.2%
fma-def98.4%
fma-def99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (fma a b (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, b, fma(x, y, (z * t)));
}
function code(x, y, z, t, a, b) return fma(a, b, fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)
\end{array}
Initial program 97.2%
+-commutative97.2%
fma-def97.6%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(z, t, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(z, t, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around 0 42.9%
fma-def42.9%
Simplified42.9%
fma-udef42.9%
+-commutative42.9%
*-commutative42.9%
Applied egg-rr42.9%
fma-def71.4%
Applied egg-rr71.4%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + fma(x, y, (z * t));
}
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)
\end{array}
Initial program 97.2%
fma-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t a b) :precision binary64 (+ (fma z t (* a b)) (* x y)))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, t, (a * b)) + (x * y);
}
function code(x, y, z, t, a, b) return Float64(fma(z, t, Float64(a * b)) + Float64(x * y)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, a \cdot b\right) + x \cdot y
\end{array}
Initial program 97.2%
+-commutative97.2%
fma-def97.6%
fma-def98.4%
Simplified98.4%
fma-udef98.0%
+-commutative98.0%
fma-def97.2%
associate-+l+97.2%
fma-udef98.0%
+-commutative98.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -8.5e+98)
(* x y)
(if (<= (* x y) -1.15e-49)
(* a b)
(if (<= (* x y) -3.3e-113)
(* z t)
(if (<= (* x y) 7.8e+83) (* a b) (* x y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -8.5e+98) {
tmp = x * y;
} else if ((x * y) <= -1.15e-49) {
tmp = a * b;
} else if ((x * y) <= -3.3e-113) {
tmp = z * t;
} else if ((x * y) <= 7.8e+83) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((x * y) <= (-8.5d+98)) then
tmp = x * y
else if ((x * y) <= (-1.15d-49)) then
tmp = a * b
else if ((x * y) <= (-3.3d-113)) then
tmp = z * t
else if ((x * y) <= 7.8d+83) then
tmp = a * b
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -8.5e+98) {
tmp = x * y;
} else if ((x * y) <= -1.15e-49) {
tmp = a * b;
} else if ((x * y) <= -3.3e-113) {
tmp = z * t;
} else if ((x * y) <= 7.8e+83) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -8.5e+98: tmp = x * y elif (x * y) <= -1.15e-49: tmp = a * b elif (x * y) <= -3.3e-113: tmp = z * t elif (x * y) <= 7.8e+83: tmp = a * b else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -8.5e+98) tmp = Float64(x * y); elseif (Float64(x * y) <= -1.15e-49) tmp = Float64(a * b); elseif (Float64(x * y) <= -3.3e-113) tmp = Float64(z * t); elseif (Float64(x * y) <= 7.8e+83) tmp = Float64(a * b); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -8.5e+98) tmp = x * y; elseif ((x * y) <= -1.15e-49) tmp = a * b; elseif ((x * y) <= -3.3e-113) tmp = z * t; elseif ((x * y) <= 7.8e+83) tmp = a * b; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -8.5e+98], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1.15e-49], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -3.3e-113], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 7.8e+83], N[(a * b), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -8.5 \cdot 10^{+98}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -1.15 \cdot 10^{-49}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq -3.3 \cdot 10^{-113}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 7.8 \cdot 10^{+83}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -8.4999999999999996e98 or 7.8000000000000003e83 < (*.f64 x y) Initial program 94.6%
Taylor expanded in x around inf 74.4%
if -8.4999999999999996e98 < (*.f64 x y) < -1.15e-49 or -3.3000000000000002e-113 < (*.f64 x y) < 7.8000000000000003e83Initial program 98.6%
Taylor expanded in a around inf 61.3%
if -1.15e-49 < (*.f64 x y) < -3.3000000000000002e-113Initial program 100.0%
Taylor expanded in z around inf 63.6%
Final simplification66.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (<= (* x y) -3.8e+103)
t_1
(if (<= (* x y) 2.15e-47)
(+ (* a b) (* z t))
(if (<= (* x y) 1.3e+86) (+ (* a b) (* x y)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((x * y) <= -3.8e+103) {
tmp = t_1;
} else if ((x * y) <= 2.15e-47) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 1.3e+86) {
tmp = (a * b) + (x * y);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (x * y) + (z * t)
if ((x * y) <= (-3.8d+103)) then
tmp = t_1
else if ((x * y) <= 2.15d-47) then
tmp = (a * b) + (z * t)
else if ((x * y) <= 1.3d+86) then
tmp = (a * b) + (x * y)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((x * y) <= -3.8e+103) {
tmp = t_1;
} else if ((x * y) <= 2.15e-47) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 1.3e+86) {
tmp = (a * b) + (x * y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x * y) + (z * t) tmp = 0 if (x * y) <= -3.8e+103: tmp = t_1 elif (x * y) <= 2.15e-47: tmp = (a * b) + (z * t) elif (x * y) <= 1.3e+86: tmp = (a * b) + (x * y) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (Float64(x * y) <= -3.8e+103) tmp = t_1; elseif (Float64(x * y) <= 2.15e-47) tmp = Float64(Float64(a * b) + Float64(z * t)); elseif (Float64(x * y) <= 1.3e+86) tmp = Float64(Float64(a * b) + Float64(x * y)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x * y) + (z * t); tmp = 0.0; if ((x * y) <= -3.8e+103) tmp = t_1; elseif ((x * y) <= 2.15e-47) tmp = (a * b) + (z * t); elseif ((x * y) <= 1.3e+86) tmp = (a * b) + (x * y); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -3.8e+103], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 2.15e-47], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.3e+86], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;x \cdot y \leq -3.8 \cdot 10^{+103}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot y \leq 2.15 \cdot 10^{-47}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 1.3 \cdot 10^{+86}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (*.f64 x y) < -3.7999999999999997e103 or 1.2999999999999999e86 < (*.f64 x y) Initial program 94.5%
Taylor expanded in a around 0 88.7%
if -3.7999999999999997e103 < (*.f64 x y) < 2.1499999999999999e-47Initial program 99.2%
Taylor expanded in x around 0 93.5%
if 2.1499999999999999e-47 < (*.f64 x y) < 1.2999999999999999e86Initial program 96.2%
Taylor expanded in z around 0 85.2%
Final simplification90.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -5.3e+138) (not (<= (* x y) 2.1e-47))) (+ (* a b) (* x y)) (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -5.3e+138) || !((x * y) <= 2.1e-47)) {
tmp = (a * b) + (x * y);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((x * y) <= (-5.3d+138)) .or. (.not. ((x * y) <= 2.1d-47))) then
tmp = (a * b) + (x * y)
else
tmp = (a * b) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -5.3e+138) || !((x * y) <= 2.1e-47)) {
tmp = (a * b) + (x * y);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -5.3e+138) or not ((x * y) <= 2.1e-47): tmp = (a * b) + (x * y) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -5.3e+138) || !(Float64(x * y) <= 2.1e-47)) tmp = Float64(Float64(a * b) + Float64(x * y)); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((x * y) <= -5.3e+138) || ~(((x * y) <= 2.1e-47))) tmp = (a * b) + (x * y); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5.3e+138], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.1e-47]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5.3 \cdot 10^{+138} \lor \neg \left(x \cdot y \leq 2.1 \cdot 10^{-47}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -5.29999999999999984e138 or 2.1000000000000001e-47 < (*.f64 x y) Initial program 94.7%
Taylor expanded in z around 0 83.6%
if -5.29999999999999984e138 < (*.f64 x y) < 2.1000000000000001e-47Initial program 99.2%
Taylor expanded in x around 0 92.4%
Final simplification88.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -1.6e+198) (* x y) (if (<= (* x y) 1.9e+93) (+ (* a b) (* z t)) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -1.6e+198) {
tmp = x * y;
} else if ((x * y) <= 1.9e+93) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((x * y) <= (-1.6d+198)) then
tmp = x * y
else if ((x * y) <= 1.9d+93) then
tmp = (a * b) + (z * t)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -1.6e+198) {
tmp = x * y;
} else if ((x * y) <= 1.9e+93) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -1.6e+198: tmp = x * y elif (x * y) <= 1.9e+93: tmp = (a * b) + (z * t) else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -1.6e+198) tmp = Float64(x * y); elseif (Float64(x * y) <= 1.9e+93) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -1.6e+198) tmp = x * y; elseif ((x * y) <= 1.9e+93) tmp = (a * b) + (z * t); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -1.6e+198], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.9e+93], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.6 \cdot 10^{+198}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.9 \cdot 10^{+93}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1.5999999999999999e198 or 1.8999999999999999e93 < (*.f64 x y) Initial program 93.3%
Taylor expanded in x around inf 82.3%
if -1.5999999999999999e198 < (*.f64 x y) < 1.8999999999999999e93Initial program 98.8%
Taylor expanded in x around 0 87.1%
Final simplification85.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -8e+51) (* a b) (if (<= (* a b) 9e-24) (* z t) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -8e+51) {
tmp = a * b;
} else if ((a * b) <= 9e-24) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * b) <= (-8d+51)) then
tmp = a * b
else if ((a * b) <= 9d-24) then
tmp = z * t
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -8e+51) {
tmp = a * b;
} else if ((a * b) <= 9e-24) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -8e+51: tmp = a * b elif (a * b) <= 9e-24: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -8e+51) tmp = Float64(a * b); elseif (Float64(a * b) <= 9e-24) tmp = Float64(z * t); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -8e+51) tmp = a * b; elseif ((a * b) <= 9e-24) tmp = z * t; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -8e+51], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 9e-24], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -8 \cdot 10^{+51}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 9 \cdot 10^{-24}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -8e51 or 8.9999999999999995e-24 < (*.f64 a b) Initial program 96.0%
Taylor expanded in a around inf 71.6%
if -8e51 < (*.f64 a b) < 8.9999999999999995e-24Initial program 98.4%
Taylor expanded in z around inf 45.1%
Final simplification58.0%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (+ (* x y) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a * b) + ((x * y) + (z * t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
def code(x, y, z, t, a, b): return (a * b) + ((x * y) + (z * t))
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) end
function tmp = code(x, y, z, t, a, b) tmp = (a * b) + ((x * y) + (z * t)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \left(x \cdot y + z \cdot t\right)
\end{array}
Initial program 97.2%
Final simplification97.2%
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
def code(x, y, z, t, a, b): return a * b
function code(x, y, z, t, a, b) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 97.2%
Taylor expanded in a around inf 41.0%
Final simplification41.0%
herbie shell --seed 2023271
(FPCore (x y z t a b)
:name "Linear.V3:$cdot from linear-1.19.1.3, B"
:precision binary64
(+ (+ (* x y) (* z t)) (* a b)))