
(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 -1.22e+231)
(* y z)
(if (<= z -2.2e+148)
(* x z)
(if (<= z -9.5e+72)
(* y z)
(if (<= z -29000000.0)
(* x z)
(if (<= z -2.8e-37)
x
(if (<= z -4.1e-113)
y
(if (<= z -7.5e-226)
x
(if (<= z 1.8e-297)
y
(if (<= z 9.5e-250)
x
(if (<= z 1.7e-104)
y
(if (<= z 5.4e-40)
x
(if (<= z 0.00017)
y
(if (<= z 5.9e+190) (* x z) (* y z)))))))))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.22e+231) {
tmp = y * z;
} else if (z <= -2.2e+148) {
tmp = x * z;
} else if (z <= -9.5e+72) {
tmp = y * z;
} else if (z <= -29000000.0) {
tmp = x * z;
} else if (z <= -2.8e-37) {
tmp = x;
} else if (z <= -4.1e-113) {
tmp = y;
} else if (z <= -7.5e-226) {
tmp = x;
} else if (z <= 1.8e-297) {
tmp = y;
} else if (z <= 9.5e-250) {
tmp = x;
} else if (z <= 1.7e-104) {
tmp = y;
} else if (z <= 5.4e-40) {
tmp = x;
} else if (z <= 0.00017) {
tmp = y;
} else if (z <= 5.9e+190) {
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 <= (-1.22d+231)) then
tmp = y * z
else if (z <= (-2.2d+148)) then
tmp = x * z
else if (z <= (-9.5d+72)) then
tmp = y * z
else if (z <= (-29000000.0d0)) then
tmp = x * z
else if (z <= (-2.8d-37)) then
tmp = x
else if (z <= (-4.1d-113)) then
tmp = y
else if (z <= (-7.5d-226)) then
tmp = x
else if (z <= 1.8d-297) then
tmp = y
else if (z <= 9.5d-250) then
tmp = x
else if (z <= 1.7d-104) then
tmp = y
else if (z <= 5.4d-40) then
tmp = x
else if (z <= 0.00017d0) then
tmp = y
else if (z <= 5.9d+190) 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 <= -1.22e+231) {
tmp = y * z;
} else if (z <= -2.2e+148) {
tmp = x * z;
} else if (z <= -9.5e+72) {
tmp = y * z;
} else if (z <= -29000000.0) {
tmp = x * z;
} else if (z <= -2.8e-37) {
tmp = x;
} else if (z <= -4.1e-113) {
tmp = y;
} else if (z <= -7.5e-226) {
tmp = x;
} else if (z <= 1.8e-297) {
tmp = y;
} else if (z <= 9.5e-250) {
tmp = x;
} else if (z <= 1.7e-104) {
tmp = y;
} else if (z <= 5.4e-40) {
tmp = x;
} else if (z <= 0.00017) {
tmp = y;
} else if (z <= 5.9e+190) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.22e+231: tmp = y * z elif z <= -2.2e+148: tmp = x * z elif z <= -9.5e+72: tmp = y * z elif z <= -29000000.0: tmp = x * z elif z <= -2.8e-37: tmp = x elif z <= -4.1e-113: tmp = y elif z <= -7.5e-226: tmp = x elif z <= 1.8e-297: tmp = y elif z <= 9.5e-250: tmp = x elif z <= 1.7e-104: tmp = y elif z <= 5.4e-40: tmp = x elif z <= 0.00017: tmp = y elif z <= 5.9e+190: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.22e+231) tmp = Float64(y * z); elseif (z <= -2.2e+148) tmp = Float64(x * z); elseif (z <= -9.5e+72) tmp = Float64(y * z); elseif (z <= -29000000.0) tmp = Float64(x * z); elseif (z <= -2.8e-37) tmp = x; elseif (z <= -4.1e-113) tmp = y; elseif (z <= -7.5e-226) tmp = x; elseif (z <= 1.8e-297) tmp = y; elseif (z <= 9.5e-250) tmp = x; elseif (z <= 1.7e-104) tmp = y; elseif (z <= 5.4e-40) tmp = x; elseif (z <= 0.00017) tmp = y; elseif (z <= 5.9e+190) 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 <= -1.22e+231) tmp = y * z; elseif (z <= -2.2e+148) tmp = x * z; elseif (z <= -9.5e+72) tmp = y * z; elseif (z <= -29000000.0) tmp = x * z; elseif (z <= -2.8e-37) tmp = x; elseif (z <= -4.1e-113) tmp = y; elseif (z <= -7.5e-226) tmp = x; elseif (z <= 1.8e-297) tmp = y; elseif (z <= 9.5e-250) tmp = x; elseif (z <= 1.7e-104) tmp = y; elseif (z <= 5.4e-40) tmp = x; elseif (z <= 0.00017) tmp = y; elseif (z <= 5.9e+190) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.22e+231], N[(y * z), $MachinePrecision], If[LessEqual[z, -2.2e+148], N[(x * z), $MachinePrecision], If[LessEqual[z, -9.5e+72], N[(y * z), $MachinePrecision], If[LessEqual[z, -29000000.0], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.8e-37], x, If[LessEqual[z, -4.1e-113], y, If[LessEqual[z, -7.5e-226], x, If[LessEqual[z, 1.8e-297], y, If[LessEqual[z, 9.5e-250], x, If[LessEqual[z, 1.7e-104], y, If[LessEqual[z, 5.4e-40], x, If[LessEqual[z, 0.00017], y, If[LessEqual[z, 5.9e+190], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.22 \cdot 10^{+231}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -2.2 \cdot 10^{+148}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{+72}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -29000000:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-37}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -4.1 \cdot 10^{-113}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -7.5 \cdot 10^{-226}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-297}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{-250}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-104}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 0.00017:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 5.9 \cdot 10^{+190}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -1.21999999999999998e231 or -2.1999999999999999e148 < z < -9.50000000000000054e72 or 5.89999999999999972e190 < z Initial program 100.0%
Taylor expanded in x around 0 56.7%
+-commutative56.7%
distribute-lft-in56.7%
*-rgt-identity56.7%
Applied egg-rr56.7%
Taylor expanded in z around inf 56.7%
if -1.21999999999999998e231 < z < -2.1999999999999999e148 or -9.50000000000000054e72 < z < -2.9e7 or 1.7e-4 < z < 5.89999999999999972e190Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in100.0%
fma-def100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 95.9%
Taylor expanded in y around 0 52.9%
*-commutative52.9%
Simplified52.9%
if -2.9e7 < z < -2.8000000000000001e-37 or -4.1e-113 < z < -7.50000000000000044e-226 or 1.79999999999999997e-297 < z < 9.5000000000000002e-250 or 1.70000000000000008e-104 < z < 5.4e-40Initial program 100.0%
Taylor expanded in x around inf 62.5%
Taylor expanded in z around 0 62.4%
if -2.8000000000000001e-37 < z < -4.1e-113 or -7.50000000000000044e-226 < z < 1.79999999999999997e-297 or 9.5000000000000002e-250 < z < 1.70000000000000008e-104 or 5.4e-40 < z < 1.7e-4Initial program 100.0%
Taylor expanded in x around 0 53.8%
Taylor expanded in z around 0 53.5%
Final simplification55.9%
(FPCore (x y z)
:precision binary64
(if (<= z -4.1e-7)
(* y z)
(if (<= z -4.8e-113)
y
(if (<= z -1.4e-224)
x
(if (<= z 4.2e-297)
y
(if (<= z 6e-250)
x
(if (<= z 1e-103)
y
(if (<= z 1.24e-39) x (if (<= z 0.00017) y (* y z))))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e-7) {
tmp = y * z;
} else if (z <= -4.8e-113) {
tmp = y;
} else if (z <= -1.4e-224) {
tmp = x;
} else if (z <= 4.2e-297) {
tmp = y;
} else if (z <= 6e-250) {
tmp = x;
} else if (z <= 1e-103) {
tmp = y;
} else if (z <= 1.24e-39) {
tmp = x;
} else if (z <= 0.00017) {
tmp = y;
} 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 <= (-4.1d-7)) then
tmp = y * z
else if (z <= (-4.8d-113)) then
tmp = y
else if (z <= (-1.4d-224)) then
tmp = x
else if (z <= 4.2d-297) then
tmp = y
else if (z <= 6d-250) then
tmp = x
else if (z <= 1d-103) then
tmp = y
else if (z <= 1.24d-39) then
tmp = x
else if (z <= 0.00017d0) then
tmp = y
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e-7) {
tmp = y * z;
} else if (z <= -4.8e-113) {
tmp = y;
} else if (z <= -1.4e-224) {
tmp = x;
} else if (z <= 4.2e-297) {
tmp = y;
} else if (z <= 6e-250) {
tmp = x;
} else if (z <= 1e-103) {
tmp = y;
} else if (z <= 1.24e-39) {
tmp = x;
} else if (z <= 0.00017) {
tmp = y;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.1e-7: tmp = y * z elif z <= -4.8e-113: tmp = y elif z <= -1.4e-224: tmp = x elif z <= 4.2e-297: tmp = y elif z <= 6e-250: tmp = x elif z <= 1e-103: tmp = y elif z <= 1.24e-39: tmp = x elif z <= 0.00017: tmp = y else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.1e-7) tmp = Float64(y * z); elseif (z <= -4.8e-113) tmp = y; elseif (z <= -1.4e-224) tmp = x; elseif (z <= 4.2e-297) tmp = y; elseif (z <= 6e-250) tmp = x; elseif (z <= 1e-103) tmp = y; elseif (z <= 1.24e-39) tmp = x; elseif (z <= 0.00017) tmp = y; else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.1e-7) tmp = y * z; elseif (z <= -4.8e-113) tmp = y; elseif (z <= -1.4e-224) tmp = x; elseif (z <= 4.2e-297) tmp = y; elseif (z <= 6e-250) tmp = x; elseif (z <= 1e-103) tmp = y; elseif (z <= 1.24e-39) tmp = x; elseif (z <= 0.00017) tmp = y; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.1e-7], N[(y * z), $MachinePrecision], If[LessEqual[z, -4.8e-113], y, If[LessEqual[z, -1.4e-224], x, If[LessEqual[z, 4.2e-297], y, If[LessEqual[z, 6e-250], x, If[LessEqual[z, 1e-103], y, If[LessEqual[z, 1.24e-39], x, If[LessEqual[z, 0.00017], y, N[(y * z), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{-7}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{-113}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-224}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-297}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-250}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 10^{-103}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 1.24 \cdot 10^{-39}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 0.00017:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -4.0999999999999999e-7 or 1.7e-4 < z Initial program 100.0%
Taylor expanded in x around 0 51.5%
+-commutative51.5%
distribute-lft-in51.5%
*-rgt-identity51.5%
Applied egg-rr51.5%
Taylor expanded in z around inf 49.0%
if -4.0999999999999999e-7 < z < -4.80000000000000024e-113 or -1.3999999999999999e-224 < z < 4.20000000000000027e-297 or 6.00000000000000032e-250 < z < 9.99999999999999958e-104 or 1.24000000000000004e-39 < z < 1.7e-4Initial program 100.0%
Taylor expanded in x around 0 54.4%
Taylor expanded in z around 0 53.6%
if -4.80000000000000024e-113 < z < -1.3999999999999999e-224 or 4.20000000000000027e-297 < z < 6.00000000000000032e-250 or 9.99999999999999958e-104 < z < 1.24000000000000004e-39Initial program 100.0%
Taylor expanded in x around inf 68.0%
Taylor expanded in z around 0 68.0%
Final simplification53.7%
(FPCore (x y z)
:precision binary64
(if (<= z -2.5e+231)
(* y z)
(if (<= z -1.45e+148)
(* x z)
(if (<= z -6e+72)
(* y z)
(if (<= z -98000000000000.0)
(* x z)
(if (<= z -1.0)
(* y z)
(if (<= z 550.0) (+ x y) (if (<= z 2.2e+191) (* x z) (* y z)))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.5e+231) {
tmp = y * z;
} else if (z <= -1.45e+148) {
tmp = x * z;
} else if (z <= -6e+72) {
tmp = y * z;
} else if (z <= -98000000000000.0) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= 550.0) {
tmp = x + y;
} else if (z <= 2.2e+191) {
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 <= (-2.5d+231)) then
tmp = y * z
else if (z <= (-1.45d+148)) then
tmp = x * z
else if (z <= (-6d+72)) then
tmp = y * z
else if (z <= (-98000000000000.0d0)) then
tmp = x * z
else if (z <= (-1.0d0)) then
tmp = y * z
else if (z <= 550.0d0) then
tmp = x + y
else if (z <= 2.2d+191) 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 <= -2.5e+231) {
tmp = y * z;
} else if (z <= -1.45e+148) {
tmp = x * z;
} else if (z <= -6e+72) {
tmp = y * z;
} else if (z <= -98000000000000.0) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= 550.0) {
tmp = x + y;
} else if (z <= 2.2e+191) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.5e+231: tmp = y * z elif z <= -1.45e+148: tmp = x * z elif z <= -6e+72: tmp = y * z elif z <= -98000000000000.0: tmp = x * z elif z <= -1.0: tmp = y * z elif z <= 550.0: tmp = x + y elif z <= 2.2e+191: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.5e+231) tmp = Float64(y * z); elseif (z <= -1.45e+148) tmp = Float64(x * z); elseif (z <= -6e+72) tmp = Float64(y * z); elseif (z <= -98000000000000.0) tmp = Float64(x * z); elseif (z <= -1.0) tmp = Float64(y * z); elseif (z <= 550.0) tmp = Float64(x + y); elseif (z <= 2.2e+191) 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 <= -2.5e+231) tmp = y * z; elseif (z <= -1.45e+148) tmp = x * z; elseif (z <= -6e+72) tmp = y * z; elseif (z <= -98000000000000.0) tmp = x * z; elseif (z <= -1.0) tmp = y * z; elseif (z <= 550.0) tmp = x + y; elseif (z <= 2.2e+191) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.5e+231], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.45e+148], N[(x * z), $MachinePrecision], If[LessEqual[z, -6e+72], N[(y * z), $MachinePrecision], If[LessEqual[z, -98000000000000.0], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 550.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 2.2e+191], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+231}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{+148}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -6 \cdot 10^{+72}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -98000000000000:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 550:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+191}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -2.50000000000000014e231 or -1.45e148 < z < -6.00000000000000006e72 or -9.8e13 < z < -1 or 2.2e191 < z Initial program 100.0%
Taylor expanded in x around 0 58.2%
+-commutative58.2%
distribute-lft-in58.1%
*-rgt-identity58.1%
Applied egg-rr58.1%
Taylor expanded in z around inf 56.2%
if -2.50000000000000014e231 < z < -1.45e148 or -6.00000000000000006e72 < z < -9.8e13 or 550 < z < 2.2e191Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in100.0%
fma-def100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 99.2%
Taylor expanded in y around 0 54.4%
*-commutative54.4%
Simplified54.4%
if -1 < z < 550Initial program 100.0%
Taylor expanded in z around 0 97.1%
+-commutative97.1%
Simplified97.1%
Final simplification75.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ z 1.0))))
(if (<= z -6.5e+232)
(* y z)
(if (<= z -1.8e+148)
(* x z)
(if (<= z -4.6e+72)
(* y z)
(if (<= z -1.75e-9)
t_0
(if (<= z 3.2e-6) (+ x y) (if (<= z 8.4e+190) t_0 (* y z)))))))))
double code(double x, double y, double z) {
double t_0 = x * (z + 1.0);
double tmp;
if (z <= -6.5e+232) {
tmp = y * z;
} else if (z <= -1.8e+148) {
tmp = x * z;
} else if (z <= -4.6e+72) {
tmp = y * z;
} else if (z <= -1.75e-9) {
tmp = t_0;
} else if (z <= 3.2e-6) {
tmp = x + y;
} else if (z <= 8.4e+190) {
tmp = t_0;
} 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 = x * (z + 1.0d0)
if (z <= (-6.5d+232)) then
tmp = y * z
else if (z <= (-1.8d+148)) then
tmp = x * z
else if (z <= (-4.6d+72)) then
tmp = y * z
else if (z <= (-1.75d-9)) then
tmp = t_0
else if (z <= 3.2d-6) then
tmp = x + y
else if (z <= 8.4d+190) then
tmp = t_0
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (z + 1.0);
double tmp;
if (z <= -6.5e+232) {
tmp = y * z;
} else if (z <= -1.8e+148) {
tmp = x * z;
} else if (z <= -4.6e+72) {
tmp = y * z;
} else if (z <= -1.75e-9) {
tmp = t_0;
} else if (z <= 3.2e-6) {
tmp = x + y;
} else if (z <= 8.4e+190) {
tmp = t_0;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z + 1.0) tmp = 0 if z <= -6.5e+232: tmp = y * z elif z <= -1.8e+148: tmp = x * z elif z <= -4.6e+72: tmp = y * z elif z <= -1.75e-9: tmp = t_0 elif z <= 3.2e-6: tmp = x + y elif z <= 8.4e+190: tmp = t_0 else: tmp = y * z return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z + 1.0)) tmp = 0.0 if (z <= -6.5e+232) tmp = Float64(y * z); elseif (z <= -1.8e+148) tmp = Float64(x * z); elseif (z <= -4.6e+72) tmp = Float64(y * z); elseif (z <= -1.75e-9) tmp = t_0; elseif (z <= 3.2e-6) tmp = Float64(x + y); elseif (z <= 8.4e+190) tmp = t_0; else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z + 1.0); tmp = 0.0; if (z <= -6.5e+232) tmp = y * z; elseif (z <= -1.8e+148) tmp = x * z; elseif (z <= -4.6e+72) tmp = y * z; elseif (z <= -1.75e-9) tmp = t_0; elseif (z <= 3.2e-6) tmp = x + y; elseif (z <= 8.4e+190) tmp = t_0; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.5e+232], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.8e+148], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.6e+72], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.75e-9], t$95$0, If[LessEqual[z, 3.2e-6], N[(x + y), $MachinePrecision], If[LessEqual[z, 8.4e+190], t$95$0, N[(y * z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z + 1\right)\\
\mathbf{if}\;z \leq -6.5 \cdot 10^{+232}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{+148}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -4.6 \cdot 10^{+72}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1.75 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-6}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{+190}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -6.50000000000000016e232 or -1.80000000000000003e148 < z < -4.6e72 or 8.4000000000000003e190 < z Initial program 100.0%
Taylor expanded in x around 0 56.7%
+-commutative56.7%
distribute-lft-in56.7%
*-rgt-identity56.7%
Applied egg-rr56.7%
Taylor expanded in z around inf 56.7%
if -6.50000000000000016e232 < z < -1.80000000000000003e148Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in100.0%
fma-def100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 100.0%
Taylor expanded in y around 0 63.2%
*-commutative63.2%
Simplified63.2%
if -4.6e72 < z < -1.75e-9 or 3.1999999999999999e-6 < z < 8.4000000000000003e190Initial program 100.0%
Taylor expanded in x around inf 50.9%
if -1.75e-9 < z < 3.1999999999999999e-6Initial program 100.0%
Taylor expanded in z around 0 99.5%
+-commutative99.5%
Simplified99.5%
Final simplification76.2%
(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 97.2%
+-commutative97.2%
Simplified97.2%
if -1 < z < 1Initial program 100.0%
Taylor expanded in z around 0 97.8%
+-commutative97.8%
Simplified97.8%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.36e-86) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.36e-86) {
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 (y <= 1.36d-86) 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 (y <= 1.36e-86) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.36e-86: tmp = x * (z + 1.0) else: tmp = y * (z + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.36e-86) 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 (y <= 1.36e-86) tmp = x * (z + 1.0); else tmp = y * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.36e-86], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.36 \cdot 10^{-86}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < 1.3599999999999999e-86Initial program 100.0%
Taylor expanded in x around inf 64.4%
if 1.3599999999999999e-86 < y Initial program 100.0%
Taylor expanded in x around 0 66.5%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (<= y 1.15e-77) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e-77) {
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 (y <= 1.15d-77) 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 (y <= 1.15e-77) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.15e-77: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.15e-77) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.15e-77) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.15e-77], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{-77}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 1.14999999999999999e-77Initial program 100.0%
Taylor expanded in x around inf 64.1%
Taylor expanded in z around 0 33.0%
if 1.14999999999999999e-77 < y Initial program 99.9%
Taylor expanded in x around 0 67.1%
Taylor expanded in z around 0 34.7%
Final simplification33.6%
(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 53.8%
Taylor expanded in z around 0 28.4%
Final simplification28.4%
herbie shell --seed 2024031
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))