
(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 9 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%
(FPCore (x y z t) :precision binary64 (if (<= x -4.2e+56) (* 0.5 (/ x t)) (if (<= x 6.4e-286) (/ (* z -0.5) t) (* 0.5 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.2e+56) {
tmp = 0.5 * (x / t);
} else if (x <= 6.4e-286) {
tmp = (z * -0.5) / 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 <= (-4.2d+56)) then
tmp = 0.5d0 * (x / t)
else if (x <= 6.4d-286) then
tmp = (z * (-0.5d0)) / 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 <= -4.2e+56) {
tmp = 0.5 * (x / t);
} else if (x <= 6.4e-286) {
tmp = (z * -0.5) / t;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.2e+56: tmp = 0.5 * (x / t) elif x <= 6.4e-286: tmp = (z * -0.5) / t else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.2e+56) tmp = Float64(0.5 * Float64(x / t)); elseif (x <= 6.4e-286) tmp = Float64(Float64(z * -0.5) / 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 <= -4.2e+56) tmp = 0.5 * (x / t); elseif (x <= 6.4e-286) tmp = (z * -0.5) / t; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.2e+56], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.4e-286], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+56}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-286}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if x < -4.20000000000000034e56Initial program 100.0%
Taylor expanded in x around inf 72.7%
if -4.20000000000000034e56 < x < 6.40000000000000014e-286Initial program 100.0%
Taylor expanded in z around inf 48.4%
associate-*r/48.4%
Simplified48.4%
if 6.40000000000000014e-286 < x Initial program 99.9%
Taylor expanded in y around inf 39.1%
Final simplification49.2%
(FPCore (x y z t) :precision binary64 (if (<= x -6.1e+57) (* 0.5 (/ x t)) (if (<= x 1.35e-285) (/ -0.5 (/ t z)) (* 0.5 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.1e+57) {
tmp = 0.5 * (x / t);
} else if (x <= 1.35e-285) {
tmp = -0.5 / (t / z);
} 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 <= (-6.1d+57)) then
tmp = 0.5d0 * (x / t)
else if (x <= 1.35d-285) then
tmp = (-0.5d0) / (t / z)
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 <= -6.1e+57) {
tmp = 0.5 * (x / t);
} else if (x <= 1.35e-285) {
tmp = -0.5 / (t / z);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -6.1e+57: tmp = 0.5 * (x / t) elif x <= 1.35e-285: tmp = -0.5 / (t / z) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -6.1e+57) tmp = Float64(0.5 * Float64(x / t)); elseif (x <= 1.35e-285) tmp = Float64(-0.5 / Float64(t / z)); 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 <= -6.1e+57) tmp = 0.5 * (x / t); elseif (x <= 1.35e-285) tmp = -0.5 / (t / z); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -6.1e+57], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e-285], N[(-0.5 / N[(t / z), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{+57}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-285}:\\
\;\;\;\;\frac{-0.5}{\frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if x < -6.09999999999999975e57Initial program 100.0%
Taylor expanded in x around inf 72.7%
if -6.09999999999999975e57 < x < 1.3499999999999999e-285Initial program 100.0%
Taylor expanded in z around inf 48.4%
associate-*r/48.4%
Simplified48.4%
clear-num48.2%
inv-pow48.2%
*-un-lft-identity48.2%
times-frac48.2%
metadata-eval48.2%
Applied egg-rr48.2%
unpow-148.2%
associate-/r*48.2%
metadata-eval48.2%
Simplified48.2%
if 1.3499999999999999e-285 < x Initial program 99.9%
Taylor expanded in y around inf 39.1%
(FPCore (x y z t) :precision binary64 (if (<= x -8.5e-16) (/ (- x z) (* t 2.0)) (* (/ 0.5 t) (- y z))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.5e-16) {
tmp = (x - z) / (t * 2.0);
} else {
tmp = (0.5 / t) * (y - z);
}
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 <= (-8.5d-16)) then
tmp = (x - z) / (t * 2.0d0)
else
tmp = (0.5d0 / t) * (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.5e-16) {
tmp = (x - z) / (t * 2.0);
} else {
tmp = (0.5 / t) * (y - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -8.5e-16: tmp = (x - z) / (t * 2.0) else: tmp = (0.5 / t) * (y - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -8.5e-16) tmp = Float64(Float64(x - z) / Float64(t * 2.0)); else tmp = Float64(Float64(0.5 / t) * Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -8.5e-16) tmp = (x - z) / (t * 2.0); else tmp = (0.5 / t) * (y - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -8.5e-16], N[(N[(x - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / t), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-16}:\\
\;\;\;\;\frac{x - z}{t \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{t} \cdot \left(y - z\right)\\
\end{array}
\end{array}
if x < -8.5000000000000001e-16Initial program 100.0%
Taylor expanded in x around inf 85.1%
if -8.5000000000000001e-16 < x Initial program 100.0%
Taylor expanded in x around 0 78.9%
*-commutative78.9%
associate-*l/78.9%
associate-*r/78.8%
Simplified78.8%
Final simplification80.4%
(FPCore (x y z t) :precision binary64 (if (<= x -8.5e-16) (* (/ 0.5 t) (- x z)) (* (/ 0.5 t) (- y z))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.5e-16) {
tmp = (0.5 / t) * (x - z);
} else {
tmp = (0.5 / t) * (y - z);
}
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 <= (-8.5d-16)) then
tmp = (0.5d0 / t) * (x - z)
else
tmp = (0.5d0 / t) * (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.5e-16) {
tmp = (0.5 / t) * (x - z);
} else {
tmp = (0.5 / t) * (y - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -8.5e-16: tmp = (0.5 / t) * (x - z) else: tmp = (0.5 / t) * (y - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -8.5e-16) tmp = Float64(Float64(0.5 / t) * Float64(x - z)); else tmp = Float64(Float64(0.5 / t) * Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -8.5e-16) tmp = (0.5 / t) * (x - z); else tmp = (0.5 / t) * (y - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -8.5e-16], N[(N[(0.5 / t), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / t), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-16}:\\
\;\;\;\;\frac{0.5}{t} \cdot \left(x - z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{t} \cdot \left(y - z\right)\\
\end{array}
\end{array}
if x < -8.5000000000000001e-16Initial program 100.0%
Taylor expanded in x around 0 95.4%
associate-*r/95.4%
associate-*l/95.4%
associate-*r/95.4%
associate-*l/95.2%
distribute-lft-in99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 84.9%
if -8.5000000000000001e-16 < x Initial program 100.0%
Taylor expanded in x around 0 78.9%
*-commutative78.9%
associate-*l/78.9%
associate-*r/78.8%
Simplified78.8%
Final simplification80.3%
(FPCore (x y z t) :precision binary64 (if (<= x -7.6e+57) (* 0.5 (/ x t)) (* (/ 0.5 t) (- y z))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.6e+57) {
tmp = 0.5 * (x / t);
} else {
tmp = (0.5 / t) * (y - z);
}
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 <= (-7.6d+57)) then
tmp = 0.5d0 * (x / t)
else
tmp = (0.5d0 / t) * (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.6e+57) {
tmp = 0.5 * (x / t);
} else {
tmp = (0.5 / t) * (y - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -7.6e+57: tmp = 0.5 * (x / t) else: tmp = (0.5 / t) * (y - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -7.6e+57) tmp = Float64(0.5 * Float64(x / t)); else tmp = Float64(Float64(0.5 / t) * Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -7.6e+57) tmp = 0.5 * (x / t); else tmp = (0.5 / t) * (y - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.6e+57], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / t), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{+57}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{t} \cdot \left(y - z\right)\\
\end{array}
\end{array}
if x < -7.5999999999999997e57Initial program 100.0%
Taylor expanded in x around inf 72.7%
if -7.5999999999999997e57 < x Initial program 100.0%
Taylor expanded in x around 0 79.6%
*-commutative79.6%
associate-*l/79.6%
associate-*r/79.4%
Simplified79.4%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (<= x -12500000000000.0) (* 0.5 (/ x t)) (* 0.5 (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -12500000000000.0) {
tmp = 0.5 * (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 (x <= (-12500000000000.0d0)) then
tmp = 0.5d0 * (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 (x <= -12500000000000.0) {
tmp = 0.5 * (x / t);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -12500000000000.0: tmp = 0.5 * (x / t) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -12500000000000.0) tmp = Float64(0.5 * Float64(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 (x <= -12500000000000.0) tmp = 0.5 * (x / t); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -12500000000000.0], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -12500000000000:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if x < -1.25e13Initial program 100.0%
Taylor expanded in x around inf 65.5%
if -1.25e13 < x Initial program 100.0%
Taylor expanded in y around inf 44.6%
(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}
Initial program 100.0%
Taylor expanded in x around 0 97.2%
associate-*r/97.2%
associate-*l/97.1%
associate-*r/97.1%
associate-*l/97.0%
distribute-lft-in99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.7%
(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 36.6%
herbie shell --seed 2024135
(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)))