
(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 12 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 (/ (- (+ y x) z) (* 2.0 t)))
double code(double x, double y, double z, double t) {
return ((y + x) - z) / (2.0 * 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 + x) - z) / (2.0d0 * t)
end function
public static double code(double x, double y, double z, double t) {
return ((y + x) - z) / (2.0 * t);
}
def code(x, y, z, t): return ((y + x) - z) / (2.0 * t)
function code(x, y, z, t) return Float64(Float64(Float64(y + x) - z) / Float64(2.0 * t)) end
function tmp = code(x, y, z, t) tmp = ((y + x) - z) / (2.0 * t); end
code[x_, y_, z_, t_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] / N[(2.0 * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(y + x\right) - z}{2 \cdot t}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (if (<= (+ y x) -2e+40) (/ (* 0.5 x) t) (if (<= (+ y x) 2e-7) (/ (* -0.5 z) t) (/ (* 0.5 y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y + x) <= -2e+40) {
tmp = (0.5 * x) / t;
} else if ((y + x) <= 2e-7) {
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 ((y + x) <= (-2d+40)) then
tmp = (0.5d0 * x) / t
else if ((y + x) <= 2d-7) 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 ((y + x) <= -2e+40) {
tmp = (0.5 * x) / t;
} else if ((y + x) <= 2e-7) {
tmp = (-0.5 * z) / t;
} else {
tmp = (0.5 * y) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y + x) <= -2e+40: tmp = (0.5 * x) / t elif (y + x) <= 2e-7: tmp = (-0.5 * z) / t else: tmp = (0.5 * y) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(y + x) <= -2e+40) tmp = Float64(Float64(0.5 * x) / t); elseif (Float64(y + x) <= 2e-7) tmp = Float64(Float64(-0.5 * z) / t); else tmp = Float64(Float64(0.5 * y) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y + x) <= -2e+40) tmp = (0.5 * x) / t; elseif ((y + x) <= 2e-7) tmp = (-0.5 * z) / t; else tmp = (0.5 * y) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(y + x), $MachinePrecision], -2e+40], N[(N[(0.5 * x), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(y + x), $MachinePrecision], 2e-7], N[(N[(-0.5 * z), $MachinePrecision] / t), $MachinePrecision], N[(N[(0.5 * y), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + x \leq -2 \cdot 10^{+40}:\\
\;\;\;\;\frac{0.5 \cdot x}{t}\\
\mathbf{elif}\;y + x \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{-0.5 \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot y}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < -2.00000000000000006e40Initial program 99.9%
Taylor expanded in x around inf
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6444.5
Applied rewrites44.5%
Applied rewrites44.6%
if -2.00000000000000006e40 < (+.f64 x y) < 1.9999999999999999e-7Initial program 99.9%
Taylor expanded in z around inf
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6468.7
Applied rewrites68.7%
Applied rewrites68.9%
if 1.9999999999999999e-7 < (+.f64 x y) Initial program 99.9%
Taylor expanded in y around inf
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6441.7
Applied rewrites41.7%
Applied rewrites41.8%
Final simplification50.3%
herbie shell --seed 2024230
(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)))