
(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 10 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.3%
associate-+l+97.3%
fma-def99.2%
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.3%
+-commutative97.3%
fma-def98.0%
fma-def99.2%
Simplified99.2%
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.3%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -4.5e+132)
(* x y)
(if (<= (* x y) -2.15e-99)
(* z t)
(if (<= (* x y) -3.3e-195)
(* a b)
(if (<= (* x y) 2e-313)
(* z t)
(if (<= (* x y) 9500000000000.0) (* a b) (* x y)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -4.5e+132) {
tmp = x * y;
} else if ((x * y) <= -2.15e-99) {
tmp = z * t;
} else if ((x * y) <= -3.3e-195) {
tmp = a * b;
} else if ((x * y) <= 2e-313) {
tmp = z * t;
} else if ((x * y) <= 9500000000000.0) {
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) <= (-4.5d+132)) then
tmp = x * y
else if ((x * y) <= (-2.15d-99)) then
tmp = z * t
else if ((x * y) <= (-3.3d-195)) then
tmp = a * b
else if ((x * y) <= 2d-313) then
tmp = z * t
else if ((x * y) <= 9500000000000.0d0) 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) <= -4.5e+132) {
tmp = x * y;
} else if ((x * y) <= -2.15e-99) {
tmp = z * t;
} else if ((x * y) <= -3.3e-195) {
tmp = a * b;
} else if ((x * y) <= 2e-313) {
tmp = z * t;
} else if ((x * y) <= 9500000000000.0) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -4.5e+132: tmp = x * y elif (x * y) <= -2.15e-99: tmp = z * t elif (x * y) <= -3.3e-195: tmp = a * b elif (x * y) <= 2e-313: tmp = z * t elif (x * y) <= 9500000000000.0: tmp = a * b else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -4.5e+132) tmp = Float64(x * y); elseif (Float64(x * y) <= -2.15e-99) tmp = Float64(z * t); elseif (Float64(x * y) <= -3.3e-195) tmp = Float64(a * b); elseif (Float64(x * y) <= 2e-313) tmp = Float64(z * t); elseif (Float64(x * y) <= 9500000000000.0) 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) <= -4.5e+132) tmp = x * y; elseif ((x * y) <= -2.15e-99) tmp = z * t; elseif ((x * y) <= -3.3e-195) tmp = a * b; elseif ((x * y) <= 2e-313) tmp = z * t; elseif ((x * y) <= 9500000000000.0) 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], -4.5e+132], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2.15e-99], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -3.3e-195], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e-313], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 9500000000000.0], N[(a * b), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4.5 \cdot 10^{+132}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -2.15 \cdot 10^{-99}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq -3.3 \cdot 10^{-195}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-313}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 9500000000000:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -4.49999999999999972e132 or 9.5e12 < (*.f64 x y) Initial program 93.2%
Taylor expanded in x around inf 70.4%
if -4.49999999999999972e132 < (*.f64 x y) < -2.1499999999999999e-99 or -3.3e-195 < (*.f64 x y) < 1.99999999998e-313Initial program 100.0%
Taylor expanded in z around inf 56.7%
if -2.1499999999999999e-99 < (*.f64 x y) < -3.3e-195 or 1.99999999998e-313 < (*.f64 x y) < 9.5e12Initial program 100.0%
Taylor expanded in a around inf 61.9%
Final simplification63.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (+ (* a b) (* z t)))))
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 = (a * b) + (z * t);
}
return tmp;
}
public static 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.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + ((x * y) + (z * t)) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = (a * b) + (z * t) 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 = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + ((x * y) + (z * t)); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = (a * b) + (z * t); end tmp_2 = 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[(N[(a * b), $MachinePrecision] + N[(z * t), $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}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\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 71.4%
Final simplification99.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (<= (* x y) -42000000.0)
t_1
(if (<= (* x y) 1.85e-22)
(+ (* a b) (* z t))
(if (<= (* x y) 6.8e+56) (+ (* 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) <= -42000000.0) {
tmp = t_1;
} else if ((x * y) <= 1.85e-22) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 6.8e+56) {
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) <= (-42000000.0d0)) then
tmp = t_1
else if ((x * y) <= 1.85d-22) then
tmp = (a * b) + (z * t)
else if ((x * y) <= 6.8d+56) 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) <= -42000000.0) {
tmp = t_1;
} else if ((x * y) <= 1.85e-22) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 6.8e+56) {
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) <= -42000000.0: tmp = t_1 elif (x * y) <= 1.85e-22: tmp = (a * b) + (z * t) elif (x * y) <= 6.8e+56: 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) <= -42000000.0) tmp = t_1; elseif (Float64(x * y) <= 1.85e-22) tmp = Float64(Float64(a * b) + Float64(z * t)); elseif (Float64(x * y) <= 6.8e+56) 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) <= -42000000.0) tmp = t_1; elseif ((x * y) <= 1.85e-22) tmp = (a * b) + (z * t); elseif ((x * y) <= 6.8e+56) 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], -42000000.0], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1.85e-22], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 6.8e+56], 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 -42000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot y \leq 1.85 \cdot 10^{-22}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 6.8 \cdot 10^{+56}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (*.f64 x y) < -4.2e7 or 6.80000000000000002e56 < (*.f64 x y) Initial program 93.9%
Taylor expanded in a around 0 87.4%
if -4.2e7 < (*.f64 x y) < 1.85e-22Initial program 100.0%
Taylor expanded in x around 0 91.6%
if 1.85e-22 < (*.f64 x y) < 6.80000000000000002e56Initial program 100.0%
Taylor expanded in z around 0 94.4%
Final simplification89.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -9.5e+46) (not (<= (* x y) 9.6e-23))) (+ (* 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) <= -9.5e+46) || !((x * y) <= 9.6e-23)) {
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) <= (-9.5d+46)) .or. (.not. ((x * y) <= 9.6d-23))) 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) <= -9.5e+46) || !((x * y) <= 9.6e-23)) {
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) <= -9.5e+46) or not ((x * y) <= 9.6e-23): 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) <= -9.5e+46) || !(Float64(x * y) <= 9.6e-23)) 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) <= -9.5e+46) || ~(((x * y) <= 9.6e-23))) 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], -9.5e+46], N[Not[LessEqual[N[(x * y), $MachinePrecision], 9.6e-23]], $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 -9.5 \cdot 10^{+46} \lor \neg \left(x \cdot y \leq 9.6 \cdot 10^{-23}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -9.5000000000000008e46 or 9.59999999999999986e-23 < (*.f64 x y) Initial program 94.5%
Taylor expanded in z around 0 78.4%
if -9.5000000000000008e46 < (*.f64 x y) < 9.59999999999999986e-23Initial program 100.0%
Taylor expanded in x around 0 91.2%
Final simplification84.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -2.8e+153) (* x y) (if (<= (* x y) 9e+119) (+ (* 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) <= -2.8e+153) {
tmp = x * y;
} else if ((x * y) <= 9e+119) {
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) <= (-2.8d+153)) then
tmp = x * y
else if ((x * y) <= 9d+119) 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) <= -2.8e+153) {
tmp = x * y;
} else if ((x * y) <= 9e+119) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -2.8e+153: tmp = x * y elif (x * y) <= 9e+119: 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) <= -2.8e+153) tmp = Float64(x * y); elseif (Float64(x * y) <= 9e+119) 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) <= -2.8e+153) tmp = x * y; elseif ((x * y) <= 9e+119) 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], -2.8e+153], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 9e+119], 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 -2.8 \cdot 10^{+153}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 9 \cdot 10^{+119}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -2.79999999999999985e153 or 9.00000000000000039e119 < (*.f64 x y) Initial program 90.8%
Taylor expanded in x around inf 79.4%
if -2.79999999999999985e153 < (*.f64 x y) < 9.00000000000000039e119Initial program 100.0%
Taylor expanded in x around 0 82.4%
Final simplification81.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -3.1e+73) (* a b) (if (<= (* a b) 7.2e+23) (* z t) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -3.1e+73) {
tmp = a * b;
} else if ((a * b) <= 7.2e+23) {
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) <= (-3.1d+73)) then
tmp = a * b
else if ((a * b) <= 7.2d+23) 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) <= -3.1e+73) {
tmp = a * b;
} else if ((a * b) <= 7.2e+23) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -3.1e+73: tmp = a * b elif (a * b) <= 7.2e+23: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -3.1e+73) tmp = Float64(a * b); elseif (Float64(a * b) <= 7.2e+23) 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) <= -3.1e+73) tmp = a * b; elseif ((a * b) <= 7.2e+23) 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], -3.1e+73], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 7.2e+23], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3.1 \cdot 10^{+73}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 7.2 \cdot 10^{+23}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -3.1e73 or 7.1999999999999997e23 < (*.f64 a b) Initial program 94.8%
Taylor expanded in a around inf 69.0%
if -3.1e73 < (*.f64 a b) < 7.1999999999999997e23Initial program 98.7%
Taylor expanded in z around inf 48.5%
Final simplification56.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.3%
Taylor expanded in a around inf 34.5%
Final simplification34.5%
herbie shell --seed 2023275
(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)))