
(FPCore (x y z t a b) :precision binary64 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * 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 * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
def code(x, y, z, t, a, b): return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \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 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * 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 * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
def code(x, y, z, t, a, b): return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= z -5e-137) (fma a (* 27.0 b) (fma x 2.0 (* y (* t (* z -9.0))))) (+ (- (* x 2.0) (* t (* z (* y 9.0)))) (* b (* a 27.0)))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -5e-137) {
tmp = fma(a, (27.0 * b), fma(x, 2.0, (y * (t * (z * -9.0)))));
} else {
tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
}
return tmp;
}
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -5e-137) tmp = fma(a, Float64(27.0 * b), fma(x, 2.0, Float64(y * Float64(t * Float64(z * -9.0))))); else tmp = Float64(Float64(Float64(x * 2.0) - Float64(t * Float64(z * Float64(y * 9.0)))) + Float64(b * Float64(a * 27.0))); end return tmp end
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5e-137], N[(a * N[(27.0 * b), $MachinePrecision] + N[(x * 2.0 + N[(y * N[(t * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t * N[(z * N[(y * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + b \cdot \left(a \cdot 27\right)\\
\end{array}
\end{array}
if z < -5.00000000000000001e-137Initial program 95.9%
+-commutative95.9%
associate-+r-95.9%
cancel-sign-sub-inv95.9%
*-commutative95.9%
distribute-rgt-neg-out95.9%
associate-*r*97.8%
*-commutative97.8%
distribute-rgt-neg-in97.8%
associate-+r+97.8%
sub-neg97.8%
associate-*l*97.8%
fma-def97.8%
fma-neg97.8%
associate-*l*97.8%
*-commutative97.8%
associate-*r*95.8%
distribute-rgt-neg-in95.8%
Simplified95.9%
if -5.00000000000000001e-137 < z Initial program 98.0%
Final simplification97.2%
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (* a 27.0))) (t_2 (* t (* z y))))
(if (or (<= t_1 -2e+101)
(not (or (<= t_1 7e-80) (and (not (<= t_1 5e-46)) (<= t_1 4e+98)))))
(+ t_1 (* -9.0 t_2))
(- (* x 2.0) (* 9.0 t_2)))))assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a * 27.0);
double t_2 = t * (z * y);
double tmp;
if ((t_1 <= -2e+101) || !((t_1 <= 7e-80) || (!(t_1 <= 5e-46) && (t_1 <= 4e+98)))) {
tmp = t_1 + (-9.0 * t_2);
} else {
tmp = (x * 2.0) - (9.0 * t_2);
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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) :: t_2
real(8) :: tmp
t_1 = b * (a * 27.0d0)
t_2 = t * (z * y)
if ((t_1 <= (-2d+101)) .or. (.not. (t_1 <= 7d-80) .or. (.not. (t_1 <= 5d-46)) .and. (t_1 <= 4d+98))) then
tmp = t_1 + ((-9.0d0) * t_2)
else
tmp = (x * 2.0d0) - (9.0d0 * t_2)
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a * 27.0);
double t_2 = t * (z * y);
double tmp;
if ((t_1 <= -2e+101) || !((t_1 <= 7e-80) || (!(t_1 <= 5e-46) && (t_1 <= 4e+98)))) {
tmp = t_1 + (-9.0 * t_2);
} else {
tmp = (x * 2.0) - (9.0 * t_2);
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): t_1 = b * (a * 27.0) t_2 = t * (z * y) tmp = 0 if (t_1 <= -2e+101) or not ((t_1 <= 7e-80) or (not (t_1 <= 5e-46) and (t_1 <= 4e+98))): tmp = t_1 + (-9.0 * t_2) else: tmp = (x * 2.0) - (9.0 * t_2) return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a * 27.0)) t_2 = Float64(t * Float64(z * y)) tmp = 0.0 if ((t_1 <= -2e+101) || !((t_1 <= 7e-80) || (!(t_1 <= 5e-46) && (t_1 <= 4e+98)))) tmp = Float64(t_1 + Float64(-9.0 * t_2)); else tmp = Float64(Float64(x * 2.0) - Float64(9.0 * t_2)); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = b * (a * 27.0);
t_2 = t * (z * y);
tmp = 0.0;
if ((t_1 <= -2e+101) || ~(((t_1 <= 7e-80) || (~((t_1 <= 5e-46)) && (t_1 <= 4e+98)))))
tmp = t_1 + (-9.0 * t_2);
else
tmp = (x * 2.0) - (9.0 * t_2);
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+101], N[Not[Or[LessEqual[t$95$1, 7e-80], And[N[Not[LessEqual[t$95$1, 5e-46]], $MachinePrecision], LessEqual[t$95$1, 4e+98]]]], $MachinePrecision]], N[(t$95$1 + N[(-9.0 * t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot 27\right)\\
t_2 := t \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 7 \cdot 10^{-80} \lor \neg \left(t_1 \leq 5 \cdot 10^{-46}\right) \land t_1 \leq 4 \cdot 10^{+98}\right):\\
\;\;\;\;t_1 + -9 \cdot t_2\\
\mathbf{else}:\\
\;\;\;\;x \cdot 2 - 9 \cdot t_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 a 27) b) < -2e101 or 7.00000000000000029e-80 < (*.f64 (*.f64 a 27) b) < 4.99999999999999992e-46 or 3.99999999999999999e98 < (*.f64 (*.f64 a 27) b) Initial program 97.6%
pow197.6%
associate-*l*97.6%
Applied egg-rr97.6%
Taylor expanded in x around 0 92.2%
associate-*r*92.1%
*-commutative92.1%
associate-*l*93.2%
Simplified93.2%
if -2e101 < (*.f64 (*.f64 a 27) b) < 7.00000000000000029e-80 or 4.99999999999999992e-46 < (*.f64 (*.f64 a 27) b) < 3.99999999999999999e98Initial program 96.9%
sub-neg96.9%
distribute-lft-neg-in96.9%
associate-*l*97.0%
*-commutative97.0%
*-commutative97.0%
cancel-sign-sub-inv97.0%
*-commutative97.0%
*-commutative97.0%
associate-*l*96.9%
associate-*l*94.7%
associate-*l*94.7%
Simplified94.7%
Taylor expanded in a around 0 86.7%
expm1-log1p-u63.2%
expm1-udef59.4%
*-commutative59.4%
Applied egg-rr59.4%
expm1-def63.2%
expm1-log1p86.7%
*-commutative86.7%
*-commutative86.7%
associate-*l*88.7%
*-commutative88.7%
Simplified88.7%
Final simplification90.3%
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* t (* z y)))
(t_2 (* b (* a 27.0)))
(t_3 (- (* x 2.0) (* 9.0 t_1)))
(t_4 (+ (* a (* 27.0 b)) (* y (* -9.0 (* z t))))))
(if (<= t_2 -2e+101)
t_4
(if (<= t_2 7e-80)
t_3
(if (<= t_2 5e-39) t_4 (if (<= t_2 4e+98) t_3 (+ t_2 (* -9.0 t_1))))))))assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = t * (z * y);
double t_2 = b * (a * 27.0);
double t_3 = (x * 2.0) - (9.0 * t_1);
double t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)));
double tmp;
if (t_2 <= -2e+101) {
tmp = t_4;
} else if (t_2 <= 7e-80) {
tmp = t_3;
} else if (t_2 <= 5e-39) {
tmp = t_4;
} else if (t_2 <= 4e+98) {
tmp = t_3;
} else {
tmp = t_2 + (-9.0 * t_1);
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_1 = t * (z * y)
t_2 = b * (a * 27.0d0)
t_3 = (x * 2.0d0) - (9.0d0 * t_1)
t_4 = (a * (27.0d0 * b)) + (y * ((-9.0d0) * (z * t)))
if (t_2 <= (-2d+101)) then
tmp = t_4
else if (t_2 <= 7d-80) then
tmp = t_3
else if (t_2 <= 5d-39) then
tmp = t_4
else if (t_2 <= 4d+98) then
tmp = t_3
else
tmp = t_2 + ((-9.0d0) * t_1)
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = t * (z * y);
double t_2 = b * (a * 27.0);
double t_3 = (x * 2.0) - (9.0 * t_1);
double t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)));
double tmp;
if (t_2 <= -2e+101) {
tmp = t_4;
} else if (t_2 <= 7e-80) {
tmp = t_3;
} else if (t_2 <= 5e-39) {
tmp = t_4;
} else if (t_2 <= 4e+98) {
tmp = t_3;
} else {
tmp = t_2 + (-9.0 * t_1);
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): t_1 = t * (z * y) t_2 = b * (a * 27.0) t_3 = (x * 2.0) - (9.0 * t_1) t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t))) tmp = 0 if t_2 <= -2e+101: tmp = t_4 elif t_2 <= 7e-80: tmp = t_3 elif t_2 <= 5e-39: tmp = t_4 elif t_2 <= 4e+98: tmp = t_3 else: tmp = t_2 + (-9.0 * t_1) return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) t_1 = Float64(t * Float64(z * y)) t_2 = Float64(b * Float64(a * 27.0)) t_3 = Float64(Float64(x * 2.0) - Float64(9.0 * t_1)) t_4 = Float64(Float64(a * Float64(27.0 * b)) + Float64(y * Float64(-9.0 * Float64(z * t)))) tmp = 0.0 if (t_2 <= -2e+101) tmp = t_4; elseif (t_2 <= 7e-80) tmp = t_3; elseif (t_2 <= 5e-39) tmp = t_4; elseif (t_2 <= 4e+98) tmp = t_3; else tmp = Float64(t_2 + Float64(-9.0 * t_1)); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = t * (z * y);
t_2 = b * (a * 27.0);
t_3 = (x * 2.0) - (9.0 * t_1);
t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)));
tmp = 0.0;
if (t_2 <= -2e+101)
tmp = t_4;
elseif (t_2 <= 7e-80)
tmp = t_3;
elseif (t_2 <= 5e-39)
tmp = t_4;
elseif (t_2 <= 4e+98)
tmp = t_3;
else
tmp = t_2 + (-9.0 * t_1);
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+101], t$95$4, If[LessEqual[t$95$2, 7e-80], t$95$3, If[LessEqual[t$95$2, 5e-39], t$95$4, If[LessEqual[t$95$2, 4e+98], t$95$3, N[(t$95$2 + N[(-9.0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := t \cdot \left(z \cdot y\right)\\
t_2 := b \cdot \left(a \cdot 27\right)\\
t_3 := x \cdot 2 - 9 \cdot t_1\\
t_4 := a \cdot \left(27 \cdot b\right) + y \cdot \left(-9 \cdot \left(z \cdot t\right)\right)\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+101}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_2 \leq 7 \cdot 10^{-80}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-39}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+98}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2 + -9 \cdot t_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 a 27) b) < -2e101 or 7.00000000000000029e-80 < (*.f64 (*.f64 a 27) b) < 4.9999999999999998e-39Initial program 99.7%
sub-neg99.7%
distribute-lft-neg-in99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l*97.9%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in x around 0 96.0%
*-commutative96.0%
*-commutative96.0%
associate-*r*96.0%
*-commutative96.0%
*-commutative96.0%
Simplified96.0%
if -2e101 < (*.f64 (*.f64 a 27) b) < 7.00000000000000029e-80 or 4.9999999999999998e-39 < (*.f64 (*.f64 a 27) b) < 3.99999999999999999e98Initial program 96.9%
sub-neg96.9%
distribute-lft-neg-in96.9%
associate-*l*96.9%
*-commutative96.9%
*-commutative96.9%
cancel-sign-sub-inv96.9%
*-commutative96.9%
*-commutative96.9%
associate-*l*96.9%
associate-*l*94.6%
associate-*l*94.6%
Simplified94.6%
Taylor expanded in a around 0 86.6%
expm1-log1p-u62.9%
expm1-udef59.4%
*-commutative59.4%
Applied egg-rr59.4%
expm1-def62.9%
expm1-log1p86.6%
*-commutative86.6%
*-commutative86.6%
associate-*l*88.6%
*-commutative88.6%
Simplified88.6%
if 3.99999999999999999e98 < (*.f64 (*.f64 a 27) b) Initial program 95.2%
pow195.2%
associate-*l*95.1%
Applied egg-rr95.1%
Taylor expanded in x around 0 87.6%
associate-*r*89.9%
*-commutative89.9%
associate-*l*87.6%
Simplified87.6%
Final simplification89.9%
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (* a 27.0))))
(if (or (<= t_1 -2e+101) (not (<= t_1 2e+137)))
(+ (* x 2.0) (* 27.0 (* a b)))
(+ (* x 2.0) (* y (* t (* z -9.0)))))))assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a * 27.0);
double tmp;
if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
tmp = (x * 2.0) + (27.0 * (a * b));
} else {
tmp = (x * 2.0) + (y * (t * (z * -9.0)));
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b * (a * 27.0d0)
if ((t_1 <= (-2d+101)) .or. (.not. (t_1 <= 2d+137))) then
tmp = (x * 2.0d0) + (27.0d0 * (a * b))
else
tmp = (x * 2.0d0) + (y * (t * (z * (-9.0d0))))
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a * 27.0);
double tmp;
if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
tmp = (x * 2.0) + (27.0 * (a * b));
} else {
tmp = (x * 2.0) + (y * (t * (z * -9.0)));
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): t_1 = b * (a * 27.0) tmp = 0 if (t_1 <= -2e+101) or not (t_1 <= 2e+137): tmp = (x * 2.0) + (27.0 * (a * b)) else: tmp = (x * 2.0) + (y * (t * (z * -9.0))) return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a * 27.0)) tmp = 0.0 if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) tmp = Float64(Float64(x * 2.0) + Float64(27.0 * Float64(a * b))); else tmp = Float64(Float64(x * 2.0) + Float64(y * Float64(t * Float64(z * -9.0)))); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = b * (a * 27.0);
tmp = 0.0;
if ((t_1 <= -2e+101) || ~((t_1 <= 2e+137)))
tmp = (x * 2.0) + (27.0 * (a * b));
else
tmp = (x * 2.0) + (y * (t * (z * -9.0)));
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+101], N[Not[LessEqual[t$95$1, 2e+137]], $MachinePrecision]], N[(N[(x * 2.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] + N[(y * N[(t * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot 27\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 2 \cdot 10^{+137}\right):\\
\;\;\;\;x \cdot 2 + 27 \cdot \left(a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 2 + y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 a 27) b) < -2e101 or 2.0000000000000001e137 < (*.f64 (*.f64 a 27) b) Initial program 98.4%
sub-neg98.4%
distribute-lft-neg-in98.4%
associate-*l*98.4%
*-commutative98.4%
*-commutative98.4%
cancel-sign-sub-inv98.4%
*-commutative98.4%
*-commutative98.4%
associate-*l*98.4%
associate-*l*96.0%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in y around 0 88.6%
if -2e101 < (*.f64 (*.f64 a 27) b) < 2.0000000000000001e137Initial program 96.7%
sub-neg96.7%
distribute-lft-neg-in96.7%
associate-*l*96.7%
*-commutative96.7%
*-commutative96.7%
cancel-sign-sub-inv96.7%
*-commutative96.7%
*-commutative96.7%
associate-*l*96.7%
associate-*l*95.1%
associate-*l*95.1%
Simplified95.1%
Taylor expanded in a around 0 83.6%
expm1-log1p-u60.7%
expm1-udef57.1%
*-commutative57.1%
Applied egg-rr57.1%
expm1-def60.7%
expm1-log1p83.6%
*-commutative83.6%
*-commutative83.6%
associate-*l*84.9%
*-commutative84.9%
Simplified84.9%
cancel-sign-sub-inv84.9%
*-commutative84.9%
metadata-eval84.9%
*-commutative84.9%
associate-*r*83.9%
*-commutative83.9%
associate-*r*83.9%
associate-*l*83.7%
Applied egg-rr83.7%
Final simplification85.1%
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (* a 27.0))))
(if (or (<= t_1 -2e+101) (not (<= t_1 2e+137)))
(+ (* x 2.0) (* 27.0 (* a b)))
(- (* x 2.0) (* 9.0 (* t (* z y)))))))assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a * 27.0);
double tmp;
if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
tmp = (x * 2.0) + (27.0 * (a * b));
} else {
tmp = (x * 2.0) - (9.0 * (t * (z * y)));
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b * (a * 27.0d0)
if ((t_1 <= (-2d+101)) .or. (.not. (t_1 <= 2d+137))) then
tmp = (x * 2.0d0) + (27.0d0 * (a * b))
else
tmp = (x * 2.0d0) - (9.0d0 * (t * (z * y)))
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a * 27.0);
double tmp;
if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
tmp = (x * 2.0) + (27.0 * (a * b));
} else {
tmp = (x * 2.0) - (9.0 * (t * (z * y)));
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): t_1 = b * (a * 27.0) tmp = 0 if (t_1 <= -2e+101) or not (t_1 <= 2e+137): tmp = (x * 2.0) + (27.0 * (a * b)) else: tmp = (x * 2.0) - (9.0 * (t * (z * y))) return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a * 27.0)) tmp = 0.0 if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) tmp = Float64(Float64(x * 2.0) + Float64(27.0 * Float64(a * b))); else tmp = Float64(Float64(x * 2.0) - Float64(9.0 * Float64(t * Float64(z * y)))); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = b * (a * 27.0);
tmp = 0.0;
if ((t_1 <= -2e+101) || ~((t_1 <= 2e+137)))
tmp = (x * 2.0) + (27.0 * (a * b));
else
tmp = (x * 2.0) - (9.0 * (t * (z * y)));
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+101], N[Not[LessEqual[t$95$1, 2e+137]], $MachinePrecision]], N[(N[(x * 2.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * N[(t * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot 27\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 2 \cdot 10^{+137}\right):\\
\;\;\;\;x \cdot 2 + 27 \cdot \left(a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 a 27) b) < -2e101 or 2.0000000000000001e137 < (*.f64 (*.f64 a 27) b) Initial program 98.4%
sub-neg98.4%
distribute-lft-neg-in98.4%
associate-*l*98.4%
*-commutative98.4%
*-commutative98.4%
cancel-sign-sub-inv98.4%
*-commutative98.4%
*-commutative98.4%
associate-*l*98.4%
associate-*l*96.0%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in y around 0 88.6%
if -2e101 < (*.f64 (*.f64 a 27) b) < 2.0000000000000001e137Initial program 96.7%
sub-neg96.7%
distribute-lft-neg-in96.7%
associate-*l*96.7%
*-commutative96.7%
*-commutative96.7%
cancel-sign-sub-inv96.7%
*-commutative96.7%
*-commutative96.7%
associate-*l*96.7%
associate-*l*95.1%
associate-*l*95.1%
Simplified95.1%
Taylor expanded in a around 0 83.6%
expm1-log1p-u60.7%
expm1-udef57.1%
*-commutative57.1%
Applied egg-rr57.1%
expm1-def60.7%
expm1-log1p83.6%
*-commutative83.6%
*-commutative83.6%
associate-*l*84.9%
*-commutative84.9%
Simplified84.9%
Final simplification86.0%
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* a (* 27.0 b))))
(if (<= (* y 9.0) -5e-40)
(+ t_1 (- (* x 2.0) (* (* y 9.0) (* z t))))
(+ t_1 (+ (* x 2.0) (* z (* y (* t -9.0))))))))assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * (27.0 * b);
double tmp;
if ((y * 9.0) <= -5e-40) {
tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)));
} else {
tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))));
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 * (27.0d0 * b)
if ((y * 9.0d0) <= (-5d-40)) then
tmp = t_1 + ((x * 2.0d0) - ((y * 9.0d0) * (z * t)))
else
tmp = t_1 + ((x * 2.0d0) + (z * (y * (t * (-9.0d0)))))
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * (27.0 * b);
double tmp;
if ((y * 9.0) <= -5e-40) {
tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)));
} else {
tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))));
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): t_1 = a * (27.0 * b) tmp = 0 if (y * 9.0) <= -5e-40: tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t))) else: tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0)))) return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) t_1 = Float64(a * Float64(27.0 * b)) tmp = 0.0 if (Float64(y * 9.0) <= -5e-40) tmp = Float64(t_1 + Float64(Float64(x * 2.0) - Float64(Float64(y * 9.0) * Float64(z * t)))); else tmp = Float64(t_1 + Float64(Float64(x * 2.0) + Float64(z * Float64(y * Float64(t * -9.0))))); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = a * (27.0 * b);
tmp = 0.0;
if ((y * 9.0) <= -5e-40)
tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)));
else
tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))));
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * 9.0), $MachinePrecision], -5e-40], N[(t$95$1 + N[(N[(x * 2.0), $MachinePrecision] - N[(N[(y * 9.0), $MachinePrecision] * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(x * 2.0), $MachinePrecision] + N[(z * N[(y * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := a \cdot \left(27 \cdot b\right)\\
\mathbf{if}\;y \cdot 9 \leq -5 \cdot 10^{-40}:\\
\;\;\;\;t_1 + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(x \cdot 2 + z \cdot \left(y \cdot \left(t \cdot -9\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 y 9) < -4.99999999999999965e-40Initial program 95.0%
sub-neg95.0%
distribute-lft-neg-in95.0%
associate-*l*95.0%
*-commutative95.0%
*-commutative95.0%
cancel-sign-sub-inv95.0%
*-commutative95.0%
*-commutative95.0%
associate-*l*95.0%
associate-*l*97.4%
associate-*l*97.4%
Simplified97.4%
if -4.99999999999999965e-40 < (*.f64 y 9) Initial program 98.1%
+-commutative98.1%
associate-+r-98.1%
cancel-sign-sub-inv98.1%
*-commutative98.1%
distribute-rgt-neg-out98.1%
associate-*r*96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
associate-+r+96.1%
sub-neg96.1%
+-commutative96.1%
associate-+l-96.1%
fma-neg96.1%
associate-*l*94.4%
fma-neg94.4%
*-commutative94.4%
fma-neg94.4%
Simplified96.1%
fma-udef96.1%
fma-udef96.1%
associate-*r*96.1%
associate-+r+96.1%
Applied egg-rr96.1%
Final simplification96.5%
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= t 230000000.0) (+ (+ (* x 2.0) (* a (* 27.0 b))) (* (* y t) (* z -9.0))) (+ (- (* x 2.0) (* t (* z (* y 9.0)))) (* b (* a 27.0)))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 230000000.0) {
tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
} else {
tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 <= 230000000.0d0) then
tmp = ((x * 2.0d0) + (a * (27.0d0 * b))) + ((y * t) * (z * (-9.0d0)))
else
tmp = ((x * 2.0d0) - (t * (z * (y * 9.0d0)))) + (b * (a * 27.0d0))
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 230000000.0) {
tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
} else {
tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): tmp = 0 if t <= 230000000.0: tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0)) else: tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0)) return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 230000000.0) tmp = Float64(Float64(Float64(x * 2.0) + Float64(a * Float64(27.0 * b))) + Float64(Float64(y * t) * Float64(z * -9.0))); else tmp = Float64(Float64(Float64(x * 2.0) - Float64(t * Float64(z * Float64(y * 9.0)))) + Float64(b * Float64(a * 27.0))); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
tmp = 0.0;
if (t <= 230000000.0)
tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
else
tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 230000000.0], N[(N[(N[(x * 2.0), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * t), $MachinePrecision] * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t * N[(z * N[(y * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 230000000:\\
\;\;\;\;\left(x \cdot 2 + a \cdot \left(27 \cdot b\right)\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + b \cdot \left(a \cdot 27\right)\\
\end{array}
\end{array}
if t < 2.3e8Initial program 96.0%
+-commutative96.0%
associate-+r-96.0%
cancel-sign-sub-inv96.0%
*-commutative96.0%
distribute-rgt-neg-out96.0%
associate-*r*96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
associate-+r+96.1%
sub-neg96.1%
associate-*l*96.1%
fma-def96.1%
fma-neg96.1%
associate-*l*96.1%
*-commutative96.1%
associate-*r*96.1%
distribute-rgt-neg-in96.1%
Simplified96.2%
fma-udef96.2%
fma-udef96.2%
associate-+r+96.2%
associate-*r*96.1%
*-commutative96.1%
Applied egg-rr96.1%
if 2.3e8 < t Initial program 99.8%
Final simplification97.2%
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (+ (+ (* x 2.0) (* a (* 27.0 b))) (* (* y t) (* z -9.0))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 * 2.0d0) + (a * (27.0d0 * b))) + ((y * t) * (z * (-9.0d0)))
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): return ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0))
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) + Float64(a * Float64(27.0 * b))) + Float64(Float64(y * t) * Float64(z * -9.0))) end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp = code(x, y, z, t, a, b)
tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
end
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * t), $MachinePrecision] * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(x \cdot 2 + a \cdot \left(27 \cdot b\right)\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)
\end{array}
Initial program 97.2%
+-commutative97.2%
associate-+r-97.2%
cancel-sign-sub-inv97.2%
*-commutative97.2%
distribute-rgt-neg-out97.2%
associate-*r*96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
associate-+r+96.1%
sub-neg96.1%
associate-*l*96.1%
fma-def96.1%
fma-neg96.1%
associate-*l*96.1%
*-commutative96.1%
associate-*r*95.3%
distribute-rgt-neg-in95.3%
Simplified95.4%
fma-udef95.4%
fma-udef95.4%
associate-+r+95.4%
associate-*r*96.1%
*-commutative96.1%
Applied egg-rr96.1%
Final simplification96.1%
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (or (<= b -1.15e-62) (not (<= b 4.5e+59))) (* 27.0 (* a b)) (* x 2.0)))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((b <= -1.15e-62) || !(b <= 4.5e+59)) {
tmp = 27.0 * (a * b);
} else {
tmp = x * 2.0;
}
return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 ((b <= (-1.15d-62)) .or. (.not. (b <= 4.5d+59))) then
tmp = 27.0d0 * (a * b)
else
tmp = x * 2.0d0
end if
code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((b <= -1.15e-62) || !(b <= 4.5e+59)) {
tmp = 27.0 * (a * b);
} else {
tmp = x * 2.0;
}
return tmp;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): tmp = 0 if (b <= -1.15e-62) or not (b <= 4.5e+59): tmp = 27.0 * (a * b) else: tmp = x * 2.0 return tmp
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if ((b <= -1.15e-62) || !(b <= 4.5e+59)) tmp = Float64(27.0 * Float64(a * b)); else tmp = Float64(x * 2.0); end return tmp end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
tmp = 0.0;
if ((b <= -1.15e-62) || ~((b <= 4.5e+59)))
tmp = 27.0 * (a * b);
else
tmp = x * 2.0;
end
tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[b, -1.15e-62], N[Not[LessEqual[b, 4.5e+59]], $MachinePrecision]], N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision], N[(x * 2.0), $MachinePrecision]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-62} \lor \neg \left(b \leq 4.5 \cdot 10^{+59}\right):\\
\;\;\;\;27 \cdot \left(a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 2\\
\end{array}
\end{array}
if b < -1.15e-62 or 4.49999999999999959e59 < b Initial program 98.2%
+-commutative98.2%
associate-+r-98.2%
cancel-sign-sub-inv98.2%
*-commutative98.2%
distribute-rgt-neg-out98.2%
associate-*r*95.3%
*-commutative95.3%
distribute-rgt-neg-in95.3%
associate-+r+95.3%
sub-neg95.3%
associate-*l*95.3%
fma-def95.4%
fma-neg95.4%
associate-*l*95.4%
*-commutative95.4%
associate-*r*95.3%
distribute-rgt-neg-in95.3%
Simplified95.3%
fma-udef95.3%
fma-udef95.3%
associate-+r+95.3%
associate-*r*95.4%
*-commutative95.4%
Applied egg-rr95.4%
Taylor expanded in a around inf 56.1%
if -1.15e-62 < b < 4.49999999999999959e59Initial program 96.2%
+-commutative96.2%
associate-+r-96.2%
cancel-sign-sub-inv96.2%
*-commutative96.2%
distribute-rgt-neg-out96.2%
associate-*r*96.9%
*-commutative96.9%
distribute-rgt-neg-in96.9%
associate-+r+96.9%
sub-neg96.9%
associate-*l*96.9%
fma-def96.9%
fma-neg96.9%
associate-*l*96.9%
*-commutative96.9%
associate-*r*95.3%
distribute-rgt-neg-in95.3%
Simplified95.5%
fma-udef95.5%
fma-udef95.5%
associate-+r+95.5%
associate-*r*96.9%
*-commutative96.9%
Applied egg-rr96.9%
Taylor expanded in x around inf 41.0%
Final simplification48.4%
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (+ (* x 2.0) (* 27.0 (* a b))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
return (x * 2.0) + (27.0 * (a * b));
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 * 2.0d0) + (27.0d0 * (a * b))
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
return (x * 2.0) + (27.0 * (a * b));
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): return (x * 2.0) + (27.0 * (a * b))
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) return Float64(Float64(x * 2.0) + Float64(27.0 * Float64(a * b))) end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp = code(x, y, z, t, a, b)
tmp = (x * 2.0) + (27.0 * (a * b));
end
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(N[(x * 2.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
x \cdot 2 + 27 \cdot \left(a \cdot b\right)
\end{array}
Initial program 97.2%
sub-neg97.2%
distribute-lft-neg-in97.2%
associate-*l*97.2%
*-commutative97.2%
*-commutative97.2%
cancel-sign-sub-inv97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*95.3%
associate-*l*95.4%
Simplified95.4%
Taylor expanded in y around 0 61.7%
Final simplification61.7%
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (* x 2.0))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
return x * 2.0;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
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 * 2.0d0
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
return x * 2.0;
}
[y, z, t] = sort([y, z, t]) [a, b] = sort([a, b]) def code(x, y, z, t, a, b): return x * 2.0
y, z, t = sort([y, z, t]) a, b = sort([a, b]) function code(x, y, z, t, a, b) return Float64(x * 2.0) end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp = code(x, y, z, t, a, b)
tmp = x * 2.0;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function. NOTE: a and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(x * 2.0), $MachinePrecision]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
x \cdot 2
\end{array}
Initial program 97.2%
+-commutative97.2%
associate-+r-97.2%
cancel-sign-sub-inv97.2%
*-commutative97.2%
distribute-rgt-neg-out97.2%
associate-*r*96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
associate-+r+96.1%
sub-neg96.1%
associate-*l*96.1%
fma-def96.1%
fma-neg96.1%
associate-*l*96.1%
*-commutative96.1%
associate-*r*95.3%
distribute-rgt-neg-in95.3%
Simplified95.4%
fma-udef95.4%
fma-udef95.4%
associate-+r+95.4%
associate-*r*96.1%
*-commutative96.1%
Applied egg-rr96.1%
Taylor expanded in x around inf 29.4%
Final simplification29.4%
(FPCore (x y z t a b) :precision binary64 (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y < 7.590524218811189e-161) {
tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
} else {
tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * 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 (y < 7.590524218811189d-161) then
tmp = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + (a * (27.0d0 * b))
else
tmp = ((x * 2.0d0) - (9.0d0 * (y * (t * z)))) + ((a * 27.0d0) * 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 (y < 7.590524218811189e-161) {
tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
} else {
tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y < 7.590524218811189e-161: tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b)) else: tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y < 7.590524218811189e-161) tmp = Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(a * Float64(27.0 * b))); else tmp = Float64(Float64(Float64(x * 2.0) - Float64(9.0 * Float64(y * Float64(t * z)))) + Float64(Float64(a * 27.0) * b)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y < 7.590524218811189e-161) tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b)); else tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Less[y, 7.590524218811189e-161], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * N[(y * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y < 7.590524218811189 \cdot 10^{-161}:\\
\;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\
\end{array}
\end{array}
herbie shell --seed 2023275
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))
(+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))