
(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 6 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t)
:precision binary64
(if (<= x -5e-15)
(* 0.5 (/ x t))
(if (or (<= x -6.6e-172) (and (not (<= x -3.5e-274)) (<= x 2.85e-248)))
(* (/ z t) -0.5)
(/ (* y 0.5) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -5e-15) {
tmp = 0.5 * (x / t);
} else if ((x <= -6.6e-172) || (!(x <= -3.5e-274) && (x <= 2.85e-248))) {
tmp = (z / t) * -0.5;
} 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 <= (-5d-15)) then
tmp = 0.5d0 * (x / t)
else if ((x <= (-6.6d-172)) .or. (.not. (x <= (-3.5d-274))) .and. (x <= 2.85d-248)) then
tmp = (z / t) * (-0.5d0)
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 <= -5e-15) {
tmp = 0.5 * (x / t);
} else if ((x <= -6.6e-172) || (!(x <= -3.5e-274) && (x <= 2.85e-248))) {
tmp = (z / t) * -0.5;
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -5e-15: tmp = 0.5 * (x / t) elif (x <= -6.6e-172) or (not (x <= -3.5e-274) and (x <= 2.85e-248)): tmp = (z / t) * -0.5 else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -5e-15) tmp = Float64(0.5 * Float64(x / t)); elseif ((x <= -6.6e-172) || (!(x <= -3.5e-274) && (x <= 2.85e-248))) tmp = Float64(Float64(z / t) * -0.5); 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 <= -5e-15) tmp = 0.5 * (x / t); elseif ((x <= -6.6e-172) || (~((x <= -3.5e-274)) && (x <= 2.85e-248))) tmp = (z / t) * -0.5; else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -5e-15], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -6.6e-172], And[N[Not[LessEqual[x, -3.5e-274]], $MachinePrecision], LessEqual[x, 2.85e-248]]], N[(N[(z / t), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-15}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{elif}\;x \leq -6.6 \cdot 10^{-172} \lor \neg \left(x \leq -3.5 \cdot 10^{-274}\right) \land x \leq 2.85 \cdot 10^{-248}:\\
\;\;\;\;\frac{z}{t} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
if x < -4.99999999999999999e-15Initial program 100.0%
Taylor expanded in x around inf 62.1%
if -4.99999999999999999e-15 < x < -6.6e-172 or -3.49999999999999982e-274 < x < 2.8499999999999999e-248Initial program 100.0%
Taylor expanded in z around inf 47.5%
*-commutative47.5%
Simplified47.5%
if -6.6e-172 < x < -3.49999999999999982e-274 or 2.8499999999999999e-248 < x Initial program 100.0%
Taylor expanded in y around inf 40.8%
associate-*r/40.8%
Simplified40.8%
Final simplification47.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -170000.0) (not (<= z 1.02e+93))) (* (/ z t) -0.5) (* 0.5 (/ x t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -170000.0) || !(z <= 1.02e+93)) {
tmp = (z / t) * -0.5;
} else {
tmp = 0.5 * (x / 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 <= (-170000.0d0)) .or. (.not. (z <= 1.02d+93))) then
tmp = (z / t) * (-0.5d0)
else
tmp = 0.5d0 * (x / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -170000.0) || !(z <= 1.02e+93)) {
tmp = (z / t) * -0.5;
} else {
tmp = 0.5 * (x / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -170000.0) or not (z <= 1.02e+93): tmp = (z / t) * -0.5 else: tmp = 0.5 * (x / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -170000.0) || !(z <= 1.02e+93)) tmp = Float64(Float64(z / t) * -0.5); else tmp = Float64(0.5 * Float64(x / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -170000.0) || ~((z <= 1.02e+93))) tmp = (z / t) * -0.5; else tmp = 0.5 * (x / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -170000.0], N[Not[LessEqual[z, 1.02e+93]], $MachinePrecision]], N[(N[(z / t), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -170000 \lor \neg \left(z \leq 1.02 \cdot 10^{+93}\right):\\
\;\;\;\;\frac{z}{t} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\end{array}
\end{array}
if z < -1.7e5 or 1.0200000000000001e93 < z Initial program 100.0%
Taylor expanded in z around inf 68.3%
*-commutative68.3%
Simplified68.3%
if -1.7e5 < z < 1.0200000000000001e93Initial program 100.0%
Taylor expanded in x around inf 47.6%
Final simplification56.5%
(FPCore (x y z t) :precision binary64 (if (<= y 6.6e+112) (* 0.5 (/ (- x z) t)) (/ (* y 0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.6e+112) {
tmp = 0.5 * ((x - z) / 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 <= 6.6d+112) then
tmp = 0.5d0 * ((x - z) / 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 <= 6.6e+112) {
tmp = 0.5 * ((x - z) / t);
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.6e+112: tmp = 0.5 * ((x - z) / t) else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.6e+112) tmp = Float64(0.5 * Float64(Float64(x - z) / 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 <= 6.6e+112) tmp = 0.5 * ((x - z) / t); else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.6e+112], N[(0.5 * N[(N[(x - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{+112}:\\
\;\;\;\;0.5 \cdot \frac{x - z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
if y < 6.5999999999999998e112Initial program 100.0%
Taylor expanded in y around 0 72.1%
if 6.5999999999999998e112 < y Initial program 100.0%
Taylor expanded in y around inf 70.9%
associate-*r/70.9%
Simplified70.9%
Final simplification71.9%
(FPCore (x y z t) :precision binary64 (if (<= x -2.6e-97) (* 0.5 (/ (- x z) t)) (* 0.5 (/ (- y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.6e-97) {
tmp = 0.5 * ((x - z) / t);
} else {
tmp = 0.5 * ((y - 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 <= (-2.6d-97)) then
tmp = 0.5d0 * ((x - z) / t)
else
tmp = 0.5d0 * ((y - z) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.6e-97) {
tmp = 0.5 * ((x - z) / t);
} else {
tmp = 0.5 * ((y - z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.6e-97: tmp = 0.5 * ((x - z) / t) else: tmp = 0.5 * ((y - z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.6e-97) tmp = Float64(0.5 * Float64(Float64(x - z) / t)); else tmp = Float64(0.5 * Float64(Float64(y - z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.6e-97) tmp = 0.5 * ((x - z) / t); else tmp = 0.5 * ((y - z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.6e-97], N[(0.5 * N[(N[(x - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{-97}:\\
\;\;\;\;0.5 \cdot \frac{x - z}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y - z}{t}\\
\end{array}
\end{array}
if x < -2.60000000000000007e-97Initial program 100.0%
Taylor expanded in y around 0 77.5%
if -2.60000000000000007e-97 < x Initial program 100.0%
Taylor expanded in x around 0 76.9%
Final simplification77.1%
(FPCore (x y z t) :precision binary64 (* 0.5 (/ x t)))
double code(double x, double y, double z, double t) {
return 0.5 * (x / 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 * (x / t)
end function
public static double code(double x, double y, double z, double t) {
return 0.5 * (x / t);
}
def code(x, y, z, t): return 0.5 * (x / t)
function code(x, y, z, t) return Float64(0.5 * Float64(x / t)) end
function tmp = code(x, y, z, t) tmp = 0.5 * (x / t); end
code[x_, y_, z_, t_] := N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{x}{t}
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 37.1%
Final simplification37.1%
herbie shell --seed 2023308
(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)))