
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
def code(x, y, z): return (x + y) * (z + 1.0)
function code(x, y, z) return Float64(Float64(x + y) * Float64(z + 1.0)) end
function tmp = code(x, y, z) tmp = (x + y) * (z + 1.0); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(z + 1\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
def code(x, y, z): return (x + y) * (z + 1.0)
function code(x, y, z) return Float64(Float64(x + y) * Float64(z + 1.0)) end
function tmp = code(x, y, z) tmp = (x + y) * (z + 1.0); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(z + 1\right)
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (fma (+ z 1.0) y (* (+ z 1.0) x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return fma((z + 1.0), y, ((z + 1.0) * x));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return fma(Float64(z + 1.0), y, Float64(Float64(z + 1.0) * x)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(z + 1.0), $MachinePrecision] * y + N[(N[(z + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left(z + 1, y, \left(z + 1\right) \cdot x\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in99.2%
fma-define99.6%
Applied egg-rr99.6%
Final simplification99.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= z -9e+183)
(* z x)
(if (<= z -1.0)
(* z y)
(if (<= z 6e-158)
x
(if (<= z 4e+14)
y
(if (or (<= z 4e+110) (and (not (<= z 4.4e+244)) (<= z 1.36e+293)))
(* z x)
(* z y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+183) {
tmp = z * x;
} else if (z <= -1.0) {
tmp = z * y;
} else if (z <= 6e-158) {
tmp = x;
} else if (z <= 4e+14) {
tmp = y;
} else if ((z <= 4e+110) || (!(z <= 4.4e+244) && (z <= 1.36e+293))) {
tmp = z * x;
} else {
tmp = z * y;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-9d+183)) then
tmp = z * x
else if (z <= (-1.0d0)) then
tmp = z * y
else if (z <= 6d-158) then
tmp = x
else if (z <= 4d+14) then
tmp = y
else if ((z <= 4d+110) .or. (.not. (z <= 4.4d+244)) .and. (z <= 1.36d+293)) then
tmp = z * x
else
tmp = z * y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9e+183) {
tmp = z * x;
} else if (z <= -1.0) {
tmp = z * y;
} else if (z <= 6e-158) {
tmp = x;
} else if (z <= 4e+14) {
tmp = y;
} else if ((z <= 4e+110) || (!(z <= 4.4e+244) && (z <= 1.36e+293))) {
tmp = z * x;
} else {
tmp = z * y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= -9e+183: tmp = z * x elif z <= -1.0: tmp = z * y elif z <= 6e-158: tmp = x elif z <= 4e+14: tmp = y elif (z <= 4e+110) or (not (z <= 4.4e+244) and (z <= 1.36e+293)): tmp = z * x else: tmp = z * y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= -9e+183) tmp = Float64(z * x); elseif (z <= -1.0) tmp = Float64(z * y); elseif (z <= 6e-158) tmp = x; elseif (z <= 4e+14) tmp = y; elseif ((z <= 4e+110) || (!(z <= 4.4e+244) && (z <= 1.36e+293))) tmp = Float64(z * x); else tmp = Float64(z * y); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= -9e+183)
tmp = z * x;
elseif (z <= -1.0)
tmp = z * y;
elseif (z <= 6e-158)
tmp = x;
elseif (z <= 4e+14)
tmp = y;
elseif ((z <= 4e+110) || (~((z <= 4.4e+244)) && (z <= 1.36e+293)))
tmp = z * x;
else
tmp = z * y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, -9e+183], N[(z * x), $MachinePrecision], If[LessEqual[z, -1.0], N[(z * y), $MachinePrecision], If[LessEqual[z, 6e-158], x, If[LessEqual[z, 4e+14], y, If[Or[LessEqual[z, 4e+110], And[N[Not[LessEqual[z, 4.4e+244]], $MachinePrecision], LessEqual[z, 1.36e+293]]], N[(z * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+183}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-158}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+14}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+110} \lor \neg \left(z \leq 4.4 \cdot 10^{+244}\right) \land z \leq 1.36 \cdot 10^{+293}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -9.00000000000000034e183 or 4e14 < z < 4.0000000000000001e110 or 4.40000000000000003e244 < z < 1.3600000000000001e293Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in96.9%
fma-define98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 85.2%
+-commutative85.2%
+-commutative85.2%
associate-+l+85.2%
+-commutative85.2%
*-commutative85.2%
associate-/l*86.6%
*-rgt-identity86.6%
distribute-lft-out86.6%
Simplified86.6%
Taylor expanded in z around inf 86.6%
Taylor expanded in x around inf 58.8%
*-commutative58.8%
Simplified58.8%
if -9.00000000000000034e183 < z < -1 or 4.0000000000000001e110 < z < 4.40000000000000003e244 or 1.3600000000000001e293 < z Initial program 100.0%
Taylor expanded in x around 0 66.0%
Taylor expanded in z around inf 65.4%
*-commutative65.4%
Simplified65.4%
if -1 < z < 6e-158Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 46.1%
Taylor expanded in z around 0 46.0%
if 6e-158 < z < 4e14Initial program 100.0%
Taylor expanded in x around 0 50.2%
Taylor expanded in z around 0 43.6%
Final simplification54.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= z -9.5e+182)
(* z x)
(if (<= z -1.0)
(* z y)
(if (<= z 4e+14)
(+ y x)
(if (or (<= z 1.18e+111) (and (not (<= z 1.05e+249)) (<= z 1.7e+292)))
(* z x)
(* z y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e+182) {
tmp = z * x;
} else if (z <= -1.0) {
tmp = z * y;
} else if (z <= 4e+14) {
tmp = y + x;
} else if ((z <= 1.18e+111) || (!(z <= 1.05e+249) && (z <= 1.7e+292))) {
tmp = z * x;
} else {
tmp = z * y;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-9.5d+182)) then
tmp = z * x
else if (z <= (-1.0d0)) then
tmp = z * y
else if (z <= 4d+14) then
tmp = y + x
else if ((z <= 1.18d+111) .or. (.not. (z <= 1.05d+249)) .and. (z <= 1.7d+292)) then
tmp = z * x
else
tmp = z * y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e+182) {
tmp = z * x;
} else if (z <= -1.0) {
tmp = z * y;
} else if (z <= 4e+14) {
tmp = y + x;
} else if ((z <= 1.18e+111) || (!(z <= 1.05e+249) && (z <= 1.7e+292))) {
tmp = z * x;
} else {
tmp = z * y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= -9.5e+182: tmp = z * x elif z <= -1.0: tmp = z * y elif z <= 4e+14: tmp = y + x elif (z <= 1.18e+111) or (not (z <= 1.05e+249) and (z <= 1.7e+292)): tmp = z * x else: tmp = z * y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= -9.5e+182) tmp = Float64(z * x); elseif (z <= -1.0) tmp = Float64(z * y); elseif (z <= 4e+14) tmp = Float64(y + x); elseif ((z <= 1.18e+111) || (!(z <= 1.05e+249) && (z <= 1.7e+292))) tmp = Float64(z * x); else tmp = Float64(z * y); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= -9.5e+182)
tmp = z * x;
elseif (z <= -1.0)
tmp = z * y;
elseif (z <= 4e+14)
tmp = y + x;
elseif ((z <= 1.18e+111) || (~((z <= 1.05e+249)) && (z <= 1.7e+292)))
tmp = z * x;
else
tmp = z * y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, -9.5e+182], N[(z * x), $MachinePrecision], If[LessEqual[z, -1.0], N[(z * y), $MachinePrecision], If[LessEqual[z, 4e+14], N[(y + x), $MachinePrecision], If[Or[LessEqual[z, 1.18e+111], And[N[Not[LessEqual[z, 1.05e+249]], $MachinePrecision], LessEqual[z, 1.7e+292]]], N[(z * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+182}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+14}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.18 \cdot 10^{+111} \lor \neg \left(z \leq 1.05 \cdot 10^{+249}\right) \land z \leq 1.7 \cdot 10^{+292}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -9.50000000000000002e182 or 4e14 < z < 1.1799999999999999e111 or 1.0499999999999999e249 < z < 1.7000000000000001e292Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in96.9%
fma-define98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 85.2%
+-commutative85.2%
+-commutative85.2%
associate-+l+85.2%
+-commutative85.2%
*-commutative85.2%
associate-/l*86.6%
*-rgt-identity86.6%
distribute-lft-out86.6%
Simplified86.6%
Taylor expanded in z around inf 86.6%
Taylor expanded in x around inf 58.8%
*-commutative58.8%
Simplified58.8%
if -9.50000000000000002e182 < z < -1 or 1.1799999999999999e111 < z < 1.0499999999999999e249 or 1.7000000000000001e292 < z Initial program 100.0%
Taylor expanded in x around 0 66.0%
Taylor expanded in z around inf 65.4%
*-commutative65.4%
Simplified65.4%
if -1 < z < 4e14Initial program 100.0%
Taylor expanded in z around 0 95.2%
+-commutative95.2%
Simplified95.2%
Final simplification77.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= z -2.4e+180)
(* z x)
(if (<= z -1.0)
(* z y)
(if (<= z 2.05e-7)
(+ y x)
(if (<= z 1.5e+111)
(* (+ z 1.0) x)
(if (or (<= z 3.2e+249) (not (<= z 6.8e+292))) (* z y) (* z x)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= -2.4e+180) {
tmp = z * x;
} else if (z <= -1.0) {
tmp = z * y;
} else if (z <= 2.05e-7) {
tmp = y + x;
} else if (z <= 1.5e+111) {
tmp = (z + 1.0) * x;
} else if ((z <= 3.2e+249) || !(z <= 6.8e+292)) {
tmp = z * y;
} else {
tmp = z * x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-2.4d+180)) then
tmp = z * x
else if (z <= (-1.0d0)) then
tmp = z * y
else if (z <= 2.05d-7) then
tmp = y + x
else if (z <= 1.5d+111) then
tmp = (z + 1.0d0) * x
else if ((z <= 3.2d+249) .or. (.not. (z <= 6.8d+292))) then
tmp = z * y
else
tmp = z * x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.4e+180) {
tmp = z * x;
} else if (z <= -1.0) {
tmp = z * y;
} else if (z <= 2.05e-7) {
tmp = y + x;
} else if (z <= 1.5e+111) {
tmp = (z + 1.0) * x;
} else if ((z <= 3.2e+249) || !(z <= 6.8e+292)) {
tmp = z * y;
} else {
tmp = z * x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= -2.4e+180: tmp = z * x elif z <= -1.0: tmp = z * y elif z <= 2.05e-7: tmp = y + x elif z <= 1.5e+111: tmp = (z + 1.0) * x elif (z <= 3.2e+249) or not (z <= 6.8e+292): tmp = z * y else: tmp = z * x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= -2.4e+180) tmp = Float64(z * x); elseif (z <= -1.0) tmp = Float64(z * y); elseif (z <= 2.05e-7) tmp = Float64(y + x); elseif (z <= 1.5e+111) tmp = Float64(Float64(z + 1.0) * x); elseif ((z <= 3.2e+249) || !(z <= 6.8e+292)) tmp = Float64(z * y); else tmp = Float64(z * x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= -2.4e+180)
tmp = z * x;
elseif (z <= -1.0)
tmp = z * y;
elseif (z <= 2.05e-7)
tmp = y + x;
elseif (z <= 1.5e+111)
tmp = (z + 1.0) * x;
elseif ((z <= 3.2e+249) || ~((z <= 6.8e+292)))
tmp = z * y;
else
tmp = z * x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, -2.4e+180], N[(z * x), $MachinePrecision], If[LessEqual[z, -1.0], N[(z * y), $MachinePrecision], If[LessEqual[z, 2.05e-7], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.5e+111], N[(N[(z + 1.0), $MachinePrecision] * x), $MachinePrecision], If[Or[LessEqual[z, 3.2e+249], N[Not[LessEqual[z, 6.8e+292]], $MachinePrecision]], N[(z * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+180}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{-7}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+111}:\\
\;\;\;\;\left(z + 1\right) \cdot x\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+249} \lor \neg \left(z \leq 6.8 \cdot 10^{+292}\right):\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -2.3999999999999998e180 or 3.20000000000000014e249 < z < 6.8000000000000003e292Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in95.3%
fma-define97.7%
Applied egg-rr97.7%
Taylor expanded in x around inf 86.6%
+-commutative86.6%
+-commutative86.6%
associate-+l+86.6%
+-commutative86.6%
*-commutative86.6%
associate-/l*88.8%
*-rgt-identity88.8%
distribute-lft-out88.8%
Simplified88.8%
Taylor expanded in z around inf 88.8%
Taylor expanded in x around inf 54.5%
*-commutative54.5%
Simplified54.5%
if -2.3999999999999998e180 < z < -1 or 1.5e111 < z < 3.20000000000000014e249 or 6.8000000000000003e292 < z Initial program 100.0%
Taylor expanded in x around 0 66.0%
Taylor expanded in z around inf 65.4%
*-commutative65.4%
Simplified65.4%
if -1 < z < 2.05e-7Initial program 100.0%
Taylor expanded in z around 0 99.7%
+-commutative99.7%
Simplified99.7%
if 2.05e-7 < z < 1.5e111Initial program 99.9%
Taylor expanded in x around inf 64.0%
Final simplification78.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= z -5.4e-12)
(* z x)
(if (<= z -1.56e-208)
x
(if (<= z 1.15e-286)
y
(if (<= z 3.8e-157) x (if (<= z 4e+14) y (* z x)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= -5.4e-12) {
tmp = z * x;
} else if (z <= -1.56e-208) {
tmp = x;
} else if (z <= 1.15e-286) {
tmp = y;
} else if (z <= 3.8e-157) {
tmp = x;
} else if (z <= 4e+14) {
tmp = y;
} else {
tmp = z * x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.4d-12)) then
tmp = z * x
else if (z <= (-1.56d-208)) then
tmp = x
else if (z <= 1.15d-286) then
tmp = y
else if (z <= 3.8d-157) then
tmp = x
else if (z <= 4d+14) then
tmp = y
else
tmp = z * x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.4e-12) {
tmp = z * x;
} else if (z <= -1.56e-208) {
tmp = x;
} else if (z <= 1.15e-286) {
tmp = y;
} else if (z <= 3.8e-157) {
tmp = x;
} else if (z <= 4e+14) {
tmp = y;
} else {
tmp = z * x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= -5.4e-12: tmp = z * x elif z <= -1.56e-208: tmp = x elif z <= 1.15e-286: tmp = y elif z <= 3.8e-157: tmp = x elif z <= 4e+14: tmp = y else: tmp = z * x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= -5.4e-12) tmp = Float64(z * x); elseif (z <= -1.56e-208) tmp = x; elseif (z <= 1.15e-286) tmp = y; elseif (z <= 3.8e-157) tmp = x; elseif (z <= 4e+14) tmp = y; else tmp = Float64(z * x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= -5.4e-12)
tmp = z * x;
elseif (z <= -1.56e-208)
tmp = x;
elseif (z <= 1.15e-286)
tmp = y;
elseif (z <= 3.8e-157)
tmp = x;
elseif (z <= 4e+14)
tmp = y;
else
tmp = z * x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, -5.4e-12], N[(z * x), $MachinePrecision], If[LessEqual[z, -1.56e-208], x, If[LessEqual[z, 1.15e-286], y, If[LessEqual[z, 3.8e-157], x, If[LessEqual[z, 4e+14], y, N[(z * x), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{-12}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -1.56 \cdot 10^{-208}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-286}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-157}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+14}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -5.39999999999999961e-12 or 4e14 < z Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in98.5%
fma-define99.3%
Applied egg-rr99.3%
Taylor expanded in x around inf 82.6%
+-commutative82.6%
+-commutative82.6%
associate-+l+82.6%
+-commutative82.6%
*-commutative82.6%
associate-/l*83.2%
*-rgt-identity83.2%
distribute-lft-out83.2%
Simplified83.2%
Taylor expanded in z around inf 82.6%
Taylor expanded in x around inf 46.5%
*-commutative46.5%
Simplified46.5%
if -5.39999999999999961e-12 < z < -1.56e-208 or 1.1500000000000001e-286 < z < 3.8000000000000002e-157Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 42.1%
Taylor expanded in z around 0 42.0%
if -1.56e-208 < z < 1.1500000000000001e-286 or 3.8000000000000002e-157 < z < 4e14Initial program 100.0%
Taylor expanded in x around 0 46.1%
Taylor expanded in z around 0 41.9%
Final simplification44.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (+ y x)) (+ y x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (y + x);
} else {
tmp = y + x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (y + x)
else
tmp = y + x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (y + x);
} else {
tmp = y + x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * (y + x) else: tmp = y + x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(y + x)); else tmp = Float64(y + x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z <= -1.0) || ~((z <= 1.0)))
tmp = z * (y + x);
else
tmp = y + x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(y + x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 100.0%
Taylor expanded in z around inf 97.8%
+-commutative97.8%
Simplified97.8%
if -1 < z < 1Initial program 100.0%
Taylor expanded in z around 0 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification98.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.56e-146) (* (+ z 1.0) x) (* (+ z 1.0) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.56e-146) {
tmp = (z + 1.0) * x;
} else {
tmp = (z + 1.0) * y;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.56d-146) then
tmp = (z + 1.0d0) * x
else
tmp = (z + 1.0d0) * y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.56e-146) {
tmp = (z + 1.0) * x;
} else {
tmp = (z + 1.0) * y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.56e-146: tmp = (z + 1.0) * x else: tmp = (z + 1.0) * y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.56e-146) tmp = Float64(Float64(z + 1.0) * x); else tmp = Float64(Float64(z + 1.0) * y); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 1.56e-146)
tmp = (z + 1.0) * x;
else
tmp = (z + 1.0) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.56e-146], N[(N[(z + 1.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(z + 1.0), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.56 \cdot 10^{-146}:\\
\;\;\;\;\left(z + 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(z + 1\right) \cdot y\\
\end{array}
\end{array}
if y < 1.5599999999999999e-146Initial program 100.0%
Taylor expanded in x around inf 56.5%
if 1.5599999999999999e-146 < y Initial program 100.0%
Taylor expanded in x around 0 70.9%
Final simplification62.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (+ z 1.0) (+ y x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (z + 1.0) * (y + x);
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (z + 1.0d0) * (y + x)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (z + 1.0) * (y + x);
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (z + 1.0) * (y + x)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(z + 1.0) * Float64(y + x)) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (z + 1.0) * (y + x);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(z + 1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\left(z + 1\right) \cdot \left(y + x\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 8.8e-132) x y))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 8.8e-132) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 8.8d-132) then
tmp = x
else
tmp = y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8.8e-132) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 8.8e-132: tmp = x else: tmp = y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 8.8e-132) tmp = x; else tmp = y; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 8.8e-132)
tmp = x;
else
tmp = y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 8.8e-132], x, y]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.8 \cdot 10^{-132}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 8.79999999999999963e-132Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 55.5%
Taylor expanded in z around 0 28.4%
if 8.79999999999999963e-132 < y Initial program 100.0%
Taylor expanded in x around 0 71.4%
Taylor expanded in z around 0 27.2%
Final simplification27.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 x)
assert(x < y && y < z);
double code(double x, double y, double z) {
return x;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x
x, y, z = sort([x, y, z]) function code(x, y, z) return x end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := x
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x
\end{array}
Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 47.6%
Taylor expanded in z around 0 23.5%
Final simplification23.5%
herbie shell --seed 2024080
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))