
(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 10 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 y) -4e+75) (* (+ x y) (/ 0.5 t)) (* (/ -0.5 t) (- z y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -4e+75) {
tmp = (x + y) * (0.5 / t);
} else {
tmp = (-0.5 / t) * (z - y);
}
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+75)) then
tmp = (x + y) * (0.5d0 / t)
else
tmp = ((-0.5d0) / t) * (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -4e+75) {
tmp = (x + y) * (0.5 / t);
} else {
tmp = (-0.5 / t) * (z - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -4e+75: tmp = (x + y) * (0.5 / t) else: tmp = (-0.5 / t) * (z - y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -4e+75) tmp = Float64(Float64(x + y) * Float64(0.5 / t)); else tmp = Float64(Float64(-0.5 / t) * Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -4e+75) tmp = (x + y) * (0.5 / t); else tmp = (-0.5 / t) * (z - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -4e+75], N[(N[(x + y), $MachinePrecision] * N[(0.5 / t), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / t), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -4 \cdot 10^{+75}:\\
\;\;\;\;\left(x + y\right) \cdot \frac{0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{t} \cdot \left(z - y\right)\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -4e+75) (/ (* (+ x y) 0.5) t) (* (/ -0.5 t) (- z y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -4e+75) {
tmp = ((x + y) * 0.5) / t;
} else {
tmp = (-0.5 / t) * (z - y);
}
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+75)) then
tmp = ((x + y) * 0.5d0) / t
else
tmp = ((-0.5d0) / t) * (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -4e+75) {
tmp = ((x + y) * 0.5) / t;
} else {
tmp = (-0.5 / t) * (z - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -4e+75: tmp = ((x + y) * 0.5) / t else: tmp = (-0.5 / t) * (z - y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -4e+75) tmp = Float64(Float64(Float64(x + y) * 0.5) / t); else tmp = Float64(Float64(-0.5 / t) * Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -4e+75) tmp = ((x + y) * 0.5) / t; else tmp = (-0.5 / t) * (z - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -4e+75], N[(N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision] / t), $MachinePrecision], N[(N[(-0.5 / t), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -4 \cdot 10^{+75}:\\
\;\;\;\;\frac{\left(x + y\right) \cdot 0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{t} \cdot \left(z - y\right)\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) 2e-166) (/ (- z x) (* t -2.0)) (* (/ -0.5 t) (- z y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= 2e-166) {
tmp = (z - x) / (t * -2.0);
} else {
tmp = (-0.5 / t) * (z - y);
}
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-166) then
tmp = (z - x) / (t * (-2.0d0))
else
tmp = ((-0.5d0) / t) * (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= 2e-166) {
tmp = (z - x) / (t * -2.0);
} else {
tmp = (-0.5 / t) * (z - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= 2e-166: tmp = (z - x) / (t * -2.0) else: tmp = (-0.5 / t) * (z - y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= 2e-166) tmp = Float64(Float64(z - x) / Float64(t * -2.0)); else tmp = Float64(Float64(-0.5 / t) * Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= 2e-166) tmp = (z - x) / (t * -2.0); else tmp = (-0.5 / t) * (z - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], 2e-166], N[(N[(z - x), $MachinePrecision] / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / t), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 2 \cdot 10^{-166}:\\
\;\;\;\;\frac{z - x}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{t} \cdot \left(z - y\right)\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y -3.8e-167) (/ (* x 0.5) t) (if (<= y 2.2e+58) (/ z (* t -2.0)) (* y (/ 0.5 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.8e-167) {
tmp = (x * 0.5) / t;
} else if (y <= 2.2e+58) {
tmp = z / (t * -2.0);
} 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 <= (-3.8d-167)) then
tmp = (x * 0.5d0) / t
else if (y <= 2.2d+58) then
tmp = z / (t * (-2.0d0))
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 <= -3.8e-167) {
tmp = (x * 0.5) / t;
} else if (y <= 2.2e+58) {
tmp = z / (t * -2.0);
} else {
tmp = y * (0.5 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.8e-167: tmp = (x * 0.5) / t elif y <= 2.2e+58: tmp = z / (t * -2.0) else: tmp = y * (0.5 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.8e-167) tmp = Float64(Float64(x * 0.5) / t); elseif (y <= 2.2e+58) tmp = Float64(z / Float64(t * -2.0)); else tmp = Float64(y * Float64(0.5 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -3.8e-167) tmp = (x * 0.5) / t; elseif (y <= 2.2e+58) tmp = z / (t * -2.0); else tmp = y * (0.5 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.8e-167], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[y, 2.2e+58], N[(z / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{-167}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+58}:\\
\;\;\;\;\frac{z}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y -1.12e-167) (/ (* x 0.5) t) (if (<= y 3e+53) (/ z (* t -2.0)) (/ (* y 0.5) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.12e-167) {
tmp = (x * 0.5) / t;
} else if (y <= 3e+53) {
tmp = z / (t * -2.0);
} 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 <= (-1.12d-167)) then
tmp = (x * 0.5d0) / t
else if (y <= 3d+53) then
tmp = z / (t * (-2.0d0))
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 <= -1.12e-167) {
tmp = (x * 0.5) / t;
} else if (y <= 3e+53) {
tmp = z / (t * -2.0);
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.12e-167: tmp = (x * 0.5) / t elif y <= 3e+53: tmp = z / (t * -2.0) else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.12e-167) tmp = Float64(Float64(x * 0.5) / t); elseif (y <= 3e+53) tmp = Float64(z / Float64(t * -2.0)); 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 <= -1.12e-167) tmp = (x * 0.5) / t; elseif (y <= 3e+53) tmp = z / (t * -2.0); else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.12e-167], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[y, 3e+53], N[(z / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{-167}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+53}:\\
\;\;\;\;\frac{z}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x -4.2e+75) (/ (* x 0.5) t) (* (/ -0.5 t) (- z y))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.2e+75) {
tmp = (x * 0.5) / t;
} else {
tmp = (-0.5 / t) * (z - y);
}
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 <= (-4.2d+75)) then
tmp = (x * 0.5d0) / t
else
tmp = ((-0.5d0) / t) * (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.2e+75) {
tmp = (x * 0.5) / t;
} else {
tmp = (-0.5 / t) * (z - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.2e+75: tmp = (x * 0.5) / t else: tmp = (-0.5 / t) * (z - y) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.2e+75) tmp = Float64(Float64(x * 0.5) / t); else tmp = Float64(Float64(-0.5 / t) * Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -4.2e+75) tmp = (x * 0.5) / t; else tmp = (-0.5 / t) * (z - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.2e+75], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], N[(N[(-0.5 / t), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+75}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{t} \cdot \left(z - y\right)\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* (/ 0.5 t) (+ x (- y z))))
double code(double x, double y, double z, double t) {
return (0.5 / t) * (x + (y - z));
}
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 / t) * (x + (y - z))
end function
public static double code(double x, double y, double z, double t) {
return (0.5 / t) * (x + (y - z));
}
def code(x, y, z, t): return (0.5 / t) * (x + (y - z))
function code(x, y, z, t) return Float64(Float64(0.5 / t) * Float64(x + Float64(y - z))) end
function tmp = code(x, y, z, t) tmp = (0.5 / t) * (x + (y - z)); end
code[x_, y_, z_, t_] := N[(N[(0.5 / t), $MachinePrecision] * N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{t} \cdot \left(x + \left(y - z\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y 7.3e+56) (/ z (* t -2.0)) (* y (/ 0.5 t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.3e+56) {
tmp = z / (t * -2.0);
} 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 <= 7.3d+56) then
tmp = z / (t * (-2.0d0))
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 <= 7.3e+56) {
tmp = z / (t * -2.0);
} else {
tmp = y * (0.5 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.3e+56: tmp = z / (t * -2.0) else: tmp = y * (0.5 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.3e+56) tmp = Float64(z / Float64(t * -2.0)); else tmp = Float64(y * Float64(0.5 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7.3e+56) tmp = z / (t * -2.0); else tmp = y * (0.5 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.3e+56], N[(z / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.3 \cdot 10^{+56}:\\
\;\;\;\;\frac{z}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{0.5}{t}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* y (/ 0.5 t)))
double code(double x, double y, double z, double t) {
return y * (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 = y * (0.5d0 / t)
end function
public static double code(double x, double y, double z, double t) {
return y * (0.5 / t);
}
def code(x, y, z, t): return y * (0.5 / t)
function code(x, y, z, t) return Float64(y * Float64(0.5 / t)) end
function tmp = code(x, y, z, t) tmp = y * (0.5 / t); end
code[x_, y_, z_, t_] := N[(y * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{0.5}{t}
\end{array}
herbie shell --seed 2024010
(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)))