
(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 9 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 (* x (+ y (* t (/ z x)))))))
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 = x * (y + (t * (z / x)));
}
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 = x * (y + (t * (z / x)));
}
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 = x * (y + (t * (z / x))) 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(x * Float64(y + Float64(t * Float64(z / x)))); 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 = x * (y + (t * (z / x))); 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[(x * N[(y + N[(t * N[(z / x), $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}:\\
\;\;\;\;x \cdot \left(y + t \cdot \frac{z}{x}\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 a around 0 66.7%
Taylor expanded in x around inf 83.3%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(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.6%
+-commutative97.6%
fma-define99.2%
fma-define99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -2.1e+170)
(* x y)
(if (<= (* x y) -2.4e+131)
(* z t)
(if (<= (* x y) -8.1e+80)
(* x y)
(if (<= (* x y) -2.8e-41)
(* z t)
(if (<= (* x y) -4.25e-76)
(* a b)
(if (<= (* x y) -8.2e-179)
(* z t)
(if (<= (* x y) -3.2e-289)
(* a b)
(if (<= (* x y) 9.5e+23) (* z t) (* x y))))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -2.1e+170) {
tmp = x * y;
} else if ((x * y) <= -2.4e+131) {
tmp = z * t;
} else if ((x * y) <= -8.1e+80) {
tmp = x * y;
} else if ((x * y) <= -2.8e-41) {
tmp = z * t;
} else if ((x * y) <= -4.25e-76) {
tmp = a * b;
} else if ((x * y) <= -8.2e-179) {
tmp = z * t;
} else if ((x * y) <= -3.2e-289) {
tmp = a * b;
} else if ((x * y) <= 9.5e+23) {
tmp = 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.1d+170)) then
tmp = x * y
else if ((x * y) <= (-2.4d+131)) then
tmp = z * t
else if ((x * y) <= (-8.1d+80)) then
tmp = x * y
else if ((x * y) <= (-2.8d-41)) then
tmp = z * t
else if ((x * y) <= (-4.25d-76)) then
tmp = a * b
else if ((x * y) <= (-8.2d-179)) then
tmp = z * t
else if ((x * y) <= (-3.2d-289)) then
tmp = a * b
else if ((x * y) <= 9.5d+23) then
tmp = 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.1e+170) {
tmp = x * y;
} else if ((x * y) <= -2.4e+131) {
tmp = z * t;
} else if ((x * y) <= -8.1e+80) {
tmp = x * y;
} else if ((x * y) <= -2.8e-41) {
tmp = z * t;
} else if ((x * y) <= -4.25e-76) {
tmp = a * b;
} else if ((x * y) <= -8.2e-179) {
tmp = z * t;
} else if ((x * y) <= -3.2e-289) {
tmp = a * b;
} else if ((x * y) <= 9.5e+23) {
tmp = z * t;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -2.1e+170: tmp = x * y elif (x * y) <= -2.4e+131: tmp = z * t elif (x * y) <= -8.1e+80: tmp = x * y elif (x * y) <= -2.8e-41: tmp = z * t elif (x * y) <= -4.25e-76: tmp = a * b elif (x * y) <= -8.2e-179: tmp = z * t elif (x * y) <= -3.2e-289: tmp = a * b elif (x * y) <= 9.5e+23: tmp = z * t else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -2.1e+170) tmp = Float64(x * y); elseif (Float64(x * y) <= -2.4e+131) tmp = Float64(z * t); elseif (Float64(x * y) <= -8.1e+80) tmp = Float64(x * y); elseif (Float64(x * y) <= -2.8e-41) tmp = Float64(z * t); elseif (Float64(x * y) <= -4.25e-76) tmp = Float64(a * b); elseif (Float64(x * y) <= -8.2e-179) tmp = Float64(z * t); elseif (Float64(x * y) <= -3.2e-289) tmp = Float64(a * b); elseif (Float64(x * y) <= 9.5e+23) tmp = 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.1e+170) tmp = x * y; elseif ((x * y) <= -2.4e+131) tmp = z * t; elseif ((x * y) <= -8.1e+80) tmp = x * y; elseif ((x * y) <= -2.8e-41) tmp = z * t; elseif ((x * y) <= -4.25e-76) tmp = a * b; elseif ((x * y) <= -8.2e-179) tmp = z * t; elseif ((x * y) <= -3.2e-289) tmp = a * b; elseif ((x * y) <= 9.5e+23) tmp = 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.1e+170], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2.4e+131], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -8.1e+80], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2.8e-41], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -4.25e-76], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -8.2e-179], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -3.2e-289], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 9.5e+23], N[(z * t), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.1 \cdot 10^{+170}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -2.4 \cdot 10^{+131}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq -8.1 \cdot 10^{+80}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -2.8 \cdot 10^{-41}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq -4.25 \cdot 10^{-76}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq -8.2 \cdot 10^{-179}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq -3.2 \cdot 10^{-289}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq 9.5 \cdot 10^{+23}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -2.09999999999999998e170 or -2.3999999999999999e131 < (*.f64 x y) < -8.10000000000000002e80 or 9.50000000000000038e23 < (*.f64 x y) Initial program 95.7%
Taylor expanded in x around inf 77.7%
if -2.09999999999999998e170 < (*.f64 x y) < -2.3999999999999999e131 or -8.10000000000000002e80 < (*.f64 x y) < -2.8000000000000002e-41 or -4.25000000000000019e-76 < (*.f64 x y) < -8.2e-179 or -3.2000000000000002e-289 < (*.f64 x y) < 9.50000000000000038e23Initial program 98.5%
Taylor expanded in z around inf 65.8%
if -2.8000000000000002e-41 < (*.f64 x y) < -4.25000000000000019e-76 or -8.2e-179 < (*.f64 x y) < -3.2000000000000002e-289Initial program 100.0%
Taylor expanded in a around inf 71.0%
Final simplification70.6%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -1.75e+178)
(and (not (<= (* x y) -1.02e+129))
(or (<= (* x y) -2.25e+108) (not (<= (* x y) 4.5e+98)))))
(* 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.75e+178) || (!((x * y) <= -1.02e+129) && (((x * y) <= -2.25e+108) || !((x * y) <= 4.5e+98)))) {
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.75d+178)) .or. (.not. ((x * y) <= (-1.02d+129))) .and. ((x * y) <= (-2.25d+108)) .or. (.not. ((x * y) <= 4.5d+98))) 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.75e+178) || (!((x * y) <= -1.02e+129) && (((x * y) <= -2.25e+108) || !((x * y) <= 4.5e+98)))) {
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.75e+178) or (not ((x * y) <= -1.02e+129) and (((x * y) <= -2.25e+108) or not ((x * y) <= 4.5e+98))): 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.75e+178) || (!(Float64(x * y) <= -1.02e+129) && ((Float64(x * y) <= -2.25e+108) || !(Float64(x * y) <= 4.5e+98)))) 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.75e+178) || (~(((x * y) <= -1.02e+129)) && (((x * y) <= -2.25e+108) || ~(((x * y) <= 4.5e+98))))) 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.75e+178], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -1.02e+129]], $MachinePrecision], Or[LessEqual[N[(x * y), $MachinePrecision], -2.25e+108], N[Not[LessEqual[N[(x * y), $MachinePrecision], 4.5e+98]], $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.75 \cdot 10^{+178} \lor \neg \left(x \cdot y \leq -1.02 \cdot 10^{+129}\right) \land \left(x \cdot y \leq -2.25 \cdot 10^{+108} \lor \neg \left(x \cdot y \leq 4.5 \cdot 10^{+98}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.75e178 or -1.01999999999999996e129 < (*.f64 x y) < -2.25e108 or 4.5000000000000002e98 < (*.f64 x y) Initial program 94.6%
Taylor expanded in x around inf 85.2%
if -1.75e178 < (*.f64 x y) < -1.01999999999999996e129 or -2.25e108 < (*.f64 x y) < 4.5000000000000002e98Initial program 98.9%
Taylor expanded in x around 0 86.1%
Final simplification85.8%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -1.6e+170)
(not
(or (<= (* x y) -5.8e+130)
(and (not (<= (* x y) -1.45e+81)) (<= (* x y) 2.5e+26)))))
(+ (* 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) <= -1.6e+170) || !(((x * y) <= -5.8e+130) || (!((x * y) <= -1.45e+81) && ((x * y) <= 2.5e+26)))) {
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) <= (-1.6d+170)) .or. (.not. ((x * y) <= (-5.8d+130)) .or. (.not. ((x * y) <= (-1.45d+81))) .and. ((x * y) <= 2.5d+26))) 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) <= -1.6e+170) || !(((x * y) <= -5.8e+130) || (!((x * y) <= -1.45e+81) && ((x * y) <= 2.5e+26)))) {
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) <= -1.6e+170) or not (((x * y) <= -5.8e+130) or (not ((x * y) <= -1.45e+81) and ((x * y) <= 2.5e+26))): 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) <= -1.6e+170) || !((Float64(x * y) <= -5.8e+130) || (!(Float64(x * y) <= -1.45e+81) && (Float64(x * y) <= 2.5e+26)))) 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) <= -1.6e+170) || ~((((x * y) <= -5.8e+130) || (~(((x * y) <= -1.45e+81)) && ((x * y) <= 2.5e+26))))) 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], -1.6e+170], N[Not[Or[LessEqual[N[(x * y), $MachinePrecision], -5.8e+130], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -1.45e+81]], $MachinePrecision], LessEqual[N[(x * y), $MachinePrecision], 2.5e+26]]]], $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 -1.6 \cdot 10^{+170} \lor \neg \left(x \cdot y \leq -5.8 \cdot 10^{+130} \lor \neg \left(x \cdot y \leq -1.45 \cdot 10^{+81}\right) \land x \cdot y \leq 2.5 \cdot 10^{+26}\right):\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.59999999999999989e170 or -5.7999999999999998e130 < (*.f64 x y) < -1.45e81 or 2.5e26 < (*.f64 x y) Initial program 95.7%
Taylor expanded in z around 0 87.2%
if -1.59999999999999989e170 < (*.f64 x y) < -5.7999999999999998e130 or -1.45e81 < (*.f64 x y) < 2.5e26Initial program 98.8%
Taylor expanded in x around 0 89.5%
Final simplification88.6%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -3.8e+87) (+ (* x y) (* a b)) (if (<= (* a b) 3.1e+56) (+ (* 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) <= -3.8e+87) {
tmp = (x * y) + (a * b);
} else if ((a * b) <= 3.1e+56) {
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) <= (-3.8d+87)) then
tmp = (x * y) + (a * b)
else if ((a * b) <= 3.1d+56) 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) <= -3.8e+87) {
tmp = (x * y) + (a * b);
} else if ((a * b) <= 3.1e+56) {
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) <= -3.8e+87: tmp = (x * y) + (a * b) elif (a * b) <= 3.1e+56: 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) <= -3.8e+87) tmp = Float64(Float64(x * y) + Float64(a * b)); elseif (Float64(a * b) <= 3.1e+56) 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) <= -3.8e+87) tmp = (x * y) + (a * b); elseif ((a * b) <= 3.1e+56) 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], -3.8e+87], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.1e+56], 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 -3.8 \cdot 10^{+87}:\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 3.1 \cdot 10^{+56}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -3.80000000000000011e87Initial program 97.7%
Taylor expanded in z around 0 86.6%
if -3.80000000000000011e87 < (*.f64 a b) < 3.10000000000000005e56Initial program 98.8%
Taylor expanded in a around 0 91.1%
if 3.10000000000000005e56 < (*.f64 a b) Initial program 92.6%
Taylor expanded in x around 0 85.3%
Final simplification89.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -5e+60) (* y (+ x (/ (* z t) y))) (if (<= (* x y) 200000.0) (+ (* a b) (* z t)) (+ (* x y) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -5e+60) {
tmp = y * (x + ((z * t) / y));
} else if ((x * y) <= 200000.0) {
tmp = (a * b) + (z * t);
} 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) :: tmp
if ((x * y) <= (-5d+60)) then
tmp = y * (x + ((z * t) / y))
else if ((x * y) <= 200000.0d0) then
tmp = (a * b) + (z * t)
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 tmp;
if ((x * y) <= -5e+60) {
tmp = y * (x + ((z * t) / y));
} else if ((x * y) <= 200000.0) {
tmp = (a * b) + (z * t);
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -5e+60: tmp = y * (x + ((z * t) / y)) elif (x * y) <= 200000.0: tmp = (a * b) + (z * t) else: tmp = (x * y) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -5e+60) tmp = Float64(y * Float64(x + Float64(Float64(z * t) / y))); elseif (Float64(x * y) <= 200000.0) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(Float64(x * y) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -5e+60) tmp = y * (x + ((z * t) / y)); elseif ((x * y) <= 200000.0) tmp = (a * b) + (z * t); else tmp = (x * y) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+60], N[(y * N[(x + N[(N[(z * t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 200000.0], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+60}:\\
\;\;\;\;y \cdot \left(x + \frac{z \cdot t}{y}\right)\\
\mathbf{elif}\;x \cdot y \leq 200000:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999975e60Initial program 94.9%
Taylor expanded in y around inf 95.0%
Taylor expanded in a around 0 85.4%
if -4.99999999999999975e60 < (*.f64 x y) < 2e5Initial program 98.6%
Taylor expanded in x around 0 91.6%
if 2e5 < (*.f64 x y) Initial program 98.1%
Taylor expanded in a around 0 86.7%
Final simplification89.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -3.8e+80) (not (<= (* a b) 1.08e+66))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -3.8e+80) || !((a * b) <= 1.08e+66)) {
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) <= (-3.8d+80)) .or. (.not. ((a * b) <= 1.08d+66))) 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) <= -3.8e+80) || !((a * b) <= 1.08e+66)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -3.8e+80) or not ((a * b) <= 1.08e+66): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -3.8e+80) || !(Float64(a * b) <= 1.08e+66)) 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) <= -3.8e+80) || ~(((a * b) <= 1.08e+66))) 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], -3.8e+80], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1.08e+66]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3.8 \cdot 10^{+80} \lor \neg \left(a \cdot b \leq 1.08 \cdot 10^{+66}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -3.79999999999999997e80 or 1.08000000000000008e66 < (*.f64 a b) Initial program 95.0%
Taylor expanded in a around inf 66.0%
if -3.79999999999999997e80 < (*.f64 a b) < 1.08000000000000008e66Initial program 98.8%
Taylor expanded in z around inf 51.6%
Final simplification56.1%
(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.6%
Taylor expanded in a around inf 27.8%
Final simplification27.8%
herbie shell --seed 2024079
(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)))