
(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 (+ x y))))
double code(double x, double y, double z) {
return (x + y) + (z * (x + y));
}
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 * (x + y))
end function
public static double code(double x, double y, double z) {
return (x + y) + (z * (x + y));
}
def code(x, y, z): return (x + y) + (z * (x + y))
function code(x, y, z) return Float64(Float64(x + y) + Float64(z * Float64(x + y))) end
function tmp = code(x, y, z) tmp = (x + y) + (z * (x + y)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] + N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) + z \cdot \left(x + y\right)
\end{array}
(FPCore (x y z)
:precision binary64
(if (<= z -1.0)
(* y z)
(if (<= z -1.7e-237)
y
(if (<= z 1.35e-223)
x
(if (<= z 2.8e-181)
y
(if (<= z 5.2e-123) x (if (<= z 8200000.0) y (* y z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= -1.7e-237) {
tmp = y;
} else if (z <= 1.35e-223) {
tmp = x;
} else if (z <= 2.8e-181) {
tmp = y;
} else if (z <= 5.2e-123) {
tmp = x;
} else if (z <= 8200000.0) {
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 <= (-1.0d0)) then
tmp = y * z
else if (z <= (-1.7d-237)) then
tmp = y
else if (z <= 1.35d-223) then
tmp = x
else if (z <= 2.8d-181) then
tmp = y
else if (z <= 5.2d-123) then
tmp = x
else if (z <= 8200000.0d0) 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 <= -1.0) {
tmp = y * z;
} else if (z <= -1.7e-237) {
tmp = y;
} else if (z <= 1.35e-223) {
tmp = x;
} else if (z <= 2.8e-181) {
tmp = y;
} else if (z <= 5.2e-123) {
tmp = x;
} else if (z <= 8200000.0) {
tmp = y;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = y * z elif z <= -1.7e-237: tmp = y elif z <= 1.35e-223: tmp = x elif z <= 2.8e-181: tmp = y elif z <= 5.2e-123: tmp = x elif z <= 8200000.0: tmp = y else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(y * z); elseif (z <= -1.7e-237) tmp = y; elseif (z <= 1.35e-223) tmp = x; elseif (z <= 2.8e-181) tmp = y; elseif (z <= 5.2e-123) tmp = x; elseif (z <= 8200000.0) tmp = y; else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = y * z; elseif (z <= -1.7e-237) tmp = y; elseif (z <= 1.35e-223) tmp = x; elseif (z <= 2.8e-181) tmp = y; elseif (z <= 5.2e-123) tmp = x; elseif (z <= 8200000.0) tmp = y; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.7e-237], y, If[LessEqual[z, 1.35e-223], x, If[LessEqual[z, 2.8e-181], y, If[LessEqual[z, 5.2e-123], x, If[LessEqual[z, 8200000.0], y, N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{-237}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-223}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-181}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-123}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 8200000:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -0.00058) (not (<= z 0.00064))) (* x (+ z 1.0)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.00058) || !(z <= 0.00064)) {
tmp = x * (z + 1.0);
} 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 <= (-0.00058d0)) .or. (.not. (z <= 0.00064d0))) then
tmp = x * (z + 1.0d0)
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.00058) || !(z <= 0.00064)) {
tmp = x * (z + 1.0);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.00058) or not (z <= 0.00064): tmp = x * (z + 1.0) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.00058) || !(z <= 0.00064)) tmp = Float64(x * Float64(z + 1.0)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.00058) || ~((z <= 0.00064))) tmp = x * (z + 1.0); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.00058], N[Not[LessEqual[z, 0.00064]], $MachinePrecision]], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00058 \lor \neg \left(z \leq 0.00064\right):\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
(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}
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 8200000.0))) (* y z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 8200000.0)) {
tmp = y * z;
} 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 <= 8200000.0d0))) then
tmp = y * z
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 <= 8200000.0)) {
tmp = y * z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 8200000.0): tmp = y * z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 8200000.0)) tmp = Float64(y * z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 8200000.0))) tmp = y * z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 8200000.0]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 8200000\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= x -6.5e-128) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.5e-128) {
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 <= (-6.5d-128)) 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 <= -6.5e-128) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.5e-128: tmp = x * (z + 1.0) else: tmp = y * (z + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.5e-128) 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 <= -6.5e-128) tmp = x * (z + 1.0); else tmp = y * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.5e-128], 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 -6.5 \cdot 10^{-128}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\end{array}
\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}
(FPCore (x y z) :precision binary64 (if (<= y 7.8e-147) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.8e-147) {
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 <= 7.8d-147) 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 <= 7.8e-147) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.8e-147: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.8e-147) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7.8e-147) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.8e-147], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.8 \cdot 10^{-147}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
(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}
herbie shell --seed 2024008
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))