
(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 7 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 -85000000000.0)
(* 0.5 (/ x t))
(if (or (<= x -3.2e-251) (and (not (<= x 1.65e-279)) (<= x 4.7e-178)))
(* -0.5 (/ z t))
(* 0.5 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -85000000000.0) {
tmp = 0.5 * (x / t);
} else if ((x <= -3.2e-251) || (!(x <= 1.65e-279) && (x <= 4.7e-178))) {
tmp = -0.5 * (z / t);
} else {
tmp = 0.5 * (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 <= (-85000000000.0d0)) then
tmp = 0.5d0 * (x / t)
else if ((x <= (-3.2d-251)) .or. (.not. (x <= 1.65d-279)) .and. (x <= 4.7d-178)) then
tmp = (-0.5d0) * (z / t)
else
tmp = 0.5d0 * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -85000000000.0) {
tmp = 0.5 * (x / t);
} else if ((x <= -3.2e-251) || (!(x <= 1.65e-279) && (x <= 4.7e-178))) {
tmp = -0.5 * (z / t);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -85000000000.0: tmp = 0.5 * (x / t) elif (x <= -3.2e-251) or (not (x <= 1.65e-279) and (x <= 4.7e-178)): tmp = -0.5 * (z / t) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -85000000000.0) tmp = Float64(0.5 * Float64(x / t)); elseif ((x <= -3.2e-251) || (!(x <= 1.65e-279) && (x <= 4.7e-178))) tmp = Float64(-0.5 * Float64(z / t)); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -85000000000.0) tmp = 0.5 * (x / t); elseif ((x <= -3.2e-251) || (~((x <= 1.65e-279)) && (x <= 4.7e-178))) tmp = -0.5 * (z / t); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -85000000000.0], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -3.2e-251], And[N[Not[LessEqual[x, 1.65e-279]], $MachinePrecision], LessEqual[x, 4.7e-178]]], N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -85000000000:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-251} \lor \neg \left(x \leq 1.65 \cdot 10^{-279}\right) \land x \leq 4.7 \cdot 10^{-178}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (or (<= y 2.7e+67) (and (not (<= y 1.02e+124)) (<= y 6e+168))) (* -0.5 (/ (- z x) t)) (* 0.5 (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 2.7e+67) || (!(y <= 1.02e+124) && (y <= 6e+168))) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = 0.5 * (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 ((y <= 2.7d+67) .or. (.not. (y <= 1.02d+124)) .and. (y <= 6d+168)) then
tmp = (-0.5d0) * ((z - x) / t)
else
tmp = 0.5d0 * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 2.7e+67) || (!(y <= 1.02e+124) && (y <= 6e+168))) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 2.7e+67) or (not (y <= 1.02e+124) and (y <= 6e+168)): tmp = -0.5 * ((z - x) / t) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 2.7e+67) || (!(y <= 1.02e+124) && (y <= 6e+168))) tmp = Float64(-0.5 * Float64(Float64(z - x) / t)); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 2.7e+67) || (~((y <= 1.02e+124)) && (y <= 6e+168))) tmp = -0.5 * ((z - x) / t); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 2.7e+67], And[N[Not[LessEqual[y, 1.02e+124]], $MachinePrecision], LessEqual[y, 6e+168]]], N[(-0.5 * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+67} \lor \neg \left(y \leq 1.02 \cdot 10^{+124}\right) \land y \leq 6 \cdot 10^{+168}:\\
\;\;\;\;-0.5 \cdot \frac{z - x}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (or (<= z -500000.0) (not (<= z 6.9e+28))) (* -0.5 (/ (- z x) t)) (* (+ x y) (/ 0.5 t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -500000.0) || !(z <= 6.9e+28)) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = (x + 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 ((z <= (-500000.0d0)) .or. (.not. (z <= 6.9d+28))) then
tmp = (-0.5d0) * ((z - x) / t)
else
tmp = (x + 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 ((z <= -500000.0) || !(z <= 6.9e+28)) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = (x + y) * (0.5 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -500000.0) or not (z <= 6.9e+28): tmp = -0.5 * ((z - x) / t) else: tmp = (x + y) * (0.5 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -500000.0) || !(z <= 6.9e+28)) tmp = Float64(-0.5 * Float64(Float64(z - x) / t)); else tmp = Float64(Float64(x + y) * Float64(0.5 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -500000.0) || ~((z <= 6.9e+28))) tmp = -0.5 * ((z - x) / t); else tmp = (x + y) * (0.5 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -500000.0], N[Not[LessEqual[z, 6.9e+28]], $MachinePrecision]], N[(-0.5 * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -500000 \lor \neg \left(z \leq 6.9 \cdot 10^{+28}\right):\\
\;\;\;\;-0.5 \cdot \frac{z - x}{t}\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \frac{0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -4e-187) (* -0.5 (/ (- z x) t)) (* (- z y) (/ -0.5 t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -4e-187) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = (z - 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 + y) <= (-4d-187)) then
tmp = (-0.5d0) * ((z - x) / t)
else
tmp = (z - 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 + y) <= -4e-187) {
tmp = -0.5 * ((z - x) / t);
} else {
tmp = (z - y) * (-0.5 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -4e-187: tmp = -0.5 * ((z - x) / t) else: tmp = (z - y) * (-0.5 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -4e-187) tmp = Float64(-0.5 * Float64(Float64(z - x) / t)); else tmp = Float64(Float64(z - y) * Float64(-0.5 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -4e-187) tmp = -0.5 * ((z - x) / t); else tmp = (z - y) * (-0.5 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -4e-187], N[(-0.5 * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(z - y), $MachinePrecision] * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -4 \cdot 10^{-187}:\\
\;\;\;\;-0.5 \cdot \frac{z - x}{t}\\
\mathbf{else}:\\
\;\;\;\;\left(z - y\right) \cdot \frac{-0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -95000000000.0) (* 0.5 (/ x t)) (* -0.5 (/ z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -95000000000.0) {
tmp = 0.5 * (x / t);
} else {
tmp = -0.5 * (z / 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 <= (-95000000000.0d0)) then
tmp = 0.5d0 * (x / t)
else
tmp = (-0.5d0) * (z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -95000000000.0) {
tmp = 0.5 * (x / t);
} else {
tmp = -0.5 * (z / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -95000000000.0: tmp = 0.5 * (x / t) else: tmp = -0.5 * (z / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -95000000000.0) tmp = Float64(0.5 * Float64(x / t)); else tmp = Float64(-0.5 * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -95000000000.0) tmp = 0.5 * (x / t); else tmp = -0.5 * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -95000000000.0], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -95000000000:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* -0.5 (/ z t)))
double code(double x, double y, double z, double t) {
return -0.5 * (z / 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 = (-0.5d0) * (z / t)
end function
public static double code(double x, double y, double z, double t) {
return -0.5 * (z / t);
}
def code(x, y, z, t): return -0.5 * (z / t)
function code(x, y, z, t) return Float64(-0.5 * Float64(z / t)) end
function tmp = code(x, y, z, t) tmp = -0.5 * (z / t); end
code[x_, y_, z_, t_] := N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{z}{t}
\end{array}
herbie shell --seed 2024006
(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)))