
(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%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (if (<= y -5.2e-193) (/ (* x 0.5) t) (if (<= y 2400000.0) (* (/ z t) -0.5) (* 0.5 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.2e-193) {
tmp = (x * 0.5) / t;
} else if (y <= 2400000.0) {
tmp = (z / t) * -0.5;
} 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 <= (-5.2d-193)) then
tmp = (x * 0.5d0) / t
else if (y <= 2400000.0d0) then
tmp = (z / t) * (-0.5d0)
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 <= -5.2e-193) {
tmp = (x * 0.5) / t;
} else if (y <= 2400000.0) {
tmp = (z / t) * -0.5;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.2e-193: tmp = (x * 0.5) / t elif y <= 2400000.0: tmp = (z / t) * -0.5 else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.2e-193) tmp = Float64(Float64(x * 0.5) / t); elseif (y <= 2400000.0) tmp = Float64(Float64(z / t) * -0.5); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5.2e-193) tmp = (x * 0.5) / t; elseif (y <= 2400000.0) tmp = (z / t) * -0.5; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.2e-193], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[y, 2400000.0], N[(N[(z / t), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-193}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{elif}\;y \leq 2400000:\\
\;\;\;\;\frac{z}{t} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -5.20000000000000015e-193Initial program 100.0%
Taylor expanded in x around inf 31.6%
associate-*r/31.6%
Simplified31.6%
if -5.20000000000000015e-193 < y < 2.4e6Initial program 100.0%
Taylor expanded in z around inf 57.0%
*-commutative57.0%
Simplified57.0%
if 2.4e6 < y Initial program 100.0%
Taylor expanded in y around inf 67.5%
Final simplification49.3%
(FPCore (x y z t) :precision binary64 (if (<= y 9e+96) (* 0.5 (/ (- x z) t)) (* 0.5 (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9e+96) {
tmp = 0.5 * ((x - 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 <= 9d+96) then
tmp = 0.5d0 * ((x - 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 <= 9e+96) {
tmp = 0.5 * ((x - z) / t);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9e+96: tmp = 0.5 * ((x - z) / t) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9e+96) tmp = Float64(0.5 * Float64(Float64(x - z) / 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 (y <= 9e+96) tmp = 0.5 * ((x - z) / t); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9e+96], N[(0.5 * N[(N[(x - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \frac{x - z}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < 8.99999999999999914e96Initial program 100.0%
Taylor expanded in y around 0 74.6%
if 8.99999999999999914e96 < y Initial program 100.0%
Taylor expanded in y around inf 79.5%
Final simplification75.3%
(FPCore (x y z t) :precision binary64 (if (<= x -4.2e-36) (* 0.5 (/ (- x z) t)) (* 0.5 (/ (- y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.2e-36) {
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 <= (-4.2d-36)) 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 <= -4.2e-36) {
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 <= -4.2e-36: 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 <= -4.2e-36) 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 <= -4.2e-36) 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, -4.2e-36], 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 -4.2 \cdot 10^{-36}:\\
\;\;\;\;0.5 \cdot \frac{x - z}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y - z}{t}\\
\end{array}
\end{array}
if x < -4.19999999999999982e-36Initial program 100.0%
Taylor expanded in y around 0 76.5%
if -4.19999999999999982e-36 < x Initial program 100.0%
Taylor expanded in x around 0 80.8%
Final simplification79.7%
(FPCore (x y z t) :precision binary64 (/ 0.5 (/ t (- y (- z x)))))
double code(double x, double y, double z, double t) {
return 0.5 / (t / (y - (z - x)));
}
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 / (y - (z - x)))
end function
public static double code(double x, double y, double z, double t) {
return 0.5 / (t / (y - (z - x)));
}
def code(x, y, z, t): return 0.5 / (t / (y - (z - x)))
function code(x, y, z, t) return Float64(0.5 / Float64(t / Float64(y - Float64(z - x)))) end
function tmp = code(x, y, z, t) tmp = 0.5 / (t / (y - (z - x))); end
code[x_, y_, z_, t_] := N[(0.5 / N[(t / N[(y - N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{\frac{t}{y - \left(z - x\right)}}
\end{array}
Initial program 100.0%
clear-num99.6%
inv-pow99.6%
*-commutative99.6%
*-un-lft-identity99.6%
times-frac99.6%
metadata-eval99.6%
associate--l+99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
associate-+l-99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z t) :precision binary64 (if (<= y 225000.0) (* (/ z t) -0.5) (* 0.5 (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 225000.0) {
tmp = (z / t) * -0.5;
} 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 <= 225000.0d0) then
tmp = (z / t) * (-0.5d0)
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 <= 225000.0) {
tmp = (z / t) * -0.5;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 225000.0: tmp = (z / t) * -0.5 else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 225000.0) tmp = Float64(Float64(z / t) * -0.5); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 225000.0) tmp = (z / t) * -0.5; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 225000.0], N[(N[(z / t), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 225000:\\
\;\;\;\;\frac{z}{t} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < 225000Initial program 100.0%
Taylor expanded in z around inf 45.8%
*-commutative45.8%
Simplified45.8%
if 225000 < y Initial program 100.0%
Taylor expanded in y around inf 67.5%
Final simplification51.0%
(FPCore (x y z t) :precision binary64 (* 0.5 (/ y t)))
double code(double x, double y, double z, double t) {
return 0.5 * (y / 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 * (y / t)
end function
public static double code(double x, double y, double z, double t) {
return 0.5 * (y / t);
}
def code(x, y, z, t): return 0.5 * (y / t)
function code(x, y, z, t) return Float64(0.5 * Float64(y / t)) end
function tmp = code(x, y, z, t) tmp = 0.5 * (y / t); end
code[x_, y_, z_, t_] := N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{y}{t}
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 38.2%
Final simplification38.2%
(FPCore (x y z t) :precision binary64 0.0)
double code(double x, double y, double z, double t) {
return 0.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 = 0.0d0
end function
public static double code(double x, double y, double z, double t) {
return 0.0;
}
def code(x, y, z, t): return 0.0
function code(x, y, z, t) return 0.0 end
function tmp = code(x, y, z, t) tmp = 0.0; end
code[x_, y_, z_, t_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
clear-num99.6%
inv-pow99.6%
*-commutative99.6%
*-un-lft-identity99.6%
times-frac99.6%
metadata-eval99.6%
associate--l+99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-*r/99.6%
count-299.6%
associate-/r/99.7%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
clear-num0.0%
+-inverses0.0%
+-inverses0.0%
+-commutative0.0%
associate-+l-0.0%
Applied egg-rr0.0%
Simplified4.7%
Final simplification4.7%
herbie shell --seed 2023279
(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)))