
(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 8 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 y) -5e-13) (/ (* x 0.5) t) (if (<= (+ x y) 2e+17) (/ (* z -0.5) t) (/ (* y 0.5) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-13) {
tmp = (x * 0.5) / t;
} else if ((x + y) <= 2e+17) {
tmp = (z * -0.5) / 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 ((x + y) <= (-5d-13)) then
tmp = (x * 0.5d0) / t
else if ((x + y) <= 2d+17) then
tmp = (z * (-0.5d0)) / 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 ((x + y) <= -5e-13) {
tmp = (x * 0.5) / t;
} else if ((x + y) <= 2e+17) {
tmp = (z * -0.5) / t;
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e-13: tmp = (x * 0.5) / t elif (x + y) <= 2e+17: tmp = (z * -0.5) / t else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e-13) tmp = Float64(Float64(x * 0.5) / t); elseif (Float64(x + y) <= 2e+17) tmp = Float64(Float64(z * -0.5) / 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 ((x + y) <= -5e-13) tmp = (x * 0.5) / t; elseif ((x + y) <= 2e+17) tmp = (z * -0.5) / t; else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e-13], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 2e+17], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{-13}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;x + y \leq 2 \cdot 10^{+17}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < -4.9999999999999999e-13Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6439.4
Simplified39.4%
if -4.9999999999999999e-13 < (+.f64 x y) < 2e17Initial program 100.0%
Taylor expanded in z around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6480.0
Simplified80.0%
if 2e17 < (+.f64 x y) Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6444.9
Simplified44.9%
Final simplification52.2%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e-13) (/ (* x 0.5) t) (if (<= (+ x y) 2e+17) (* z (/ -0.5 t)) (/ (* y 0.5) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-13) {
tmp = (x * 0.5) / t;
} else if ((x + y) <= 2e+17) {
tmp = z * (-0.5 / 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 ((x + y) <= (-5d-13)) then
tmp = (x * 0.5d0) / t
else if ((x + y) <= 2d+17) then
tmp = z * ((-0.5d0) / 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 ((x + y) <= -5e-13) {
tmp = (x * 0.5) / t;
} else if ((x + y) <= 2e+17) {
tmp = z * (-0.5 / t);
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e-13: tmp = (x * 0.5) / t elif (x + y) <= 2e+17: tmp = z * (-0.5 / t) else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e-13) tmp = Float64(Float64(x * 0.5) / t); elseif (Float64(x + y) <= 2e+17) tmp = Float64(z * Float64(-0.5 / 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 ((x + y) <= -5e-13) tmp = (x * 0.5) / t; elseif ((x + y) <= 2e+17) tmp = z * (-0.5 / t); else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e-13], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 2e+17], N[(z * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{-13}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;x + y \leq 2 \cdot 10^{+17}:\\
\;\;\;\;z \cdot \frac{-0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < -4.9999999999999999e-13Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6439.4
Simplified39.4%
if -4.9999999999999999e-13 < (+.f64 x y) < 2e17Initial program 100.0%
Taylor expanded in z around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6480.0
Simplified80.0%
associate-/l*N/A
metadata-evalN/A
associate-/r*N/A
*-commutativeN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f6479.7
Applied egg-rr79.7%
if 2e17 < (+.f64 x y) Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6444.9
Simplified44.9%
Final simplification52.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* z -0.5) t))) (if (<= z -2.4e+74) t_1 (if (<= z 7e+43) (/ (+ x y) (* t 2.0)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (z * -0.5) / t;
double tmp;
if (z <= -2.4e+74) {
tmp = t_1;
} else if (z <= 7e+43) {
tmp = (x + y) / (t * 2.0);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = (z * (-0.5d0)) / t
if (z <= (-2.4d+74)) then
tmp = t_1
else if (z <= 7d+43) then
tmp = (x + y) / (t * 2.0d0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * -0.5) / t;
double tmp;
if (z <= -2.4e+74) {
tmp = t_1;
} else if (z <= 7e+43) {
tmp = (x + y) / (t * 2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * -0.5) / t tmp = 0 if z <= -2.4e+74: tmp = t_1 elif z <= 7e+43: tmp = (x + y) / (t * 2.0) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * -0.5) / t) tmp = 0.0 if (z <= -2.4e+74) tmp = t_1; elseif (z <= 7e+43) tmp = Float64(Float64(x + y) / Float64(t * 2.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * -0.5) / t; tmp = 0.0; if (z <= -2.4e+74) tmp = t_1; elseif (z <= 7e+43) tmp = (x + y) / (t * 2.0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[z, -2.4e+74], t$95$1, If[LessEqual[z, 7e+43], N[(N[(x + y), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot -0.5}{t}\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7 \cdot 10^{+43}:\\
\;\;\;\;\frac{x + y}{t \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.40000000000000008e74 or 7.0000000000000002e43 < z Initial program 100.0%
Taylor expanded in z around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6473.1
Simplified73.1%
if -2.40000000000000008e74 < z < 7.0000000000000002e43Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f6488.5
Simplified88.5%
Final simplification81.9%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e-202) (/ (- x z) (* t 2.0)) (/ (- y z) (* t 2.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-202) {
tmp = (x - z) / (t * 2.0);
} else {
tmp = (y - z) / (t * 2.0);
}
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) <= (-5d-202)) then
tmp = (x - z) / (t * 2.0d0)
else
tmp = (y - z) / (t * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-202) {
tmp = (x - z) / (t * 2.0);
} else {
tmp = (y - z) / (t * 2.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e-202: tmp = (x - z) / (t * 2.0) else: tmp = (y - z) / (t * 2.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e-202) tmp = Float64(Float64(x - z) / Float64(t * 2.0)); else tmp = Float64(Float64(y - z) / Float64(t * 2.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -5e-202) tmp = (x - z) / (t * 2.0); else tmp = (y - z) / (t * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e-202], N[(N[(x - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{-202}:\\
\;\;\;\;\frac{x - z}{t \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - z}{t \cdot 2}\\
\end{array}
\end{array}
if (+.f64 x y) < -4.99999999999999973e-202Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6465.1
Simplified65.1%
if -4.99999999999999973e-202 < (+.f64 x y) Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f6471.0
Simplified71.0%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) 2e+17) (/ (- x z) (* t 2.0)) (/ (* y 0.5) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= 2e+17) {
tmp = (x - 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 ((x + y) <= 2d+17) then
tmp = (x - 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 ((x + y) <= 2e+17) {
tmp = (x - z) / (t * 2.0);
} else {
tmp = (y * 0.5) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= 2e+17: tmp = (x - z) / (t * 2.0) else: tmp = (y * 0.5) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= 2e+17) tmp = Float64(Float64(x - 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 ((x + y) <= 2e+17) tmp = (x - z) / (t * 2.0); else tmp = (y * 0.5) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], 2e+17], N[(N[(x - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 2 \cdot 10^{+17}:\\
\;\;\;\;\frac{x - z}{t \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < 2e17Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6473.0
Simplified73.0%
if 2e17 < (+.f64 x y) Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6444.9
Simplified44.9%
Final simplification64.1%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e-13) (/ (* x 0.5) t) (* z (/ -0.5 t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-13) {
tmp = (x * 0.5) / t;
} else {
tmp = z * (-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) <= (-5d-13)) then
tmp = (x * 0.5d0) / t
else
tmp = z * ((-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) <= -5e-13) {
tmp = (x * 0.5) / t;
} else {
tmp = z * (-0.5 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e-13: tmp = (x * 0.5) / t else: tmp = z * (-0.5 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e-13) tmp = Float64(Float64(x * 0.5) / t); else tmp = Float64(z * Float64(-0.5 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -5e-13) tmp = (x * 0.5) / t; else tmp = z * (-0.5 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e-13], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], N[(z * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{-13}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{-0.5}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < -4.9999999999999999e-13Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6439.4
Simplified39.4%
if -4.9999999999999999e-13 < (+.f64 x y) Initial program 100.0%
Taylor expanded in z around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6448.8
Simplified48.8%
associate-/l*N/A
metadata-evalN/A
associate-/r*N/A
*-commutativeN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f6448.7
Applied egg-rr48.7%
Final simplification44.9%
(FPCore (x y z t) :precision binary64 (* z (/ -0.5 t)))
double code(double x, double y, double z, double t) {
return z * (-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 = z * ((-0.5d0) / t)
end function
public static double code(double x, double y, double z, double t) {
return z * (-0.5 / t);
}
def code(x, y, z, t): return z * (-0.5 / t)
function code(x, y, z, t) return Float64(z * Float64(-0.5 / t)) end
function tmp = code(x, y, z, t) tmp = z * (-0.5 / t); end
code[x_, y_, z_, t_] := N[(z * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \frac{-0.5}{t}
\end{array}
Initial program 100.0%
Taylor expanded in z around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6439.6
Simplified39.6%
associate-/l*N/A
metadata-evalN/A
associate-/r*N/A
*-commutativeN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f6439.5
Applied egg-rr39.5%
Final simplification39.5%
herbie shell --seed 2024196
(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)))