
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x + y) - z) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x + y) - z) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x + y) - z) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
(FPCore (x y z t)
:precision binary64
(if (<= x -1.8e+38)
(/ (* x 0.5) t)
(if (or (<= x -1.55e-219) (and (not (<= x -9.5e-299)) (<= x 1.2e-239)))
(/ (* z -0.5) t)
(/ (* y 0.5) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.8e+38) {
tmp = (x * 0.5) / t;
} else if ((x <= -1.55e-219) || (!(x <= -9.5e-299) && (x <= 1.2e-239))) {
tmp = (z * -0.5) / t;
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-1.8d+38)) then
tmp = (x * 0.5d0) / t
else if ((x <= (-1.55d-219)) .or. (.not. (x <= (-9.5d-299))) .and. (x <= 1.2d-239)) then
tmp = (z * (-0.5d0)) / t
else
tmp = (y * 0.5d0) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.8e+38) {
tmp = (x * 0.5) / t;
} else if ((x <= -1.55e-219) || (!(x <= -9.5e-299) && (x <= 1.2e-239))) {
tmp = (z * -0.5) / t;
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.8e+38: tmp = (x * 0.5) / t elif (x <= -1.55e-219) or (not (x <= -9.5e-299) and (x <= 1.2e-239)): tmp = (z * -0.5) / t else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.8e+38) tmp = Float64(Float64(x * 0.5) / t); elseif ((x <= -1.55e-219) || (!(x <= -9.5e-299) && (x <= 1.2e-239))) tmp = Float64(Float64(z * -0.5) / t); else tmp = Float64(Float64(y * 0.5) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.8e+38) tmp = (x * 0.5) / t; elseif ((x <= -1.55e-219) || (~((x <= -9.5e-299)) && (x <= 1.2e-239))) tmp = (z * -0.5) / t; else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.8e+38], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[Or[LessEqual[x, -1.55e-219], And[N[Not[LessEqual[x, -9.5e-299]], $MachinePrecision], LessEqual[x, 1.2e-239]]], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+38}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-219} \lor \neg \left(x \leq -9.5 \cdot 10^{-299}\right) \land x \leq 1.2 \cdot 10^{-239}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (or (<= y 5.8e+40) (and (not (<= y 1e+58)) (<= y 6.5e+149))) (* -0.5 (/ (- z x) t)) (/ (* y 0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 5.8e+40) || (!(y <= 1e+58) && (y <= 6.5e+149))) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= 5.8d+40) .or. (.not. (y <= 1d+58)) .and. (y <= 6.5d+149)) then
tmp = (-0.5d0) * ((z - x) / t)
else
tmp = (y * 0.5d0) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 5.8e+40) || (!(y <= 1e+58) && (y <= 6.5e+149))) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 5.8e+40) or (not (y <= 1e+58) and (y <= 6.5e+149)): tmp = -0.5 * ((z - x) / t) else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 5.8e+40) || (!(y <= 1e+58) && (y <= 6.5e+149))) tmp = Float64(-0.5 * Float64(Float64(z - x) / t)); else tmp = Float64(Float64(y * 0.5) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 5.8e+40) || (~((y <= 1e+58)) && (y <= 6.5e+149))) tmp = -0.5 * ((z - x) / t); else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 5.8e+40], And[N[Not[LessEqual[y, 1e+58]], $MachinePrecision], LessEqual[y, 6.5e+149]]], N[(-0.5 * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.8 \cdot 10^{+40} \lor \neg \left(y \leq 10^{+58}\right) \land y \leq 6.5 \cdot 10^{+149}:\\
\;\;\;\;-0.5 \cdot \frac{z - x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -2e-232) (* -0.5 (/ (- z x) t)) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -2e-232) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x + y) <= (-2d-232)) then
tmp = (-0.5d0) * ((z - x) / t)
else
tmp = (-0.5d0) * ((z - y) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -2e-232) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -2e-232: tmp = -0.5 * ((z - x) / t) else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -2e-232) tmp = Float64(-0.5 * Float64(Float64(z - x) / t)); else tmp = Float64(-0.5 * Float64(Float64(z - y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -2e-232) tmp = -0.5 * ((z - x) / t); else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -2e-232], N[(-0.5 * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -2 \cdot 10^{-232}:\\
\;\;\;\;-0.5 \cdot \frac{z - x}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* (- (- z y) x) (/ -0.5 t)))
double code(double x, double y, double z, double t) {
return ((z - y) - x) * (-0.5 / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((z - y) - x) * ((-0.5d0) / t)
end function
public static double code(double x, double y, double z, double t) {
return ((z - y) - x) * (-0.5 / t);
}
def code(x, y, z, t): return ((z - y) - x) * (-0.5 / t)
function code(x, y, z, t) return Float64(Float64(Float64(z - y) - x) * Float64(-0.5 / t)) end
function tmp = code(x, y, z, t) tmp = ((z - y) - x) * (-0.5 / t); end
code[x_, y_, z_, t_] := N[(N[(N[(z - y), $MachinePrecision] - x), $MachinePrecision] * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(z - y\right) - x\right) \cdot \frac{-0.5}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -1.6e+38) (/ 0.5 (/ t x)) (* z (/ -0.5 t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.6e+38) {
tmp = 0.5 / (t / x);
} else {
tmp = z * (-0.5 / t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-1.6d+38)) then
tmp = 0.5d0 / (t / x)
else
tmp = z * ((-0.5d0) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.6e+38) {
tmp = 0.5 / (t / x);
} else {
tmp = z * (-0.5 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.6e+38: tmp = 0.5 / (t / x) else: tmp = z * (-0.5 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.6e+38) tmp = Float64(0.5 / Float64(t / x)); else tmp = Float64(z * Float64(-0.5 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.6e+38) tmp = 0.5 / (t / x); else tmp = z * (-0.5 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.6e+38], N[(0.5 / N[(t / x), $MachinePrecision]), $MachinePrecision], N[(z * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+38}:\\
\;\;\;\;\frac{0.5}{\frac{t}{x}}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{-0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -1.66e+38) (/ 0.5 (/ t x)) (/ (* z -0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.66e+38) {
tmp = 0.5 / (t / x);
} else {
tmp = (z * -0.5) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-1.66d+38)) then
tmp = 0.5d0 / (t / x)
else
tmp = (z * (-0.5d0)) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.66e+38) {
tmp = 0.5 / (t / x);
} else {
tmp = (z * -0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.66e+38: tmp = 0.5 / (t / x) else: tmp = (z * -0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.66e+38) tmp = Float64(0.5 / Float64(t / x)); else tmp = Float64(Float64(z * -0.5) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.66e+38) tmp = 0.5 / (t / x); else tmp = (z * -0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.66e+38], N[(0.5 / N[(t / x), $MachinePrecision]), $MachinePrecision], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.66 \cdot 10^{+38}:\\
\;\;\;\;\frac{0.5}{\frac{t}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -1.4e+38) (/ (* x 0.5) t) (/ (* z -0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.4e+38) {
tmp = (x * 0.5) / t;
} else {
tmp = (z * -0.5) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-1.4d+38)) then
tmp = (x * 0.5d0) / t
else
tmp = (z * (-0.5d0)) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.4e+38) {
tmp = (x * 0.5) / t;
} else {
tmp = (z * -0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.4e+38: tmp = (x * 0.5) / t else: tmp = (z * -0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.4e+38) tmp = Float64(Float64(x * 0.5) / t); else tmp = Float64(Float64(z * -0.5) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.4e+38) tmp = (x * 0.5) / t; else tmp = (z * -0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.4e+38], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+38}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* z (/ -0.5 t)))
double code(double x, double y, double z, double t) {
return z * (-0.5 / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = z * ((-0.5d0) / t)
end function
public static double code(double x, double y, double z, double t) {
return z * (-0.5 / t);
}
def code(x, y, z, t): return z * (-0.5 / t)
function code(x, y, z, t) return Float64(z * Float64(-0.5 / t)) end
function tmp = code(x, y, z, t) tmp = z * (-0.5 / t); end
code[x_, y_, z_, t_] := N[(z * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \frac{-0.5}{t}
\end{array}
herbie shell --seed 2024008
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
:precision binary64
(/ (- (+ x y) z) (* t 2.0)))