
(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 11 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 (<= (* a b) (- INFINITY)) (* z (+ t (* a (/ b z)))) (+ (* a b) (fma x y (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -((double) INFINITY)) {
tmp = z * (t + (a * (b / z)));
} else {
tmp = (a * b) + fma(x, y, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= Float64(-Inf)) tmp = Float64(z * Float64(t + Float64(a * Float64(b / z)))); else tmp = Float64(Float64(a * b) + fma(x, y, Float64(z * t))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], (-Infinity)], N[(z * N[(t + N[(a * N[(b / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -\infty:\\
\;\;\;\;z \cdot \left(t + a \cdot \frac{b}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -inf.0Initial program 73.9%
Taylor expanded in x around 0 82.6%
Taylor expanded in z around inf 91.3%
associate-/l*95.7%
Simplified95.7%
if -inf.0 < (*.f64 a b) Initial program 99.1%
fma-define100.0%
Simplified100.0%
Final simplification99.6%
(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.9%
associate-+l+96.9%
fma-define98.4%
fma-define99.2%
Simplified99.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 96.9%
+-commutative96.9%
fma-define97.7%
fma-define98.4%
Simplified98.4%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -1.22e+117)
(and (not (<= (* x y) 2.4e+122))
(or (<= (* x y) 1.3e+221) (not (<= (* x y) 1.55e+252)))))
(* 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) <= -1.22e+117) || (!((x * y) <= 2.4e+122) && (((x * y) <= 1.3e+221) || !((x * y) <= 1.55e+252)))) {
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) <= (-1.22d+117)) .or. (.not. ((x * y) <= 2.4d+122)) .and. ((x * y) <= 1.3d+221) .or. (.not. ((x * y) <= 1.55d+252))) 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) <= -1.22e+117) || (!((x * y) <= 2.4e+122) && (((x * y) <= 1.3e+221) || !((x * y) <= 1.55e+252)))) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -1.22e+117) or (not ((x * y) <= 2.4e+122) and (((x * y) <= 1.3e+221) or not ((x * y) <= 1.55e+252))): 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) <= -1.22e+117) || (!(Float64(x * y) <= 2.4e+122) && ((Float64(x * y) <= 1.3e+221) || !(Float64(x * y) <= 1.55e+252)))) 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) <= -1.22e+117) || (~(((x * y) <= 2.4e+122)) && (((x * y) <= 1.3e+221) || ~(((x * y) <= 1.55e+252))))) 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], -1.22e+117], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.4e+122]], $MachinePrecision], Or[LessEqual[N[(x * y), $MachinePrecision], 1.3e+221], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.55e+252]], $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 -1.22 \cdot 10^{+117} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+122}\right) \land \left(x \cdot y \leq 1.3 \cdot 10^{+221} \lor \neg \left(x \cdot y \leq 1.55 \cdot 10^{+252}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.22000000000000004e117 or 2.4000000000000002e122 < (*.f64 x y) < 1.30000000000000002e221 or 1.54999999999999991e252 < (*.f64 x y) Initial program 93.3%
Taylor expanded in x around inf 76.6%
if -1.22000000000000004e117 < (*.f64 x y) < 2.4000000000000002e122 or 1.30000000000000002e221 < (*.f64 x y) < 1.54999999999999991e252Initial program 98.3%
Taylor expanded in x around 0 87.1%
Final simplification84.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* a b) (* x y))))
(if (<= (* x y) -7.2e+71)
t_1
(if (<= (* x y) 2e-22)
(+ (* a b) (* z t))
(if (or (<= (* x y) 9e+71) (not (<= (* x y) 1.85e+171)))
t_1
(+ (* x y) (* z t)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + (x * y);
double tmp;
if ((x * y) <= -7.2e+71) {
tmp = t_1;
} else if ((x * y) <= 2e-22) {
tmp = (a * b) + (z * t);
} else if (((x * y) <= 9e+71) || !((x * y) <= 1.85e+171)) {
tmp = t_1;
} else {
tmp = (x * y) + (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) :: t_1
real(8) :: tmp
t_1 = (a * b) + (x * y)
if ((x * y) <= (-7.2d+71)) then
tmp = t_1
else if ((x * y) <= 2d-22) then
tmp = (a * b) + (z * t)
else if (((x * y) <= 9d+71) .or. (.not. ((x * y) <= 1.85d+171))) then
tmp = t_1
else
tmp = (x * y) + (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 t_1 = (a * b) + (x * y);
double tmp;
if ((x * y) <= -7.2e+71) {
tmp = t_1;
} else if ((x * y) <= 2e-22) {
tmp = (a * b) + (z * t);
} else if (((x * y) <= 9e+71) || !((x * y) <= 1.85e+171)) {
tmp = t_1;
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + (x * y) tmp = 0 if (x * y) <= -7.2e+71: tmp = t_1 elif (x * y) <= 2e-22: tmp = (a * b) + (z * t) elif ((x * y) <= 9e+71) or not ((x * y) <= 1.85e+171): tmp = t_1 else: tmp = (x * y) + (z * t) return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(x * y)) tmp = 0.0 if (Float64(x * y) <= -7.2e+71) tmp = t_1; elseif (Float64(x * y) <= 2e-22) tmp = Float64(Float64(a * b) + Float64(z * t)); elseif ((Float64(x * y) <= 9e+71) || !(Float64(x * y) <= 1.85e+171)) tmp = t_1; else tmp = Float64(Float64(x * y) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + (x * y); tmp = 0.0; if ((x * y) <= -7.2e+71) tmp = t_1; elseif ((x * y) <= 2e-22) tmp = (a * b) + (z * t); elseif (((x * y) <= 9e+71) || ~(((x * y) <= 1.85e+171))) tmp = t_1; else tmp = (x * y) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -7.2e+71], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 2e-22], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], 9e+71], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.85e+171]], $MachinePrecision]], t$95$1, N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
\mathbf{if}\;x \cdot y \leq -7.2 \cdot 10^{+71}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-22}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 9 \cdot 10^{+71} \lor \neg \left(x \cdot y \leq 1.85 \cdot 10^{+171}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -7.1999999999999999e71 or 2.0000000000000001e-22 < (*.f64 x y) < 9.00000000000000087e71 or 1.84999999999999999e171 < (*.f64 x y) Initial program 93.9%
Taylor expanded in z around 0 86.0%
if -7.1999999999999999e71 < (*.f64 x y) < 2.0000000000000001e-22Initial program 98.5%
Taylor expanded in x around 0 93.5%
if 9.00000000000000087e71 < (*.f64 x y) < 1.84999999999999999e171Initial program 100.0%
Taylor expanded in a around 0 94.7%
Final simplification90.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* a b) (* x y))))
(if (<= (* x y) -3.2e+70)
t_1
(if (<= (* x y) 7e-22)
(+ (* a b) (* z t))
(if (or (<= (* x y) 8.2e+83) (not (<= (* x y) 5e+106))) t_1 (* z t))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + (x * y);
double tmp;
if ((x * y) <= -3.2e+70) {
tmp = t_1;
} else if ((x * y) <= 7e-22) {
tmp = (a * b) + (z * t);
} else if (((x * y) <= 8.2e+83) || !((x * y) <= 5e+106)) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = (a * b) + (x * y)
if ((x * y) <= (-3.2d+70)) then
tmp = t_1
else if ((x * y) <= 7d-22) then
tmp = (a * b) + (z * t)
else if (((x * y) <= 8.2d+83) .or. (.not. ((x * y) <= 5d+106))) then
tmp = t_1
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 t_1 = (a * b) + (x * y);
double tmp;
if ((x * y) <= -3.2e+70) {
tmp = t_1;
} else if ((x * y) <= 7e-22) {
tmp = (a * b) + (z * t);
} else if (((x * y) <= 8.2e+83) || !((x * y) <= 5e+106)) {
tmp = t_1;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + (x * y) tmp = 0 if (x * y) <= -3.2e+70: tmp = t_1 elif (x * y) <= 7e-22: tmp = (a * b) + (z * t) elif ((x * y) <= 8.2e+83) or not ((x * y) <= 5e+106): tmp = t_1 else: tmp = z * t return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(x * y)) tmp = 0.0 if (Float64(x * y) <= -3.2e+70) tmp = t_1; elseif (Float64(x * y) <= 7e-22) tmp = Float64(Float64(a * b) + Float64(z * t)); elseif ((Float64(x * y) <= 8.2e+83) || !(Float64(x * y) <= 5e+106)) tmp = t_1; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + (x * y); tmp = 0.0; if ((x * y) <= -3.2e+70) tmp = t_1; elseif ((x * y) <= 7e-22) tmp = (a * b) + (z * t); elseif (((x * y) <= 8.2e+83) || ~(((x * y) <= 5e+106))) tmp = t_1; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -3.2e+70], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 7e-22], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], 8.2e+83], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+106]], $MachinePrecision]], t$95$1, N[(z * t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
\mathbf{if}\;x \cdot y \leq -3.2 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 7 \cdot 10^{-22}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 8.2 \cdot 10^{+83} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+106}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -3.2000000000000002e70 or 7.00000000000000011e-22 < (*.f64 x y) < 8.2000000000000002e83 or 4.9999999999999998e106 < (*.f64 x y) Initial program 94.5%
Taylor expanded in z around 0 85.4%
if -3.2000000000000002e70 < (*.f64 x y) < 7.00000000000000011e-22Initial program 98.5%
Taylor expanded in x around 0 93.5%
if 8.2000000000000002e83 < (*.f64 x y) < 4.9999999999999998e106Initial program 100.0%
Taylor expanded in z around inf 75.4%
Final simplification89.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* a b) (* x y))))
(if (<= (* x y) -2.1e+71)
t_1
(if (<= (* x y) 3.5e-24)
(+ (* a b) (* z t))
(if (<= (* x y) 6.8e+71)
(* a (+ b (/ (* x y) a)))
(if (<= (* x y) 1.85e+171) (+ (* x y) (* z t)) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + (x * y);
double tmp;
if ((x * y) <= -2.1e+71) {
tmp = t_1;
} else if ((x * y) <= 3.5e-24) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 6.8e+71) {
tmp = a * (b + ((x * y) / a));
} else if ((x * y) <= 1.85e+171) {
tmp = (x * y) + (z * t);
} 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) + (x * y)
if ((x * y) <= (-2.1d+71)) then
tmp = t_1
else if ((x * y) <= 3.5d-24) then
tmp = (a * b) + (z * t)
else if ((x * y) <= 6.8d+71) then
tmp = a * (b + ((x * y) / a))
else if ((x * y) <= 1.85d+171) then
tmp = (x * y) + (z * t)
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) + (x * y);
double tmp;
if ((x * y) <= -2.1e+71) {
tmp = t_1;
} else if ((x * y) <= 3.5e-24) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 6.8e+71) {
tmp = a * (b + ((x * y) / a));
} else if ((x * y) <= 1.85e+171) {
tmp = (x * y) + (z * t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + (x * y) tmp = 0 if (x * y) <= -2.1e+71: tmp = t_1 elif (x * y) <= 3.5e-24: tmp = (a * b) + (z * t) elif (x * y) <= 6.8e+71: tmp = a * (b + ((x * y) / a)) elif (x * y) <= 1.85e+171: tmp = (x * y) + (z * t) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(x * y)) tmp = 0.0 if (Float64(x * y) <= -2.1e+71) tmp = t_1; elseif (Float64(x * y) <= 3.5e-24) tmp = Float64(Float64(a * b) + Float64(z * t)); elseif (Float64(x * y) <= 6.8e+71) tmp = Float64(a * Float64(b + Float64(Float64(x * y) / a))); elseif (Float64(x * y) <= 1.85e+171) tmp = Float64(Float64(x * y) + Float64(z * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + (x * y); tmp = 0.0; if ((x * y) <= -2.1e+71) tmp = t_1; elseif ((x * y) <= 3.5e-24) tmp = (a * b) + (z * t); elseif ((x * y) <= 6.8e+71) tmp = a * (b + ((x * y) / a)); elseif ((x * y) <= 1.85e+171) tmp = (x * y) + (z * t); 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2.1e+71], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 3.5e-24], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 6.8e+71], N[(a * N[(b + N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.85e+171], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
\mathbf{if}\;x \cdot y \leq -2.1 \cdot 10^{+71}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 3.5 \cdot 10^{-24}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 6.8 \cdot 10^{+71}:\\
\;\;\;\;a \cdot \left(b + \frac{x \cdot y}{a}\right)\\
\mathbf{elif}\;x \cdot y \leq 1.85 \cdot 10^{+171}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -2.09999999999999989e71 or 1.84999999999999999e171 < (*.f64 x y) Initial program 93.7%
Taylor expanded in z around 0 86.2%
if -2.09999999999999989e71 < (*.f64 x y) < 3.4999999999999996e-24Initial program 98.5%
Taylor expanded in x around 0 93.5%
if 3.4999999999999996e-24 < (*.f64 x y) < 6.7999999999999997e71Initial program 94.9%
Taylor expanded in a around inf 90.1%
Taylor expanded in t around 0 80.1%
if 6.7999999999999997e71 < (*.f64 x y) < 1.84999999999999999e171Initial program 100.0%
Taylor expanded in a around 0 94.7%
Final simplification90.3%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -1.65e+103)
(* a b)
(if (<= a -1.5e-11)
(* z t)
(if (<= a -1.2e-68)
(* x y)
(if (<= a -1.55e-221) (* z t) (if (<= a 6.2e-150) (* x y) (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.65e+103) {
tmp = a * b;
} else if (a <= -1.5e-11) {
tmp = z * t;
} else if (a <= -1.2e-68) {
tmp = x * y;
} else if (a <= -1.55e-221) {
tmp = z * t;
} else if (a <= 6.2e-150) {
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 <= (-1.65d+103)) then
tmp = a * b
else if (a <= (-1.5d-11)) then
tmp = z * t
else if (a <= (-1.2d-68)) then
tmp = x * y
else if (a <= (-1.55d-221)) then
tmp = z * t
else if (a <= 6.2d-150) 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 <= -1.65e+103) {
tmp = a * b;
} else if (a <= -1.5e-11) {
tmp = z * t;
} else if (a <= -1.2e-68) {
tmp = x * y;
} else if (a <= -1.55e-221) {
tmp = z * t;
} else if (a <= 6.2e-150) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -1.65e+103: tmp = a * b elif a <= -1.5e-11: tmp = z * t elif a <= -1.2e-68: tmp = x * y elif a <= -1.55e-221: tmp = z * t elif a <= 6.2e-150: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.65e+103) tmp = Float64(a * b); elseif (a <= -1.5e-11) tmp = Float64(z * t); elseif (a <= -1.2e-68) tmp = Float64(x * y); elseif (a <= -1.55e-221) tmp = Float64(z * t); elseif (a <= 6.2e-150) 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 <= -1.65e+103) tmp = a * b; elseif (a <= -1.5e-11) tmp = z * t; elseif (a <= -1.2e-68) tmp = x * y; elseif (a <= -1.55e-221) tmp = z * t; elseif (a <= 6.2e-150) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.65e+103], N[(a * b), $MachinePrecision], If[LessEqual[a, -1.5e-11], N[(z * t), $MachinePrecision], If[LessEqual[a, -1.2e-68], N[(x * y), $MachinePrecision], If[LessEqual[a, -1.55e-221], N[(z * t), $MachinePrecision], If[LessEqual[a, 6.2e-150], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65 \cdot 10^{+103}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \leq -1.5 \cdot 10^{-11}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \leq -1.2 \cdot 10^{-68}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \leq -1.55 \cdot 10^{-221}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{-150}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if a < -1.65000000000000004e103 or 6.19999999999999996e-150 < a Initial program 96.7%
Taylor expanded in a around inf 58.2%
if -1.65000000000000004e103 < a < -1.5e-11 or -1.19999999999999996e-68 < a < -1.55e-221Initial program 93.9%
Taylor expanded in z around inf 54.0%
if -1.5e-11 < a < -1.19999999999999996e-68 or -1.55e-221 < a < 6.19999999999999996e-150Initial program 100.0%
Taylor expanded in x around inf 57.9%
Final simplification57.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (* z (+ t (* a (/ b z)))))))
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 = z * (t + (a * (b / z)));
}
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 = z * (t + (a * (b / z)));
}
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 = z * (t + (a * (b / z))) 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(z * Float64(t + Float64(a * Float64(b / z)))); 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 = z * (t + (a * (b / z))); 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[(z * N[(t + N[(a * N[(b / z), $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}:\\
\;\;\;\;z \cdot \left(t + a \cdot \frac{b}{z}\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 50.0%
Taylor expanded in z around inf 75.0%
associate-/l*87.5%
Simplified87.5%
Final simplification99.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -8.2e-35) (not (<= (* a b) 1.45e+32))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -8.2e-35) || !((a * b) <= 1.45e+32)) {
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) <= (-8.2d-35)) .or. (.not. ((a * b) <= 1.45d+32))) 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) <= -8.2e-35) || !((a * b) <= 1.45e+32)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -8.2e-35) or not ((a * b) <= 1.45e+32): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -8.2e-35) || !(Float64(a * b) <= 1.45e+32)) 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) <= -8.2e-35) || ~(((a * b) <= 1.45e+32))) 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], -8.2e-35], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1.45e+32]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -8.2 \cdot 10^{-35} \lor \neg \left(a \cdot b \leq 1.45 \cdot 10^{+32}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -8.20000000000000052e-35 or 1.45000000000000001e32 < (*.f64 a b) Initial program 94.5%
Taylor expanded in a around inf 65.9%
if -8.20000000000000052e-35 < (*.f64 a b) < 1.45000000000000001e32Initial program 100.0%
Taylor expanded in z around inf 49.5%
Final simplification58.9%
(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.9%
Taylor expanded in a around inf 40.7%
herbie shell --seed 2024101
(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)))