
(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) (+ (* x y) (* z t))) INFINITY) (fma x y (fma a b (* z t))) (* x (+ (+ y (* a (/ b x))) (* t (/ z x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) + ((x * y) + (z * t))) <= ((double) INFINITY)) {
tmp = fma(x, y, fma(a, b, (z * t)));
} else {
tmp = x * ((y + (a * (b / x))) + (t * (z / x)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) <= Inf) tmp = fma(x, y, fma(a, b, Float64(z * t))); else tmp = Float64(x * Float64(Float64(y + Float64(a * Float64(b / x))) + Float64(t * Float64(z / x)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(x * y + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y + N[(a * N[(b / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b + \left(x \cdot y + z \cdot t\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + 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%
associate-+l+100.0%
fma-define100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
fma-define10.0%
Simplified10.0%
Taylor expanded in x around inf 20.0%
associate-+r+20.0%
associate-/l*60.0%
associate-/l*90.0%
Simplified90.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.1%
associate-+l+96.1%
fma-define96.9%
fma-define98.0%
Simplified98.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (* a b) (+ (* x y) (* z t))) INFINITY) (+ (* a b) (fma x y (* z t))) (* x (+ (+ y (* a (/ b x))) (* t (/ z x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) + ((x * y) + (z * t))) <= ((double) INFINITY)) {
tmp = (a * b) + fma(x, y, (z * t));
} else {
tmp = x * ((y + (a * (b / x))) + (t * (z / x)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) <= Inf) tmp = Float64(Float64(a * b) + fma(x, y, Float64(z * t))); else tmp = Float64(x * Float64(Float64(y + Float64(a * Float64(b / x))) + Float64(t * Float64(z / x)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y + N[(a * N[(b / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b + \left(x \cdot y + z \cdot t\right) \leq \infty:\\
\;\;\;\;a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + 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%
fma-define100.0%
Simplified100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
fma-define10.0%
Simplified10.0%
Taylor expanded in x around inf 20.0%
associate-+r+20.0%
associate-/l*60.0%
associate-/l*90.0%
Simplified90.0%
Final simplification99.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (* x (+ (+ y (* a (/ b x))) (* 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 + (a * (b / x))) + (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 + (a * (b / x))) + (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 + (a * (b / x))) + (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(Float64(y + Float64(a * Float64(b / x))) + 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 + (a * (b / x))) + (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[(N[(y + N[(a * N[(b / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 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(\left(y + a \cdot \frac{b}{x}\right) + 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%
fma-define10.0%
Simplified10.0%
Taylor expanded in x around inf 20.0%
associate-+r+20.0%
associate-/l*60.0%
associate-/l*90.0%
Simplified90.0%
Final simplification99.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* a b) (* x y))))
(if (<= (* x y) -9.5e-17)
t_1
(if (<= (* x y) 2e+51)
(+ (* a b) (* z t))
(if (<= (* x y) 8.5e+221) t_1 (* x y))))))
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) <= -9.5e-17) {
tmp = t_1;
} else if ((x * y) <= 2e+51) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 8.5e+221) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = (a * b) + (x * y)
if ((x * y) <= (-9.5d-17)) then
tmp = t_1
else if ((x * y) <= 2d+51) then
tmp = (a * b) + (z * t)
else if ((x * y) <= 8.5d+221) then
tmp = t_1
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 t_1 = (a * b) + (x * y);
double tmp;
if ((x * y) <= -9.5e-17) {
tmp = t_1;
} else if ((x * y) <= 2e+51) {
tmp = (a * b) + (z * t);
} else if ((x * y) <= 8.5e+221) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + (x * y) tmp = 0 if (x * y) <= -9.5e-17: tmp = t_1 elif (x * y) <= 2e+51: tmp = (a * b) + (z * t) elif (x * y) <= 8.5e+221: tmp = t_1 else: tmp = x * y 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) <= -9.5e-17) tmp = t_1; elseif (Float64(x * y) <= 2e+51) tmp = Float64(Float64(a * b) + Float64(z * t)); elseif (Float64(x * y) <= 8.5e+221) tmp = t_1; else tmp = Float64(x * y); 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) <= -9.5e-17) tmp = t_1; elseif ((x * y) <= 2e+51) tmp = (a * b) + (z * t); elseif ((x * y) <= 8.5e+221) 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[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -9.5e-17], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 2e+51], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 8.5e+221], t$95$1, N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
\mathbf{if}\;x \cdot y \leq -9.5 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+51}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 8.5 \cdot 10^{+221}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -9.50000000000000029e-17 or 2e51 < (*.f64 x y) < 8.5000000000000004e221Initial program 96.2%
Taylor expanded in x around inf 88.3%
if -9.50000000000000029e-17 < (*.f64 x y) < 2e51Initial program 99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in x around 0 88.9%
if 8.5000000000000004e221 < (*.f64 x y) Initial program 78.3%
Taylor expanded in x around inf 78.3%
Taylor expanded in x around inf 95.7%
Final simplification89.2%
(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))))
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;
}
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;
}
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 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 * 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 = x * 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[(x * y), $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 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 40.0%
Taylor expanded in x around inf 60.1%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -1e-16) (+ (* a b) (* x y)) (if (<= (* x y) 2e+51) (+ (* a b) (* z t)) (* y (+ x (/ (* a b) y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -1e-16) {
tmp = (a * b) + (x * y);
} else if ((x * y) <= 2e+51) {
tmp = (a * b) + (z * t);
} else {
tmp = y * (x + ((a * b) / 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) <= (-1d-16)) then
tmp = (a * b) + (x * y)
else if ((x * y) <= 2d+51) then
tmp = (a * b) + (z * t)
else
tmp = y * (x + ((a * b) / 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) <= -1e-16) {
tmp = (a * b) + (x * y);
} else if ((x * y) <= 2e+51) {
tmp = (a * b) + (z * t);
} else {
tmp = y * (x + ((a * b) / y));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -1e-16: tmp = (a * b) + (x * y) elif (x * y) <= 2e+51: tmp = (a * b) + (z * t) else: tmp = y * (x + ((a * b) / y)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -1e-16) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(x * y) <= 2e+51) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(y * Float64(x + Float64(Float64(a * b) / y))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -1e-16) tmp = (a * b) + (x * y); elseif ((x * y) <= 2e+51) tmp = (a * b) + (z * t); else tmp = y * (x + ((a * b) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e-16], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+51], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(N[(a * b), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-16}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+51}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + \frac{a \cdot b}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999998e-17Initial program 95.9%
Taylor expanded in x around inf 88.2%
if -9.9999999999999998e-17 < (*.f64 x y) < 2e51Initial program 99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in x around 0 88.9%
if 2e51 < (*.f64 x y) Initial program 89.2%
Taylor expanded in x around inf 84.2%
Taylor expanded in y around inf 84.3%
Final simplification87.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -2e+248) (not (<= (* x y) 1.75e+70))) (* 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) <= -2e+248) || !((x * y) <= 1.75e+70)) {
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) <= (-2d+248)) .or. (.not. ((x * y) <= 1.75d+70))) 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) <= -2e+248) || !((x * y) <= 1.75e+70)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -2e+248) or not ((x * y) <= 1.75e+70): 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) <= -2e+248) || !(Float64(x * y) <= 1.75e+70)) 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) <= -2e+248) || ~(((x * y) <= 1.75e+70))) 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], -2e+248], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.75e+70]], $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 \cdot 10^{+248} \lor \neg \left(x \cdot y \leq 1.75 \cdot 10^{+70}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000009e248 or 1.75000000000000001e70 < (*.f64 x y) Initial program 88.8%
Taylor expanded in x around inf 87.9%
Taylor expanded in x around inf 78.6%
if -2.00000000000000009e248 < (*.f64 x y) < 1.75000000000000001e70Initial program 99.4%
fma-define99.4%
Simplified99.4%
Taylor expanded in x around 0 79.3%
Final simplification79.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -1e+129) (not (<= (* a b) 5e+50))) (* a b) (* x y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -1e+129) || !((a * b) <= 5e+50)) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((a * b) <= (-1d+129)) .or. (.not. ((a * b) <= 5d+50))) then
tmp = a * b
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -1e+129) || !((a * b) <= 5e+50)) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -1e+129) or not ((a * b) <= 5e+50): tmp = a * b else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -1e+129) || !(Float64(a * b) <= 5e+50)) tmp = Float64(a * b); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((a * b) <= -1e+129) || ~(((a * b) <= 5e+50))) tmp = a * b; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -1e+129], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+50]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(x * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+129} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+50}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 a b) < -1e129 or 5e50 < (*.f64 a b) Initial program 92.4%
fma-define92.4%
Simplified92.4%
Taylor expanded in a around inf 71.4%
if -1e129 < (*.f64 a b) < 5e50Initial program 98.6%
Taylor expanded in x around inf 64.8%
Taylor expanded in x around inf 53.6%
Final simplification60.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -2.7e+107) (not (<= (* a b) 3.9e-19))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -2.7e+107) || !((a * b) <= 3.9e-19)) {
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) <= (-2.7d+107)) .or. (.not. ((a * b) <= 3.9d-19))) 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) <= -2.7e+107) || !((a * b) <= 3.9e-19)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -2.7e+107) or not ((a * b) <= 3.9e-19): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -2.7e+107) || !(Float64(a * b) <= 3.9e-19)) 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) <= -2.7e+107) || ~(((a * b) <= 3.9e-19))) 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], -2.7e+107], N[Not[LessEqual[N[(a * b), $MachinePrecision], 3.9e-19]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2.7 \cdot 10^{+107} \lor \neg \left(a \cdot b \leq 3.9 \cdot 10^{-19}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -2.7000000000000001e107 or 3.89999999999999995e-19 < (*.f64 a b) Initial program 93.5%
fma-define93.5%
Simplified93.5%
Taylor expanded in a around inf 65.5%
if -2.7000000000000001e107 < (*.f64 a b) < 3.89999999999999995e-19Initial program 98.5%
fma-define99.2%
Simplified99.2%
Taylor expanded in x around 0 49.3%
Taylor expanded in a around 0 41.1%
Final simplification52.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.1%
fma-define96.5%
Simplified96.5%
Taylor expanded in a around inf 37.2%
herbie shell --seed 2024157
(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)))