
(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 (if (<= (+ (+ (* x y) (* z t)) (* a b)) INFINITY) (+ (* a b) (fma x y (* z t))) (fma a b (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x * y) + (z * t)) + (a * b)) <= ((double) INFINITY)) {
tmp = (a * b) + fma(x, y, (z * t));
} else {
tmp = fma(a, b, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) <= Inf) tmp = Float64(Float64(a * b) + fma(x, y, Float64(z * t))); else tmp = fma(a, b, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot y + z \cdot t\right) + a \cdot b \leq \infty:\\
\;\;\;\;a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
fma-def100.0%
Simplified100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in z around 0 40.0%
fma-def70.0%
Simplified70.0%
Final simplification98.8%
(FPCore (x y z t a b) :precision binary64 (fma x y (fma a b (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, fma(a, b, (z * t)));
}
function code(x, y, z, t, a, b) return fma(x, y, fma(a, b, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right)
\end{array}
Initial program 96.1%
associate-+l+96.1%
fma-def96.9%
+-commutative96.9%
fma-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (* x y) (* z t)) (* a b)))) (if (<= t_1 INFINITY) t_1 (fma a b (* x y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(a, b, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(a, b, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot y + z \cdot t\right) + a \cdot b\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\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 z around 0 40.0%
fma-def70.0%
Simplified70.0%
Final simplification98.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -1.42e+116)
(* a b)
(if (<= (* a b) -8e-16)
(* x y)
(if (<= (* a b) -1.5e-122)
(* z t)
(if (<= (* a b) 4.4e-270)
(* x y)
(if (<= (* a b) 3.9e-89)
(* z t)
(if (<= (* a b) 5.2e+35)
(* x y)
(if (<= (* a b) 5.4e+110)
(* z t)
(if (<= (* a b) 4.8e+120) (* x y) (* a b))))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.42e+116) {
tmp = a * b;
} else if ((a * b) <= -8e-16) {
tmp = x * y;
} else if ((a * b) <= -1.5e-122) {
tmp = z * t;
} else if ((a * b) <= 4.4e-270) {
tmp = x * y;
} else if ((a * b) <= 3.9e-89) {
tmp = z * t;
} else if ((a * b) <= 5.2e+35) {
tmp = x * y;
} else if ((a * b) <= 5.4e+110) {
tmp = z * t;
} else if ((a * b) <= 4.8e+120) {
tmp = x * y;
} 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) <= (-1.42d+116)) then
tmp = a * b
else if ((a * b) <= (-8d-16)) then
tmp = x * y
else if ((a * b) <= (-1.5d-122)) then
tmp = z * t
else if ((a * b) <= 4.4d-270) then
tmp = x * y
else if ((a * b) <= 3.9d-89) then
tmp = z * t
else if ((a * b) <= 5.2d+35) then
tmp = x * y
else if ((a * b) <= 5.4d+110) then
tmp = z * t
else if ((a * b) <= 4.8d+120) 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 tmp;
if ((a * b) <= -1.42e+116) {
tmp = a * b;
} else if ((a * b) <= -8e-16) {
tmp = x * y;
} else if ((a * b) <= -1.5e-122) {
tmp = z * t;
} else if ((a * b) <= 4.4e-270) {
tmp = x * y;
} else if ((a * b) <= 3.9e-89) {
tmp = z * t;
} else if ((a * b) <= 5.2e+35) {
tmp = x * y;
} else if ((a * b) <= 5.4e+110) {
tmp = z * t;
} else if ((a * b) <= 4.8e+120) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1.42e+116: tmp = a * b elif (a * b) <= -8e-16: tmp = x * y elif (a * b) <= -1.5e-122: tmp = z * t elif (a * b) <= 4.4e-270: tmp = x * y elif (a * b) <= 3.9e-89: tmp = z * t elif (a * b) <= 5.2e+35: tmp = x * y elif (a * b) <= 5.4e+110: tmp = z * t elif (a * b) <= 4.8e+120: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1.42e+116) tmp = Float64(a * b); elseif (Float64(a * b) <= -8e-16) tmp = Float64(x * y); elseif (Float64(a * b) <= -1.5e-122) tmp = Float64(z * t); elseif (Float64(a * b) <= 4.4e-270) tmp = Float64(x * y); elseif (Float64(a * b) <= 3.9e-89) tmp = Float64(z * t); elseif (Float64(a * b) <= 5.2e+35) tmp = Float64(x * y); elseif (Float64(a * b) <= 5.4e+110) tmp = Float64(z * t); elseif (Float64(a * b) <= 4.8e+120) tmp = Float64(x * y); 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) <= -1.42e+116) tmp = a * b; elseif ((a * b) <= -8e-16) tmp = x * y; elseif ((a * b) <= -1.5e-122) tmp = z * t; elseif ((a * b) <= 4.4e-270) tmp = x * y; elseif ((a * b) <= 3.9e-89) tmp = z * t; elseif ((a * b) <= 5.2e+35) tmp = x * y; elseif ((a * b) <= 5.4e+110) tmp = z * t; elseif ((a * b) <= 4.8e+120) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1.42e+116], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -8e-16], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.5e-122], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.4e-270], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.9e-89], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5.2e+35], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5.4e+110], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.8e+120], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.42 \cdot 10^{+116}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -8 \cdot 10^{-16}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq -1.5 \cdot 10^{-122}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 4.4 \cdot 10^{-270}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 3.9 \cdot 10^{-89}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 5.2 \cdot 10^{+35}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 5.4 \cdot 10^{+110}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 4.8 \cdot 10^{+120}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -1.4199999999999999e116 or 4.80000000000000002e120 < (*.f64 a b) Initial program 93.2%
Taylor expanded in a around inf 79.2%
if -1.4199999999999999e116 < (*.f64 a b) < -7.9999999999999998e-16 or -1.50000000000000002e-122 < (*.f64 a b) < 4.3999999999999997e-270 or 3.89999999999999978e-89 < (*.f64 a b) < 5.20000000000000013e35 or 5.40000000000000019e110 < (*.f64 a b) < 4.80000000000000002e120Initial program 97.9%
Taylor expanded in x around inf 59.6%
if -7.9999999999999998e-16 < (*.f64 a b) < -1.50000000000000002e-122 or 4.3999999999999997e-270 < (*.f64 a b) < 3.89999999999999978e-89 or 5.20000000000000013e35 < (*.f64 a b) < 5.40000000000000019e110Initial program 98.2%
Taylor expanded in z around inf 63.0%
Final simplification68.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (* x y) (* z t)) (* a b)))) (if (<= t_1 INFINITY) t_1 (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = ((x * y) + (z * t)) + (a * b) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = x * y return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = ((x * y) + (z * t)) + (a * b); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot y + z \cdot t\right) + a \cdot b\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\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 inf 50.4%
Final simplification98.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -2.8e+148) (not (<= (* x y) 2.4e+216))) (* 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) <= -2.8e+148) || !((x * y) <= 2.4e+216)) {
tmp = 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) <= (-2.8d+148)) .or. (.not. ((x * y) <= 2.4d+216))) then
tmp = 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) <= -2.8e+148) || !((x * y) <= 2.4e+216)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -2.8e+148) or not ((x * y) <= 2.4e+216): tmp = 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) <= -2.8e+148) || !(Float64(x * y) <= 2.4e+216)) tmp = 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) <= -2.8e+148) || ~(((x * y) <= 2.4e+216))) tmp = 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], -2.8e+148], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.4e+216]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.8 \cdot 10^{+148} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+216}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -2.7999999999999998e148 or 2.3999999999999999e216 < (*.f64 x y) Initial program 89.6%
Taylor expanded in x around inf 81.6%
if -2.7999999999999998e148 < (*.f64 x y) < 2.3999999999999999e216Initial program 98.4%
Taylor expanded in x around 0 82.9%
Final simplification82.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -2.35e+64) (not (<= (* x y) 1.25e+57))) (+ (* x y) (* a b)) (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -2.35e+64) || !((x * y) <= 1.25e+57)) {
tmp = (x * y) + (a * b);
} 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) <= (-2.35d+64)) .or. (.not. ((x * y) <= 1.25d+57))) then
tmp = (x * y) + (a * b)
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) <= -2.35e+64) || !((x * y) <= 1.25e+57)) {
tmp = (x * y) + (a * b);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -2.35e+64) or not ((x * y) <= 1.25e+57): tmp = (x * y) + (a * b) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -2.35e+64) || !(Float64(x * y) <= 1.25e+57)) tmp = Float64(Float64(x * y) + Float64(a * b)); 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) <= -2.35e+64) || ~(((x * y) <= 1.25e+57))) tmp = (x * y) + (a * b); 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], -2.35e+64], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.25e+57]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.35 \cdot 10^{+64} \lor \neg \left(x \cdot y \leq 1.25 \cdot 10^{+57}\right):\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -2.35000000000000015e64 or 1.24999999999999993e57 < (*.f64 x y) Initial program 94.0%
Taylor expanded in z around 0 82.7%
if -2.35000000000000015e64 < (*.f64 x y) < 1.24999999999999993e57Initial program 97.8%
Taylor expanded in x around 0 88.8%
Final simplification86.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -2.3e-20) (+ (* x y) (* a b)) (if (<= (* a b) 1.9e+58) (+ (* x y) (* z t)) (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -2.3e-20) {
tmp = (x * y) + (a * b);
} else if ((a * b) <= 1.9e+58) {
tmp = (x * y) + (z * t);
} 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 ((a * b) <= (-2.3d-20)) then
tmp = (x * y) + (a * b)
else if ((a * b) <= 1.9d+58) then
tmp = (x * y) + (z * t)
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 ((a * b) <= -2.3e-20) {
tmp = (x * y) + (a * b);
} else if ((a * b) <= 1.9e+58) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -2.3e-20: tmp = (x * y) + (a * b) elif (a * b) <= 1.9e+58: tmp = (x * y) + (z * t) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -2.3e-20) tmp = Float64(Float64(x * y) + Float64(a * b)); elseif (Float64(a * b) <= 1.9e+58) tmp = Float64(Float64(x * y) + Float64(z * t)); 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 ((a * b) <= -2.3e-20) tmp = (x * y) + (a * b); elseif ((a * b) <= 1.9e+58) tmp = (x * y) + (z * t); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -2.3e-20], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.9e+58], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2.3 \cdot 10^{-20}:\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 1.9 \cdot 10^{+58}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -2.2999999999999999e-20Initial program 96.0%
Taylor expanded in z around 0 85.9%
if -2.2999999999999999e-20 < (*.f64 a b) < 1.8999999999999999e58Initial program 98.3%
Taylor expanded in a around 0 93.5%
if 1.8999999999999999e58 < (*.f64 a b) Initial program 91.7%
Taylor expanded in x around 0 87.0%
Final simplification89.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -9.8e+109) (not (<= (* a b) 3e+101))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -9.8e+109) || !((a * b) <= 3e+101)) {
tmp = a * b;
} else {
tmp = 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 (((a * b) <= (-9.8d+109)) .or. (.not. ((a * b) <= 3d+101))) then
tmp = a * b
else
tmp = 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 (((a * b) <= -9.8e+109) || !((a * b) <= 3e+101)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -9.8e+109) or not ((a * b) <= 3e+101): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -9.8e+109) || !(Float64(a * b) <= 3e+101)) tmp = Float64(a * b); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((a * b) <= -9.8e+109) || ~(((a * b) <= 3e+101))) tmp = a * b; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -9.8e+109], N[Not[LessEqual[N[(a * b), $MachinePrecision], 3e+101]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -9.8 \cdot 10^{+109} \lor \neg \left(a \cdot b \leq 3 \cdot 10^{+101}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -9.8000000000000007e109 or 2.99999999999999993e101 < (*.f64 a b) Initial program 93.5%
Taylor expanded in a around inf 76.6%
if -9.8000000000000007e109 < (*.f64 a b) < 2.99999999999999993e101Initial program 97.9%
Taylor expanded in z around inf 48.7%
Final simplification60.5%
(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 96.1%
Taylor expanded in a around inf 39.4%
Final simplification39.4%
herbie shell --seed 2024041
(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)))