
(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) (+ (* z t) (* x y))))) (if (<= t_1 INFINITY) t_1 (fma a b (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(a, b, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(a, b, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, z \cdot t\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 37.5%
fma-def62.5%
Simplified62.5%
Final simplification98.8%
(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-def98.0%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -4.2e+197)
(* a b)
(if (<= (* a b) -2.5e-19)
(* x y)
(if (<= (* a b) -6.2e-130)
(* z t)
(if (<= (* a b) -1.65e-213)
(* x y)
(if (<= (* a b) -5.2e-255)
(* z t)
(if (<= (* a b) 5.6e-247)
(* x y)
(if (<= (* a b) 7.5e-88)
(* z t)
(if (<= (* a b) 8.6e-36)
(* x y)
(if (<= (* a b) 1.45e+148) (* z t) (* a b)))))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -4.2e+197) {
tmp = a * b;
} else if ((a * b) <= -2.5e-19) {
tmp = x * y;
} else if ((a * b) <= -6.2e-130) {
tmp = z * t;
} else if ((a * b) <= -1.65e-213) {
tmp = x * y;
} else if ((a * b) <= -5.2e-255) {
tmp = z * t;
} else if ((a * b) <= 5.6e-247) {
tmp = x * y;
} else if ((a * b) <= 7.5e-88) {
tmp = z * t;
} else if ((a * b) <= 8.6e-36) {
tmp = x * y;
} else if ((a * b) <= 1.45e+148) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * b) <= (-4.2d+197)) then
tmp = a * b
else if ((a * b) <= (-2.5d-19)) then
tmp = x * y
else if ((a * b) <= (-6.2d-130)) then
tmp = z * t
else if ((a * b) <= (-1.65d-213)) then
tmp = x * y
else if ((a * b) <= (-5.2d-255)) then
tmp = z * t
else if ((a * b) <= 5.6d-247) then
tmp = x * y
else if ((a * b) <= 7.5d-88) then
tmp = z * t
else if ((a * b) <= 8.6d-36) then
tmp = x * y
else if ((a * b) <= 1.45d+148) then
tmp = z * t
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -4.2e+197) {
tmp = a * b;
} else if ((a * b) <= -2.5e-19) {
tmp = x * y;
} else if ((a * b) <= -6.2e-130) {
tmp = z * t;
} else if ((a * b) <= -1.65e-213) {
tmp = x * y;
} else if ((a * b) <= -5.2e-255) {
tmp = z * t;
} else if ((a * b) <= 5.6e-247) {
tmp = x * y;
} else if ((a * b) <= 7.5e-88) {
tmp = z * t;
} else if ((a * b) <= 8.6e-36) {
tmp = x * y;
} else if ((a * b) <= 1.45e+148) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -4.2e+197: tmp = a * b elif (a * b) <= -2.5e-19: tmp = x * y elif (a * b) <= -6.2e-130: tmp = z * t elif (a * b) <= -1.65e-213: tmp = x * y elif (a * b) <= -5.2e-255: tmp = z * t elif (a * b) <= 5.6e-247: tmp = x * y elif (a * b) <= 7.5e-88: tmp = z * t elif (a * b) <= 8.6e-36: tmp = x * y elif (a * b) <= 1.45e+148: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -4.2e+197) tmp = Float64(a * b); elseif (Float64(a * b) <= -2.5e-19) tmp = Float64(x * y); elseif (Float64(a * b) <= -6.2e-130) tmp = Float64(z * t); elseif (Float64(a * b) <= -1.65e-213) tmp = Float64(x * y); elseif (Float64(a * b) <= -5.2e-255) tmp = Float64(z * t); elseif (Float64(a * b) <= 5.6e-247) tmp = Float64(x * y); elseif (Float64(a * b) <= 7.5e-88) tmp = Float64(z * t); elseif (Float64(a * b) <= 8.6e-36) tmp = Float64(x * y); elseif (Float64(a * b) <= 1.45e+148) tmp = Float64(z * t); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -4.2e+197) tmp = a * b; elseif ((a * b) <= -2.5e-19) tmp = x * y; elseif ((a * b) <= -6.2e-130) tmp = z * t; elseif ((a * b) <= -1.65e-213) tmp = x * y; elseif ((a * b) <= -5.2e-255) tmp = z * t; elseif ((a * b) <= 5.6e-247) tmp = x * y; elseif ((a * b) <= 7.5e-88) tmp = z * t; elseif ((a * b) <= 8.6e-36) tmp = x * y; elseif ((a * b) <= 1.45e+148) tmp = z * t; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -4.2e+197], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -2.5e-19], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -6.2e-130], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.65e-213], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -5.2e-255], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5.6e-247], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 7.5e-88], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 8.6e-36], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.45e+148], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4.2 \cdot 10^{+197}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -2.5 \cdot 10^{-19}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq -6.2 \cdot 10^{-130}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq -1.65 \cdot 10^{-213}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq -5.2 \cdot 10^{-255}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 5.6 \cdot 10^{-247}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 7.5 \cdot 10^{-88}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 8.6 \cdot 10^{-36}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 1.45 \cdot 10^{+148}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -4.20000000000000013e197 or 1.45e148 < (*.f64 a b) Initial program 89.7%
Taylor expanded in a around inf 81.8%
if -4.20000000000000013e197 < (*.f64 a b) < -2.5000000000000002e-19 or -6.20000000000000021e-130 < (*.f64 a b) < -1.65000000000000016e-213 or -5.20000000000000041e-255 < (*.f64 a b) < 5.59999999999999973e-247 or 7.50000000000000041e-88 < (*.f64 a b) < 8.6000000000000004e-36Initial program 100.0%
Taylor expanded in x around inf 62.6%
if -2.5000000000000002e-19 < (*.f64 a b) < -6.20000000000000021e-130 or -1.65000000000000016e-213 < (*.f64 a b) < -5.20000000000000041e-255 or 5.59999999999999973e-247 < (*.f64 a b) < 7.50000000000000041e-88 or 8.6000000000000004e-36 < (*.f64 a b) < 1.45e148Initial program 100.0%
Taylor expanded in z around inf 62.1%
Final simplification68.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* z t) (* x y))))) (if (<= t_1 INFINITY) t_1 (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = a * b;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + ((z * t) + (x * y)) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = a * b return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + ((z * t) + (x * y)); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\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 inf 50.0%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -1.5e-19) (+ (* a b) (* x y)) (if (<= (* a b) 2.3e+24) (+ (* z t) (* x y)) (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.5e-19) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 2.3e+24) {
tmp = (z * t) + (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 ((a * b) <= (-1.5d-19)) then
tmp = (a * b) + (x * y)
else if ((a * b) <= 2.3d+24) then
tmp = (z * t) + (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 ((a * b) <= -1.5e-19) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 2.3e+24) {
tmp = (z * t) + (x * y);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1.5e-19: tmp = (a * b) + (x * y) elif (a * b) <= 2.3e+24: tmp = (z * t) + (x * y) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1.5e-19) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(a * b) <= 2.3e+24) tmp = Float64(Float64(z * t) + 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 ((a * b) <= -1.5e-19) tmp = (a * b) + (x * y); elseif ((a * b) <= 2.3e+24) tmp = (z * t) + (x * y); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1.5e-19], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2.3e+24], N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.5 \cdot 10^{-19}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 2.3 \cdot 10^{+24}:\\
\;\;\;\;z \cdot t + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.49999999999999996e-19Initial program 96.1%
Taylor expanded in z around 0 84.5%
if -1.49999999999999996e-19 < (*.f64 a b) < 2.2999999999999999e24Initial program 100.0%
Taylor expanded in a around 0 91.2%
if 2.2999999999999999e24 < (*.f64 a b) Initial program 89.4%
Taylor expanded in x around 0 83.8%
Final simplification87.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -7e+144) (not (<= x 1.5e-157))) (+ (* 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 <= -7e+144) || !(x <= 1.5e-157)) {
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 <= (-7d+144)) .or. (.not. (x <= 1.5d-157))) 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 <= -7e+144) || !(x <= 1.5e-157)) {
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 <= -7e+144) or not (x <= 1.5e-157): 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 ((x <= -7e+144) || !(x <= 1.5e-157)) 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 <= -7e+144) || ~((x <= 1.5e-157))) 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[x, -7e+144], N[Not[LessEqual[x, 1.5e-157]], $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 \leq -7 \cdot 10^{+144} \lor \neg \left(x \leq 1.5 \cdot 10^{-157}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if x < -6.9999999999999996e144 or 1.5e-157 < x Initial program 95.4%
Taylor expanded in z around 0 76.5%
if -6.9999999999999996e144 < x < 1.5e-157Initial program 98.4%
Taylor expanded in x around 0 81.2%
Final simplification78.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -1.7e-19) (* a b) (if (<= (* a b) 5.3e+150) (* z t) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.7e-19) {
tmp = a * b;
} else if ((a * b) <= 5.3e+150) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * b) <= (-1.7d-19)) then
tmp = a * b
else if ((a * b) <= 5.3d+150) then
tmp = z * t
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.7e-19) {
tmp = a * b;
} else if ((a * b) <= 5.3e+150) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1.7e-19: tmp = a * b elif (a * b) <= 5.3e+150: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1.7e-19) tmp = Float64(a * b); elseif (Float64(a * b) <= 5.3e+150) tmp = Float64(z * t); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -1.7e-19) tmp = a * b; elseif ((a * b) <= 5.3e+150) tmp = z * t; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1.7e-19], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5.3e+150], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.7 \cdot 10^{-19}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 5.3 \cdot 10^{+150}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -1.7000000000000001e-19 or 5.30000000000000013e150 < (*.f64 a b) Initial program 92.9%
Taylor expanded in a around inf 65.7%
if -1.7000000000000001e-19 < (*.f64 a b) < 5.30000000000000013e150Initial program 100.0%
Taylor expanded in z around inf 47.3%
Final simplification55.4%
(FPCore (x y z t a b) :precision binary64 (if (<= x -8.5e+156) (* x y) (if (<= x 1.46e-16) (+ (* a b) (* z t)) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -8.5e+156) {
tmp = x * y;
} else if (x <= 1.46e-16) {
tmp = (a * b) + (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 <= (-8.5d+156)) then
tmp = x * y
else if (x <= 1.46d-16) then
tmp = (a * b) + (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 <= -8.5e+156) {
tmp = x * y;
} else if (x <= 1.46e-16) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -8.5e+156: tmp = x * y elif x <= 1.46e-16: tmp = (a * b) + (z * t) else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -8.5e+156) tmp = Float64(x * y); elseif (x <= 1.46e-16) tmp = Float64(Float64(a * b) + 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 <= -8.5e+156) tmp = x * y; elseif (x <= 1.46e-16) tmp = (a * b) + (z * t); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -8.5e+156], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.46e-16], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+156}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.46 \cdot 10^{-16}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -8.49999999999999948e156 or 1.4600000000000001e-16 < x Initial program 95.0%
Taylor expanded in x around inf 61.7%
if -8.49999999999999948e156 < x < 1.4600000000000001e-16Initial program 98.1%
Taylor expanded in x around 0 80.0%
Final simplification72.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 36.2%
Final simplification36.2%
herbie shell --seed 2023257
(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)))