
(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 8 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 (or (<= x -1.15e+104) (and (not (<= x -1.25e+27)) (<= x -490000000.0))) (/ (* x 0.5) t) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.15e+104) || (!(x <= -1.25e+27) && (x <= -490000000.0))) {
tmp = (x * 0.5) / 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 <= (-1.15d+104)) .or. (.not. (x <= (-1.25d+27))) .and. (x <= (-490000000.0d0))) then
tmp = (x * 0.5d0) / 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 <= -1.15e+104) || (!(x <= -1.25e+27) && (x <= -490000000.0))) {
tmp = (x * 0.5) / t;
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.15e+104) or (not (x <= -1.25e+27) and (x <= -490000000.0)): tmp = (x * 0.5) / t else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.15e+104) || (!(x <= -1.25e+27) && (x <= -490000000.0))) tmp = Float64(Float64(x * 0.5) / 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 <= -1.15e+104) || (~((x <= -1.25e+27)) && (x <= -490000000.0))) tmp = (x * 0.5) / t; else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.15e+104], And[N[Not[LessEqual[x, -1.25e+27]], $MachinePrecision], LessEqual[x, -490000000.0]]], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{+104} \lor \neg \left(x \leq -1.25 \cdot 10^{+27}\right) \land x \leq -490000000:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -1e-109) (/ -0.5 (/ t (- z x))) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -1e-109) {
tmp = -0.5 / (t / (z - x));
} 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) <= (-1d-109)) then
tmp = (-0.5d0) / (t / (z - x))
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) <= -1e-109) {
tmp = -0.5 / (t / (z - x));
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -1e-109: tmp = -0.5 / (t / (z - x)) else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -1e-109) tmp = Float64(-0.5 / Float64(t / Float64(z - x))); 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) <= -1e-109) tmp = -0.5 / (t / (z - x)); else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -1e-109], N[(-0.5 / N[(t / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1 \cdot 10^{-109}:\\
\;\;\;\;\frac{-0.5}{\frac{t}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -490000000.0) (/ (* x 0.5) t) (if (<= x 1.8e-271) (/ (* z -0.5) t) (/ (* y 0.5) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -490000000.0) {
tmp = (x * 0.5) / t;
} else if (x <= 1.8e-271) {
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 <= (-490000000.0d0)) then
tmp = (x * 0.5d0) / t
else if (x <= 1.8d-271) 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 <= -490000000.0) {
tmp = (x * 0.5) / t;
} else if (x <= 1.8e-271) {
tmp = (z * -0.5) / t;
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -490000000.0: tmp = (x * 0.5) / t elif x <= 1.8e-271: tmp = (z * -0.5) / t else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -490000000.0) tmp = Float64(Float64(x * 0.5) / t); elseif (x <= 1.8e-271) 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 <= -490000000.0) tmp = (x * 0.5) / t; elseif (x <= 1.8e-271) tmp = (z * -0.5) / t; else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -490000000.0], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[x, 1.8e-271], 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 -490000000:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-271}:\\
\;\;\;\;\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 (* (- (- 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 -470000000.0) (* x (/ 0.5 t)) (/ (* z -0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -470000000.0) {
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 <= (-470000000.0d0)) 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 <= -470000000.0) {
tmp = x * (0.5 / t);
} else {
tmp = (z * -0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -470000000.0: tmp = x * (0.5 / t) else: tmp = (z * -0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -470000000.0) tmp = Float64(x * Float64(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 <= -470000000.0) tmp = x * (0.5 / t); else tmp = (z * -0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -470000000.0], N[(x * N[(0.5 / t), $MachinePrecision]), $MachinePrecision], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -470000000:\\
\;\;\;\;x \cdot \frac{0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -380000000.0) (/ (* x 0.5) t) (/ (* z -0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -380000000.0) {
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 <= (-380000000.0d0)) 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 <= -380000000.0) {
tmp = (x * 0.5) / t;
} else {
tmp = (z * -0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -380000000.0: tmp = (x * 0.5) / t else: tmp = (z * -0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -380000000.0) 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 <= -380000000.0) tmp = (x * 0.5) / t; else tmp = (z * -0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -380000000.0], 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 -380000000:\\
\;\;\;\;\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 (* x (/ 0.5 t)))
double code(double x, double y, double z, double t) {
return 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 = x * (0.5d0 / t)
end function
public static double code(double x, double y, double z, double t) {
return x * (0.5 / t);
}
def code(x, y, z, t): return x * (0.5 / t)
function code(x, y, z, t) return Float64(x * Float64(0.5 / t)) end
function tmp = code(x, y, z, t) tmp = x * (0.5 / t); end
code[x_, y_, z_, t_] := N[(x * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{0.5}{t}
\end{array}
herbie shell --seed 2023343
(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)))