
(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 10 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 (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 98.0%
associate-+l+98.0%
fma-def98.8%
fma-def99.6%
Simplified99.6%
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 (fma z t (* a b)))))
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 = fma(z, t, (a * b));
}
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 = fma(z, t, Float64(a * b)); end return 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 * t + N[(a * b), $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}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\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 40.0%
+-commutative40.0%
*-commutative40.0%
fma-udef80.0%
Applied egg-rr80.0%
Final simplification99.6%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + fma(x, y, (z * t));
}
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)
\end{array}
Initial program 98.0%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -1e+67)
(* a b)
(if (<= (* a b) -1e-185)
(* z t)
(if (<= (* a b) 4.2e-214)
(* x y)
(if (<= (* a b) 2.05e-88)
(* z t)
(if (<= (* a b) 0.002) (* x y) (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1e+67) {
tmp = a * b;
} else if ((a * b) <= -1e-185) {
tmp = z * t;
} else if ((a * b) <= 4.2e-214) {
tmp = x * y;
} else if ((a * b) <= 2.05e-88) {
tmp = z * t;
} else if ((a * b) <= 0.002) {
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 * b) <= (-1d+67)) then
tmp = a * b
else if ((a * b) <= (-1d-185)) then
tmp = z * t
else if ((a * b) <= 4.2d-214) then
tmp = x * y
else if ((a * b) <= 2.05d-88) then
tmp = z * t
else if ((a * b) <= 0.002d0) 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 * b) <= -1e+67) {
tmp = a * b;
} else if ((a * b) <= -1e-185) {
tmp = z * t;
} else if ((a * b) <= 4.2e-214) {
tmp = x * y;
} else if ((a * b) <= 2.05e-88) {
tmp = z * t;
} else if ((a * b) <= 0.002) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1e+67: tmp = a * b elif (a * b) <= -1e-185: tmp = z * t elif (a * b) <= 4.2e-214: tmp = x * y elif (a * b) <= 2.05e-88: tmp = z * t elif (a * b) <= 0.002: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1e+67) tmp = Float64(a * b); elseif (Float64(a * b) <= -1e-185) tmp = Float64(z * t); elseif (Float64(a * b) <= 4.2e-214) tmp = Float64(x * y); elseif (Float64(a * b) <= 2.05e-88) tmp = Float64(z * t); elseif (Float64(a * b) <= 0.002) 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 * b) <= -1e+67) tmp = a * b; elseif ((a * b) <= -1e-185) tmp = z * t; elseif ((a * b) <= 4.2e-214) tmp = x * y; elseif ((a * b) <= 2.05e-88) tmp = z * t; elseif ((a * b) <= 0.002) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1e+67], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1e-185], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.2e-214], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2.05e-88], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 0.002], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+67}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-185}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{-214}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 2.05 \cdot 10^{-88}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 0.002:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -9.99999999999999983e66 or 2e-3 < (*.f64 a b) Initial program 95.6%
Taylor expanded in a around inf 63.1%
if -9.99999999999999983e66 < (*.f64 a b) < -9.9999999999999999e-186 or 4.19999999999999984e-214 < (*.f64 a b) < 2.0500000000000001e-88Initial program 100.0%
Taylor expanded in z around inf 53.9%
if -9.9999999999999999e-186 < (*.f64 a b) < 4.19999999999999984e-214 or 2.0500000000000001e-88 < (*.f64 a b) < 2e-3Initial program 100.0%
Taylor expanded in x around inf 63.6%
Final simplification60.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= y -6e+37)
(* x y)
(if (or (<= y 8.8e+141)
(and (not (<= y 5.4e+159))
(or (<= y 4.8e+180)
(and (not (<= y 2.1e+235)) (<= y 2.25e+263)))))
(+ (* a b) (* z t))
(* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -6e+37) {
tmp = x * y;
} else if ((y <= 8.8e+141) || (!(y <= 5.4e+159) && ((y <= 4.8e+180) || (!(y <= 2.1e+235) && (y <= 2.25e+263))))) {
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 (y <= (-6d+37)) then
tmp = x * y
else if ((y <= 8.8d+141) .or. (.not. (y <= 5.4d+159)) .and. (y <= 4.8d+180) .or. (.not. (y <= 2.1d+235)) .and. (y <= 2.25d+263)) 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 (y <= -6e+37) {
tmp = x * y;
} else if ((y <= 8.8e+141) || (!(y <= 5.4e+159) && ((y <= 4.8e+180) || (!(y <= 2.1e+235) && (y <= 2.25e+263))))) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -6e+37: tmp = x * y elif (y <= 8.8e+141) or (not (y <= 5.4e+159) and ((y <= 4.8e+180) or (not (y <= 2.1e+235) and (y <= 2.25e+263)))): tmp = (a * b) + (z * t) else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -6e+37) tmp = Float64(x * y); elseif ((y <= 8.8e+141) || (!(y <= 5.4e+159) && ((y <= 4.8e+180) || (!(y <= 2.1e+235) && (y <= 2.25e+263))))) 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 (y <= -6e+37) tmp = x * y; elseif ((y <= 8.8e+141) || (~((y <= 5.4e+159)) && ((y <= 4.8e+180) || (~((y <= 2.1e+235)) && (y <= 2.25e+263))))) tmp = (a * b) + (z * t); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -6e+37], N[(x * y), $MachinePrecision], If[Or[LessEqual[y, 8.8e+141], And[N[Not[LessEqual[y, 5.4e+159]], $MachinePrecision], Or[LessEqual[y, 4.8e+180], And[N[Not[LessEqual[y, 2.1e+235]], $MachinePrecision], LessEqual[y, 2.25e+263]]]]], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+37}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{+141} \lor \neg \left(y \leq 5.4 \cdot 10^{+159}\right) \land \left(y \leq 4.8 \cdot 10^{+180} \lor \neg \left(y \leq 2.1 \cdot 10^{+235}\right) \land y \leq 2.25 \cdot 10^{+263}\right):\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -6.00000000000000043e37 or 8.8e141 < y < 5.40000000000000016e159 or 4.7999999999999997e180 < y < 2.1000000000000001e235 or 2.25000000000000007e263 < y Initial program 95.2%
Taylor expanded in x around inf 63.5%
if -6.00000000000000043e37 < y < 8.8e141 or 5.40000000000000016e159 < y < 4.7999999999999997e180 or 2.1000000000000001e235 < y < 2.25000000000000007e263Initial program 99.4%
Taylor expanded in x around 0 81.6%
Final simplification75.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -1.45e-123) (not (<= t 2.6))) (+ (* a b) (* z t)) (+ (* a b) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -1.45e-123) || !(t <= 2.6)) {
tmp = (a * b) + (z * t);
} else {
tmp = (a * b) + (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 ((t <= (-1.45d-123)) .or. (.not. (t <= 2.6d0))) then
tmp = (a * b) + (z * t)
else
tmp = (a * b) + (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 ((t <= -1.45e-123) || !(t <= 2.6)) {
tmp = (a * b) + (z * t);
} else {
tmp = (a * b) + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (t <= -1.45e-123) or not (t <= 2.6): tmp = (a * b) + (z * t) else: tmp = (a * b) + (x * y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -1.45e-123) || !(t <= 2.6)) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(Float64(a * b) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((t <= -1.45e-123) || ~((t <= 2.6))) tmp = (a * b) + (z * t); else tmp = (a * b) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -1.45e-123], N[Not[LessEqual[t, 2.6]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-123} \lor \neg \left(t \leq 2.6\right):\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\end{array}
\end{array}
if t < -1.45000000000000002e-123 or 2.60000000000000009 < t Initial program 97.3%
Taylor expanded in x around 0 77.5%
if -1.45000000000000002e-123 < t < 2.60000000000000009Initial program 99.1%
Taylor expanded in z around 0 89.6%
Final simplification82.7%
(FPCore (x y z t a b) :precision binary64 (if (<= x -3.1e-17) (+ (* x y) (* z t)) (if (<= x 4.4e-135) (+ (* a b) (* z t)) (+ (* a b) (* x y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -3.1e-17) {
tmp = (x * y) + (z * t);
} else if (x <= 4.4e-135) {
tmp = (a * b) + (z * t);
} else {
tmp = (a * b) + (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 <= (-3.1d-17)) then
tmp = (x * y) + (z * t)
else if (x <= 4.4d-135) then
tmp = (a * b) + (z * t)
else
tmp = (a * b) + (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 <= -3.1e-17) {
tmp = (x * y) + (z * t);
} else if (x <= 4.4e-135) {
tmp = (a * b) + (z * t);
} else {
tmp = (a * b) + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -3.1e-17: tmp = (x * y) + (z * t) elif x <= 4.4e-135: tmp = (a * b) + (z * t) else: tmp = (a * b) + (x * y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -3.1e-17) tmp = Float64(Float64(x * y) + Float64(z * t)); elseif (x <= 4.4e-135) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(Float64(a * b) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -3.1e-17) tmp = (x * y) + (z * t); elseif (x <= 4.4e-135) tmp = (a * b) + (z * t); else tmp = (a * b) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -3.1e-17], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.4e-135], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-17}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-135}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\end{array}
\end{array}
if x < -3.0999999999999998e-17Initial program 97.0%
Taylor expanded in a around 0 82.7%
if -3.0999999999999998e-17 < x < 4.3999999999999999e-135Initial program 100.0%
Taylor expanded in x around 0 90.5%
if 4.3999999999999999e-135 < x Initial program 96.8%
Taylor expanded in z around 0 75.5%
Final simplification82.9%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (+ (* x y) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
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) + ((x * y) + (z * t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
def code(x, y, z, t, a, b): return (a * b) + ((x * y) + (z * t))
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) end
function tmp = code(x, y, z, t, a, b) tmp = (a * b) + ((x * y) + (z * t)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \left(x \cdot y + z \cdot t\right)
\end{array}
Initial program 98.0%
Final simplification98.0%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.46e-123) (* z t) (if (<= t 0.47) (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.46e-123) {
tmp = z * t;
} else if (t <= 0.47) {
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 (t <= (-1.46d-123)) then
tmp = z * t
else if (t <= 0.47d0) 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 (t <= -1.46e-123) {
tmp = z * t;
} else if (t <= 0.47) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.46e-123: tmp = z * t elif t <= 0.47: tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.46e-123) tmp = Float64(z * t); elseif (t <= 0.47) 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 (t <= -1.46e-123) tmp = z * t; elseif (t <= 0.47) tmp = a * b; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.46e-123], N[(z * t), $MachinePrecision], If[LessEqual[t, 0.47], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.46 \cdot 10^{-123}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;t \leq 0.47:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if t < -1.46e-123 or 0.46999999999999997 < t Initial program 97.3%
Taylor expanded in z around inf 52.4%
if -1.46e-123 < t < 0.46999999999999997Initial program 99.1%
Taylor expanded in a around inf 43.4%
Final simplification48.6%
(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 98.0%
Taylor expanded in a around inf 35.7%
Final simplification35.7%
herbie shell --seed 2023238
(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)))