
(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 9 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}
(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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -7.2e+175)
(* x z)
(if (<= z -4.9e+151)
(* y z)
(if (<= z -1.0)
(* x z)
(if (<= z 2.95e-205)
y
(if (<= z 0.22)
x
(if (<= z 1.05e+46)
(* y z)
(if (<= z 3.8e+79) (* x z) (* y z)))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+175) {
tmp = x * z;
} else if (z <= -4.9e+151) {
tmp = y * z;
} else if (z <= -1.0) {
tmp = x * z;
} else if (z <= 2.95e-205) {
tmp = y;
} else if (z <= 0.22) {
tmp = x;
} else if (z <= 1.05e+46) {
tmp = y * z;
} else if (z <= 3.8e+79) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
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 <= (-7.2d+175)) then
tmp = x * z
else if (z <= (-4.9d+151)) then
tmp = y * z
else if (z <= (-1.0d0)) then
tmp = x * z
else if (z <= 2.95d-205) then
tmp = y
else if (z <= 0.22d0) then
tmp = x
else if (z <= 1.05d+46) then
tmp = y * z
else if (z <= 3.8d+79) then
tmp = x * z
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+175) {
tmp = x * z;
} else if (z <= -4.9e+151) {
tmp = y * z;
} else if (z <= -1.0) {
tmp = x * z;
} else if (z <= 2.95e-205) {
tmp = y;
} else if (z <= 0.22) {
tmp = x;
} else if (z <= 1.05e+46) {
tmp = y * z;
} else if (z <= 3.8e+79) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.2e+175: tmp = x * z elif z <= -4.9e+151: tmp = y * z elif z <= -1.0: tmp = x * z elif z <= 2.95e-205: tmp = y elif z <= 0.22: tmp = x elif z <= 1.05e+46: tmp = y * z elif z <= 3.8e+79: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.2e+175) tmp = Float64(x * z); elseif (z <= -4.9e+151) tmp = Float64(y * z); elseif (z <= -1.0) tmp = Float64(x * z); elseif (z <= 2.95e-205) tmp = y; elseif (z <= 0.22) tmp = x; elseif (z <= 1.05e+46) tmp = Float64(y * z); elseif (z <= 3.8e+79) tmp = Float64(x * z); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.2e+175) tmp = x * z; elseif (z <= -4.9e+151) tmp = y * z; elseif (z <= -1.0) tmp = x * z; elseif (z <= 2.95e-205) tmp = y; elseif (z <= 0.22) tmp = x; elseif (z <= 1.05e+46) tmp = y * z; elseif (z <= 3.8e+79) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.2e+175], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.9e+151], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(x * z), $MachinePrecision], If[LessEqual[z, 2.95e-205], y, If[LessEqual[z, 0.22], x, If[LessEqual[z, 1.05e+46], N[(y * z), $MachinePrecision], If[LessEqual[z, 3.8e+79], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+175}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -4.9 \cdot 10^{+151}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 2.95 \cdot 10^{-205}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 0.22:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+46}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+79}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -7.20000000000000067e175 or -4.8999999999999999e151 < z < -1 or 1.05e46 < z < 3.8000000000000002e79Initial program 100.0%
+-commutative100.0%
distribute-lft-in99.9%
*-rgt-identity99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 59.6%
Taylor expanded in z around inf 58.3%
if -7.20000000000000067e175 < z < -4.8999999999999999e151 or 0.220000000000000001 < z < 1.05e46 or 3.8000000000000002e79 < z Initial program 100.0%
Taylor expanded in x around 0 53.6%
*-commutative53.6%
flip-+46.0%
associate-*l/43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in z around inf 41.7%
unpow241.7%
associate-*r*41.7%
mul-1-neg41.7%
Simplified41.7%
Taylor expanded in z around inf 52.2%
if -1 < z < 2.94999999999999987e-205Initial program 100.0%
Taylor expanded in x around 0 55.1%
Taylor expanded in z around 0 55.1%
if 2.94999999999999987e-205 < z < 0.220000000000000001Initial program 100.0%
Taylor expanded in x around inf 53.0%
Taylor expanded in z around 0 53.0%
Final simplification55.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ z 1.0))))
(if (<= z -6e+179)
(* x z)
(if (<= z -2.75e+150)
(* y z)
(if (<= z -3.6e+46)
(* x z)
(if (<= z -0.00024)
t_0
(if (<= z 0.062)
(+ x y)
(if (<= z 1.4e+38) t_0 (if (<= z 5e+82) (* x z) (* y z))))))))))
double code(double x, double y, double z) {
double t_0 = y * (z + 1.0);
double tmp;
if (z <= -6e+179) {
tmp = x * z;
} else if (z <= -2.75e+150) {
tmp = y * z;
} else if (z <= -3.6e+46) {
tmp = x * z;
} else if (z <= -0.00024) {
tmp = t_0;
} else if (z <= 0.062) {
tmp = x + y;
} else if (z <= 1.4e+38) {
tmp = t_0;
} else if (z <= 5e+82) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (z + 1.0d0)
if (z <= (-6d+179)) then
tmp = x * z
else if (z <= (-2.75d+150)) then
tmp = y * z
else if (z <= (-3.6d+46)) then
tmp = x * z
else if (z <= (-0.00024d0)) then
tmp = t_0
else if (z <= 0.062d0) then
tmp = x + y
else if (z <= 1.4d+38) then
tmp = t_0
else if (z <= 5d+82) then
tmp = x * z
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (z + 1.0);
double tmp;
if (z <= -6e+179) {
tmp = x * z;
} else if (z <= -2.75e+150) {
tmp = y * z;
} else if (z <= -3.6e+46) {
tmp = x * z;
} else if (z <= -0.00024) {
tmp = t_0;
} else if (z <= 0.062) {
tmp = x + y;
} else if (z <= 1.4e+38) {
tmp = t_0;
} else if (z <= 5e+82) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z + 1.0) tmp = 0 if z <= -6e+179: tmp = x * z elif z <= -2.75e+150: tmp = y * z elif z <= -3.6e+46: tmp = x * z elif z <= -0.00024: tmp = t_0 elif z <= 0.062: tmp = x + y elif z <= 1.4e+38: tmp = t_0 elif z <= 5e+82: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z + 1.0)) tmp = 0.0 if (z <= -6e+179) tmp = Float64(x * z); elseif (z <= -2.75e+150) tmp = Float64(y * z); elseif (z <= -3.6e+46) tmp = Float64(x * z); elseif (z <= -0.00024) tmp = t_0; elseif (z <= 0.062) tmp = Float64(x + y); elseif (z <= 1.4e+38) tmp = t_0; elseif (z <= 5e+82) tmp = Float64(x * z); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z + 1.0); tmp = 0.0; if (z <= -6e+179) tmp = x * z; elseif (z <= -2.75e+150) tmp = y * z; elseif (z <= -3.6e+46) tmp = x * z; elseif (z <= -0.00024) tmp = t_0; elseif (z <= 0.062) tmp = x + y; elseif (z <= 1.4e+38) tmp = t_0; elseif (z <= 5e+82) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6e+179], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.75e+150], N[(y * z), $MachinePrecision], If[LessEqual[z, -3.6e+46], N[(x * z), $MachinePrecision], If[LessEqual[z, -0.00024], t$95$0, If[LessEqual[z, 0.062], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.4e+38], t$95$0, If[LessEqual[z, 5e+82], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z + 1\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{+179}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -2.75 \cdot 10^{+150}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{+46}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -0.00024:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 0.062:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+82}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -5.9999999999999996e179 or -2.75000000000000008e150 < z < -3.5999999999999999e46 or 1.4e38 < z < 5.00000000000000015e82Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 59.2%
Taylor expanded in z around inf 59.2%
if -5.9999999999999996e179 < z < -2.75000000000000008e150 or 5.00000000000000015e82 < z Initial program 100.0%
Taylor expanded in x around 0 55.6%
*-commutative55.6%
flip-+46.7%
associate-*l/45.0%
metadata-eval45.0%
Applied egg-rr45.0%
Taylor expanded in z around inf 45.0%
unpow245.0%
associate-*r*45.0%
mul-1-neg45.0%
Simplified45.0%
Taylor expanded in z around inf 55.6%
if -3.5999999999999999e46 < z < -2.40000000000000006e-4 or 0.062 < z < 1.4e38Initial program 99.9%
Taylor expanded in x around 0 41.3%
if -2.40000000000000006e-4 < z < 0.062Initial program 100.0%
Taylor expanded in z around 0 97.3%
Final simplification72.5%
(FPCore (x y z)
:precision binary64
(if (<= z -9e+178)
(* x z)
(if (<= z -2.75e+156)
(* y z)
(if (<= z -1.0)
(* x z)
(if (<= z 29.0)
(+ x y)
(if (<= z 1.15e+44) (* y z) (if (<= z 2.3e+82) (* x z) (* y z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+178) {
tmp = x * z;
} else if (z <= -2.75e+156) {
tmp = y * z;
} else if (z <= -1.0) {
tmp = x * z;
} else if (z <= 29.0) {
tmp = x + y;
} else if (z <= 1.15e+44) {
tmp = y * z;
} else if (z <= 2.3e+82) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
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+178)) then
tmp = x * z
else if (z <= (-2.75d+156)) then
tmp = y * z
else if (z <= (-1.0d0)) then
tmp = x * z
else if (z <= 29.0d0) then
tmp = x + y
else if (z <= 1.15d+44) then
tmp = y * z
else if (z <= 2.3d+82) then
tmp = x * z
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9e+178) {
tmp = x * z;
} else if (z <= -2.75e+156) {
tmp = y * z;
} else if (z <= -1.0) {
tmp = x * z;
} else if (z <= 29.0) {
tmp = x + y;
} else if (z <= 1.15e+44) {
tmp = y * z;
} else if (z <= 2.3e+82) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9e+178: tmp = x * z elif z <= -2.75e+156: tmp = y * z elif z <= -1.0: tmp = x * z elif z <= 29.0: tmp = x + y elif z <= 1.15e+44: tmp = y * z elif z <= 2.3e+82: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9e+178) tmp = Float64(x * z); elseif (z <= -2.75e+156) tmp = Float64(y * z); elseif (z <= -1.0) tmp = Float64(x * z); elseif (z <= 29.0) tmp = Float64(x + y); elseif (z <= 1.15e+44) tmp = Float64(y * z); elseif (z <= 2.3e+82) tmp = Float64(x * z); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9e+178) tmp = x * z; elseif (z <= -2.75e+156) tmp = y * z; elseif (z <= -1.0) tmp = x * z; elseif (z <= 29.0) tmp = x + y; elseif (z <= 1.15e+44) tmp = y * z; elseif (z <= 2.3e+82) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9e+178], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.75e+156], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(x * z), $MachinePrecision], If[LessEqual[z, 29.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.15e+44], N[(y * z), $MachinePrecision], If[LessEqual[z, 2.3e+82], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+178}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -2.75 \cdot 10^{+156}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 29:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+44}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+82}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -8.9999999999999994e178 or -2.7500000000000001e156 < z < -1 or 1.15000000000000002e44 < z < 2.29999999999999988e82Initial program 100.0%
+-commutative100.0%
distribute-lft-in99.9%
*-rgt-identity99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 59.6%
Taylor expanded in z around inf 58.3%
if -8.9999999999999994e178 < z < -2.7500000000000001e156 or 29 < z < 1.15000000000000002e44 or 2.29999999999999988e82 < z Initial program 100.0%
Taylor expanded in x around 0 52.9%
*-commutative52.9%
flip-+45.2%
associate-*l/42.3%
metadata-eval42.3%
Applied egg-rr42.3%
Taylor expanded in z around inf 42.3%
unpow242.3%
associate-*r*42.3%
mul-1-neg42.3%
Simplified42.3%
Taylor expanded in z around inf 52.8%
if -1 < z < 29Initial program 100.0%
Taylor expanded in z around 0 96.5%
Final simplification72.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.6e-59) (and (not (<= x -1.15e-88)) (<= x -2.3e-117))) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.6e-59) || (!(x <= -1.15e-88) && (x <= -2.3e-117))) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
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 ((x <= (-2.6d-59)) .or. (.not. (x <= (-1.15d-88))) .and. (x <= (-2.3d-117))) then
tmp = x * (z + 1.0d0)
else
tmp = y * (z + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.6e-59) || (!(x <= -1.15e-88) && (x <= -2.3e-117))) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.6e-59) or (not (x <= -1.15e-88) and (x <= -2.3e-117)): tmp = x * (z + 1.0) else: tmp = y * (z + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.6e-59) || (!(x <= -1.15e-88) && (x <= -2.3e-117))) tmp = Float64(x * Float64(z + 1.0)); else tmp = Float64(y * Float64(z + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.6e-59) || (~((x <= -1.15e-88)) && (x <= -2.3e-117))) tmp = x * (z + 1.0); else tmp = y * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.6e-59], And[N[Not[LessEqual[x, -1.15e-88]], $MachinePrecision], LessEqual[x, -2.3e-117]]], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{-59} \lor \neg \left(x \leq -1.15 \cdot 10^{-88}\right) \land x \leq -2.3 \cdot 10^{-117}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if x < -2.59999999999999998e-59 or -1.14999999999999993e-88 < x < -2.29999999999999994e-117Initial program 99.9%
Taylor expanded in x around inf 77.0%
if -2.59999999999999998e-59 < x < -1.14999999999999993e-88 or -2.29999999999999994e-117 < x Initial program 100.0%
Taylor expanded in x around 0 62.0%
Final simplification66.6%
(FPCore (x y z) :precision binary64 (if (<= z -7.8e-10) (* y z) (if (<= z 3.15e-204) y (if (<= z 0.36) x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e-10) {
tmp = y * z;
} else if (z <= 3.15e-204) {
tmp = y;
} else if (z <= 0.36) {
tmp = x;
} else {
tmp = y * z;
}
return tmp;
}
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 <= (-7.8d-10)) then
tmp = y * z
else if (z <= 3.15d-204) then
tmp = y
else if (z <= 0.36d0) then
tmp = x
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e-10) {
tmp = y * z;
} else if (z <= 3.15e-204) {
tmp = y;
} else if (z <= 0.36) {
tmp = x;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.8e-10: tmp = y * z elif z <= 3.15e-204: tmp = y elif z <= 0.36: tmp = x else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.8e-10) tmp = Float64(y * z); elseif (z <= 3.15e-204) tmp = y; elseif (z <= 0.36) tmp = x; else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.8e-10) tmp = y * z; elseif (z <= 3.15e-204) tmp = y; elseif (z <= 0.36) tmp = x; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.8e-10], N[(y * z), $MachinePrecision], If[LessEqual[z, 3.15e-204], y, If[LessEqual[z, 0.36], x, N[(y * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-10}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 3.15 \cdot 10^{-204}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 0.36:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -7.7999999999999999e-10 or 0.35999999999999999 < z Initial program 100.0%
Taylor expanded in x around 0 48.4%
*-commutative48.4%
flip-+45.2%
associate-*l/40.5%
metadata-eval40.5%
Applied egg-rr40.5%
Taylor expanded in z around inf 39.9%
unpow239.9%
associate-*r*39.9%
mul-1-neg39.9%
Simplified39.9%
Taylor expanded in z around inf 47.9%
if -7.7999999999999999e-10 < z < 3.14999999999999996e-204Initial program 100.0%
Taylor expanded in x around 0 56.8%
Taylor expanded in z around 0 56.8%
if 3.14999999999999996e-204 < z < 0.35999999999999999Initial program 100.0%
Taylor expanded in x around inf 53.0%
Taylor expanded in z around 0 53.0%
Final simplification50.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (+ x y)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x + y);
} else {
tmp = x + y;
}
return tmp;
}
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 * (x + y)
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x + y);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * (x + y) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(x + y)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = z * (x + y); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 100.0%
Taylor expanded in z around inf 99.0%
if -1 < z < 1Initial program 100.0%
Taylor expanded in z around 0 96.5%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (<= x -1.8e-129) x y))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e-129) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
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 (x <= (-1.8d-129)) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e-129) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.8e-129: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.8e-129) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.8e-129) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.8e-129], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-129}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -1.8e-129Initial program 99.9%
Taylor expanded in x around inf 70.1%
Taylor expanded in z around 0 28.1%
if -1.8e-129 < x Initial program 100.0%
Taylor expanded in x around 0 60.9%
Taylor expanded in z around 0 28.5%
Final simplification28.4%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
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
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 52.8%
Taylor expanded in z around 0 21.0%
Final simplification21.0%
herbie shell --seed 2023274
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))