
(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 8 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 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (* y (+ x (* a (/ b y)))))))
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 = y * (x + (a * (b / y)));
}
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 = y * (x + (a * (b / y)));
}
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 = y * (x + (a * (b / y))) 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(y * Float64(x + Float64(a * Float64(b / y)))); 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 = y * (x + (a * (b / y))); 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[(y * N[(x + N[(a * N[(b / y), $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;y \cdot \left(x + a \cdot \frac{b}{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 44.4%
Taylor expanded in y around inf 77.8%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(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 96.5%
associate-+l+96.5%
fma-define97.6%
fma-define98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -3.3e+290)
(and (not (<= (* x y) -3e+53))
(or (<= (* x y) -39000000.0) (not (<= (* x y) 7e+207)))))
(* 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) <= -3.3e+290) || (!((x * y) <= -3e+53) && (((x * y) <= -39000000.0) || !((x * y) <= 7e+207)))) {
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) <= (-3.3d+290)) .or. (.not. ((x * y) <= (-3d+53))) .and. ((x * y) <= (-39000000.0d0)) .or. (.not. ((x * y) <= 7d+207))) 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) <= -3.3e+290) || (!((x * y) <= -3e+53) && (((x * y) <= -39000000.0) || !((x * y) <= 7e+207)))) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -3.3e+290) or (not ((x * y) <= -3e+53) and (((x * y) <= -39000000.0) or not ((x * y) <= 7e+207))): 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) <= -3.3e+290) || (!(Float64(x * y) <= -3e+53) && ((Float64(x * y) <= -39000000.0) || !(Float64(x * y) <= 7e+207)))) 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) <= -3.3e+290) || (~(((x * y) <= -3e+53)) && (((x * y) <= -39000000.0) || ~(((x * y) <= 7e+207))))) 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], -3.3e+290], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -3e+53]], $MachinePrecision], Or[LessEqual[N[(x * y), $MachinePrecision], -39000000.0], N[Not[LessEqual[N[(x * y), $MachinePrecision], 7e+207]], $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 -3.3 \cdot 10^{+290} \lor \neg \left(x \cdot y \leq -3 \cdot 10^{+53}\right) \land \left(x \cdot y \leq -39000000 \lor \neg \left(x \cdot y \leq 7 \cdot 10^{+207}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -3.2999999999999999e290 or -2.99999999999999998e53 < (*.f64 x y) < -3.9e7 or 7.00000000000000056e207 < (*.f64 x y) Initial program 88.7%
Taylor expanded in x around inf 88.9%
if -3.2999999999999999e290 < (*.f64 x y) < -2.99999999999999998e53 or -3.9e7 < (*.f64 x y) < 7.00000000000000056e207Initial program 98.9%
Taylor expanded in x around 0 83.0%
Final simplification84.4%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -8.2e-13)
(and (not (<= (* x y) 5.8e+61))
(or (<= (* x y) 2.4e+104) (not (<= (* x y) 4e+170)))))
(+ (* 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) <= -8.2e-13) || (!((x * y) <= 5.8e+61) && (((x * y) <= 2.4e+104) || !((x * y) <= 4e+170)))) {
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) <= (-8.2d-13)) .or. (.not. ((x * y) <= 5.8d+61)) .and. ((x * y) <= 2.4d+104) .or. (.not. ((x * y) <= 4d+170))) 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) <= -8.2e-13) || (!((x * y) <= 5.8e+61) && (((x * y) <= 2.4e+104) || !((x * y) <= 4e+170)))) {
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) <= -8.2e-13) or (not ((x * y) <= 5.8e+61) and (((x * y) <= 2.4e+104) or not ((x * y) <= 4e+170))): 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) <= -8.2e-13) || (!(Float64(x * y) <= 5.8e+61) && ((Float64(x * y) <= 2.4e+104) || !(Float64(x * y) <= 4e+170)))) 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) <= -8.2e-13) || (~(((x * y) <= 5.8e+61)) && (((x * y) <= 2.4e+104) || ~(((x * y) <= 4e+170))))) 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], -8.2e-13], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], 5.8e+61]], $MachinePrecision], Or[LessEqual[N[(x * y), $MachinePrecision], 2.4e+104], N[Not[LessEqual[N[(x * y), $MachinePrecision], 4e+170]], $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 -8.2 \cdot 10^{-13} \lor \neg \left(x \cdot y \leq 5.8 \cdot 10^{+61}\right) \land \left(x \cdot y \leq 2.4 \cdot 10^{+104} \lor \neg \left(x \cdot y \leq 4 \cdot 10^{+170}\right)\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -8.2000000000000004e-13 or 5.8000000000000001e61 < (*.f64 x y) < 2.4e104 or 4.00000000000000014e170 < (*.f64 x y) Initial program 93.1%
Taylor expanded in z around 0 82.7%
if -8.2000000000000004e-13 < (*.f64 x y) < 5.8000000000000001e61 or 2.4e104 < (*.f64 x y) < 4.00000000000000014e170Initial program 99.3%
Taylor expanded in x around 0 92.3%
Final simplification87.9%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* a b) -2e+237)
(and (not (<= (* a b) -2.9e+227))
(or (<= (* a b) -5.8e-28) (not (<= (* a b) 4.4e+22)))))
(* a b)
(* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -2e+237) || (!((a * b) <= -2.9e+227) && (((a * b) <= -5.8e-28) || !((a * b) <= 4.4e+22)))) {
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) <= (-2d+237)) .or. (.not. ((a * b) <= (-2.9d+227))) .and. ((a * b) <= (-5.8d-28)) .or. (.not. ((a * b) <= 4.4d+22))) 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) <= -2e+237) || (!((a * b) <= -2.9e+227) && (((a * b) <= -5.8e-28) || !((a * b) <= 4.4e+22)))) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -2e+237) or (not ((a * b) <= -2.9e+227) and (((a * b) <= -5.8e-28) or not ((a * b) <= 4.4e+22))): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -2e+237) || (!(Float64(a * b) <= -2.9e+227) && ((Float64(a * b) <= -5.8e-28) || !(Float64(a * b) <= 4.4e+22)))) 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) <= -2e+237) || (~(((a * b) <= -2.9e+227)) && (((a * b) <= -5.8e-28) || ~(((a * b) <= 4.4e+22))))) 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], -2e+237], And[N[Not[LessEqual[N[(a * b), $MachinePrecision], -2.9e+227]], $MachinePrecision], Or[LessEqual[N[(a * b), $MachinePrecision], -5.8e-28], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4.4e+22]], $MachinePrecision]]]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+237} \lor \neg \left(a \cdot b \leq -2.9 \cdot 10^{+227}\right) \land \left(a \cdot b \leq -5.8 \cdot 10^{-28} \lor \neg \left(a \cdot b \leq 4.4 \cdot 10^{+22}\right)\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.99999999999999988e237 or -2.8999999999999998e227 < (*.f64 a b) < -5.80000000000000026e-28 or 4.4e22 < (*.f64 a b) Initial program 92.8%
Taylor expanded in a around inf 62.5%
if -1.99999999999999988e237 < (*.f64 a b) < -2.8999999999999998e227 or -5.80000000000000026e-28 < (*.f64 a b) < 4.4e22Initial program 100.0%
Taylor expanded in z around inf 52.6%
Final simplification57.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -3.7e+169)
(* x y)
(if (<= (* x y) -2.35e+57)
(* a b)
(if (or (<= (* x y) -4.1e-8) (not (<= (* x y) 1.6e+171)))
(* x y)
(* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -3.7e+169) {
tmp = x * y;
} else if ((x * y) <= -2.35e+57) {
tmp = a * b;
} else if (((x * y) <= -4.1e-8) || !((x * y) <= 1.6e+171)) {
tmp = x * y;
} 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 ((x * y) <= (-3.7d+169)) then
tmp = x * y
else if ((x * y) <= (-2.35d+57)) then
tmp = a * b
else if (((x * y) <= (-4.1d-8)) .or. (.not. ((x * y) <= 1.6d+171))) then
tmp = x * y
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 ((x * y) <= -3.7e+169) {
tmp = x * y;
} else if ((x * y) <= -2.35e+57) {
tmp = a * b;
} else if (((x * y) <= -4.1e-8) || !((x * y) <= 1.6e+171)) {
tmp = x * y;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -3.7e+169: tmp = x * y elif (x * y) <= -2.35e+57: tmp = a * b elif ((x * y) <= -4.1e-8) or not ((x * y) <= 1.6e+171): tmp = x * y else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -3.7e+169) tmp = Float64(x * y); elseif (Float64(x * y) <= -2.35e+57) tmp = Float64(a * b); elseif ((Float64(x * y) <= -4.1e-8) || !(Float64(x * y) <= 1.6e+171)) tmp = Float64(x * y); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -3.7e+169) tmp = x * y; elseif ((x * y) <= -2.35e+57) tmp = a * b; elseif (((x * y) <= -4.1e-8) || ~(((x * y) <= 1.6e+171))) tmp = x * y; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -3.7e+169], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2.35e+57], N[(a * b), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], -4.1e-8], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.6e+171]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(z * t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.7 \cdot 10^{+169}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -2.35 \cdot 10^{+57}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq -4.1 \cdot 10^{-8} \lor \neg \left(x \cdot y \leq 1.6 \cdot 10^{+171}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -3.70000000000000001e169 or -2.3500000000000001e57 < (*.f64 x y) < -4.10000000000000032e-8 or 1.60000000000000006e171 < (*.f64 x y) Initial program 90.1%
Taylor expanded in x around inf 78.1%
if -3.70000000000000001e169 < (*.f64 x y) < -2.3500000000000001e57Initial program 100.0%
Taylor expanded in a around inf 46.2%
if -4.10000000000000032e-8 < (*.f64 x y) < 1.60000000000000006e171Initial program 99.3%
Taylor expanded in z around inf 50.9%
Final simplification59.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* a b) (* z t))))
(if (<= (* a b) -3.5e-26)
t_1
(if (<= (* a b) 2e+22)
(+ (* x y) (* z t))
(if (<= (* a b) 1e+131) (+ (* a b) (* x y)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + (z * t);
double tmp;
if ((a * b) <= -3.5e-26) {
tmp = t_1;
} else if ((a * b) <= 2e+22) {
tmp = (x * y) + (z * t);
} else if ((a * b) <= 1e+131) {
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 = (a * b) + (z * t)
if ((a * b) <= (-3.5d-26)) then
tmp = t_1
else if ((a * b) <= 2d+22) then
tmp = (x * y) + (z * t)
else if ((a * b) <= 1d+131) 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 = (a * b) + (z * t);
double tmp;
if ((a * b) <= -3.5e-26) {
tmp = t_1;
} else if ((a * b) <= 2e+22) {
tmp = (x * y) + (z * t);
} else if ((a * b) <= 1e+131) {
tmp = (a * b) + (x * y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + (z * t) tmp = 0 if (a * b) <= -3.5e-26: tmp = t_1 elif (a * b) <= 2e+22: tmp = (x * y) + (z * t) elif (a * b) <= 1e+131: tmp = (a * b) + (x * y) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(z * t)) tmp = 0.0 if (Float64(a * b) <= -3.5e-26) tmp = t_1; elseif (Float64(a * b) <= 2e+22) tmp = Float64(Float64(x * y) + Float64(z * t)); elseif (Float64(a * b) <= 1e+131) 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 = (a * b) + (z * t); tmp = 0.0; if ((a * b) <= -3.5e-26) tmp = t_1; elseif ((a * b) <= 2e+22) tmp = (x * y) + (z * t); elseif ((a * b) <= 1e+131) 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[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -3.5e-26], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 2e+22], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+131], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -3.5 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+22}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 10^{+131}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -3.49999999999999985e-26 or 9.9999999999999991e130 < (*.f64 a b) Initial program 91.2%
Taylor expanded in x around 0 83.8%
if -3.49999999999999985e-26 < (*.f64 a b) < 2e22Initial program 100.0%
Taylor expanded in a around 0 93.6%
if 2e22 < (*.f64 a b) < 9.9999999999999991e130Initial program 100.0%
Taylor expanded in z around 0 81.2%
Final simplification88.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.5%
Taylor expanded in a around inf 34.5%
Final simplification34.5%
herbie shell --seed 2024076
(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)))