
(FPCore (x y) :precision binary64 (sqrt (fabs (- x y))))
double code(double x, double y) {
return sqrt(fabs((x - y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(abs((x - y)))
end function
public static double code(double x, double y) {
return Math.sqrt(Math.abs((x - y)));
}
def code(x, y): return math.sqrt(math.fabs((x - y)))
function code(x, y) return sqrt(abs(Float64(x - y))) end
function tmp = code(x, y) tmp = sqrt(abs((x - y))); end
code[x_, y_] := N[Sqrt[N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|x - y\right|}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (sqrt (fabs (- x y))))
double code(double x, double y) {
return sqrt(fabs((x - y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(abs((x - y)))
end function
public static double code(double x, double y) {
return Math.sqrt(Math.abs((x - y)));
}
def code(x, y): return math.sqrt(math.fabs((x - y)))
function code(x, y) return sqrt(abs(Float64(x - y))) end
function tmp = code(x, y) tmp = sqrt(abs((x - y))); end
code[x_, y_] := N[Sqrt[N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|x - y\right|}
\end{array}
(FPCore (x y) :precision binary64 (sqrt (fabs (- x y))))
double code(double x, double y) {
return sqrt(fabs((x - y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(abs((x - y)))
end function
public static double code(double x, double y) {
return Math.sqrt(Math.abs((x - y)));
}
def code(x, y): return math.sqrt(math.fabs((x - y)))
function code(x, y) return sqrt(abs(Float64(x - y))) end
function tmp = code(x, y) tmp = sqrt(abs((x - y))); end
code[x_, y_] := N[Sqrt[N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|x - y\right|}
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (if (<= y 6.8e-158) (sqrt (fabs x)) (if (<= y 1.02e+127) (pow (/ (- x y) (/ 1.0 (- x y))) 0.25) (sqrt y))))
double code(double x, double y) {
double tmp;
if (y <= 6.8e-158) {
tmp = sqrt(fabs(x));
} else if (y <= 1.02e+127) {
tmp = pow(((x - y) / (1.0 / (x - y))), 0.25);
} else {
tmp = sqrt(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 6.8d-158) then
tmp = sqrt(abs(x))
else if (y <= 1.02d+127) then
tmp = ((x - y) / (1.0d0 / (x - y))) ** 0.25d0
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 6.8e-158) {
tmp = Math.sqrt(Math.abs(x));
} else if (y <= 1.02e+127) {
tmp = Math.pow(((x - y) / (1.0 / (x - y))), 0.25);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 6.8e-158: tmp = math.sqrt(math.fabs(x)) elif y <= 1.02e+127: tmp = math.pow(((x - y) / (1.0 / (x - y))), 0.25) else: tmp = math.sqrt(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 6.8e-158) tmp = sqrt(abs(x)); elseif (y <= 1.02e+127) tmp = Float64(Float64(x - y) / Float64(1.0 / Float64(x - y))) ^ 0.25; else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.8e-158) tmp = sqrt(abs(x)); elseif (y <= 1.02e+127) tmp = ((x - y) / (1.0 / (x - y))) ^ 0.25; else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 6.8e-158], N[Sqrt[N[Abs[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 1.02e+127], N[Power[N[(N[(x - y), $MachinePrecision] / N[(1.0 / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.8 \cdot 10^{-158}:\\
\;\;\;\;\sqrt{\left|x\right|}\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+127}:\\
\;\;\;\;{\left(\frac{x - y}{\frac{1}{x - y}}\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if y < 6.7999999999999999e-158Initial program 100.0%
Taylor expanded in x around inf 0
Simplified0
if 6.7999999999999999e-158 < y < 1.02e127Initial program 100.0%
Applied egg-rr0
Applied egg-rr0
if 1.02e127 < y Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
(FPCore (x y)
:precision binary64
(let* ((t_0 (pow (* x (+ x (* y -2.0))) 0.25)))
(if (<= y 2.1e-239)
t_0
(if (<= y 4.5e-120)
(sqrt y)
(if (<= y 8.5e-100)
t_0
(if (<= y 7.2e+126) (pow (* y (+ y (* x -2.0))) 0.25) (sqrt y)))))))
double code(double x, double y) {
double t_0 = pow((x * (x + (y * -2.0))), 0.25);
double tmp;
if (y <= 2.1e-239) {
tmp = t_0;
} else if (y <= 4.5e-120) {
tmp = sqrt(y);
} else if (y <= 8.5e-100) {
tmp = t_0;
} else if (y <= 7.2e+126) {
tmp = pow((y * (y + (x * -2.0))), 0.25);
} else {
tmp = sqrt(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * (x + (y * (-2.0d0)))) ** 0.25d0
if (y <= 2.1d-239) then
tmp = t_0
else if (y <= 4.5d-120) then
tmp = sqrt(y)
else if (y <= 8.5d-100) then
tmp = t_0
else if (y <= 7.2d+126) then
tmp = (y * (y + (x * (-2.0d0)))) ** 0.25d0
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.pow((x * (x + (y * -2.0))), 0.25);
double tmp;
if (y <= 2.1e-239) {
tmp = t_0;
} else if (y <= 4.5e-120) {
tmp = Math.sqrt(y);
} else if (y <= 8.5e-100) {
tmp = t_0;
} else if (y <= 7.2e+126) {
tmp = Math.pow((y * (y + (x * -2.0))), 0.25);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): t_0 = math.pow((x * (x + (y * -2.0))), 0.25) tmp = 0 if y <= 2.1e-239: tmp = t_0 elif y <= 4.5e-120: tmp = math.sqrt(y) elif y <= 8.5e-100: tmp = t_0 elif y <= 7.2e+126: tmp = math.pow((y * (y + (x * -2.0))), 0.25) else: tmp = math.sqrt(y) return tmp
function code(x, y) t_0 = Float64(x * Float64(x + Float64(y * -2.0))) ^ 0.25 tmp = 0.0 if (y <= 2.1e-239) tmp = t_0; elseif (y <= 4.5e-120) tmp = sqrt(y); elseif (y <= 8.5e-100) tmp = t_0; elseif (y <= 7.2e+126) tmp = Float64(y * Float64(y + Float64(x * -2.0))) ^ 0.25; else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * (x + (y * -2.0))) ^ 0.25; tmp = 0.0; if (y <= 2.1e-239) tmp = t_0; elseif (y <= 4.5e-120) tmp = sqrt(y); elseif (y <= 8.5e-100) tmp = t_0; elseif (y <= 7.2e+126) tmp = (y * (y + (x * -2.0))) ^ 0.25; else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Power[N[(x * N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[y, 2.1e-239], t$95$0, If[LessEqual[y, 4.5e-120], N[Sqrt[y], $MachinePrecision], If[LessEqual[y, 8.5e-100], t$95$0, If[LessEqual[y, 7.2e+126], N[Power[N[(y * N[(y + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\
\mathbf{if}\;y \leq 2.1 \cdot 10^{-239}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-120}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-100}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{+126}:\\
\;\;\;\;{\left(y \cdot \left(y + x \cdot -2\right)\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if y < 2.1000000000000002e-239 or 4.5e-120 < y < 8.50000000000000017e-100Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around inf 0
Simplified0
if 2.1000000000000002e-239 < y < 4.5e-120 or 7.2000000000000001e126 < y Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
if 8.50000000000000017e-100 < y < 7.2000000000000001e126Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y) :precision binary64 (if (<= (- x y) -5e+154) (sqrt y) (if (<= (- x y) -1e-152) (pow (* (- x y) (- x y)) 0.25) (sqrt y))))
double code(double x, double y) {
double tmp;
if ((x - y) <= -5e+154) {
tmp = sqrt(y);
} else if ((x - y) <= -1e-152) {
tmp = pow(((x - y) * (x - y)), 0.25);
} else {
tmp = sqrt(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x - y) <= (-5d+154)) then
tmp = sqrt(y)
else if ((x - y) <= (-1d-152)) then
tmp = ((x - y) * (x - y)) ** 0.25d0
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x - y) <= -5e+154) {
tmp = Math.sqrt(y);
} else if ((x - y) <= -1e-152) {
tmp = Math.pow(((x - y) * (x - y)), 0.25);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x - y) <= -5e+154: tmp = math.sqrt(y) elif (x - y) <= -1e-152: tmp = math.pow(((x - y) * (x - y)), 0.25) else: tmp = math.sqrt(y) return tmp
function code(x, y) tmp = 0.0 if (Float64(x - y) <= -5e+154) tmp = sqrt(y); elseif (Float64(x - y) <= -1e-152) tmp = Float64(Float64(x - y) * Float64(x - y)) ^ 0.25; else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x - y) <= -5e+154) tmp = sqrt(y); elseif ((x - y) <= -1e-152) tmp = ((x - y) * (x - y)) ^ 0.25; else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -5e+154], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -1e-152], N[Power[N[(N[(x - y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -5 \cdot 10^{+154}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{elif}\;x - y \leq -1 \cdot 10^{-152}:\\
\;\;\;\;{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if (-.f64 x y) < -5.00000000000000004e154 or -1.00000000000000007e-152 < (-.f64 x y) Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
if -5.00000000000000004e154 < (-.f64 x y) < -1.00000000000000007e-152Initial program 100.0%
Applied egg-rr0
(FPCore (x y) :precision binary64 (if (<= y 2.1e-239) (pow (* x (+ x (* y -2.0))) 0.25) (sqrt y)))
double code(double x, double y) {
double tmp;
if (y <= 2.1e-239) {
tmp = pow((x * (x + (y * -2.0))), 0.25);
} else {
tmp = sqrt(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.1d-239) then
tmp = (x * (x + (y * (-2.0d0)))) ** 0.25d0
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.1e-239) {
tmp = Math.pow((x * (x + (y * -2.0))), 0.25);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.1e-239: tmp = math.pow((x * (x + (y * -2.0))), 0.25) else: tmp = math.sqrt(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.1e-239) tmp = Float64(x * Float64(x + Float64(y * -2.0))) ^ 0.25; else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.1e-239) tmp = (x * (x + (y * -2.0))) ^ 0.25; else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.1e-239], N[Power[N[(x * N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{-239}:\\
\;\;\;\;{\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if y < 2.1000000000000002e-239Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around inf 0
Simplified0
if 2.1000000000000002e-239 < y Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
(FPCore (x y) :precision binary64 (if (<= y 4.3e-240) (pow (* (- x y) x) 0.25) (sqrt y)))
double code(double x, double y) {
double tmp;
if (y <= 4.3e-240) {
tmp = pow(((x - y) * x), 0.25);
} else {
tmp = sqrt(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.3d-240) then
tmp = ((x - y) * x) ** 0.25d0
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.3e-240) {
tmp = Math.pow(((x - y) * x), 0.25);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.3e-240: tmp = math.pow(((x - y) * x), 0.25) else: tmp = math.sqrt(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.3e-240) tmp = Float64(Float64(x - y) * x) ^ 0.25; else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.3e-240) tmp = ((x - y) * x) ^ 0.25; else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.3e-240], N[Power[N[(N[(x - y), $MachinePrecision] * x), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{-240}:\\
\;\;\;\;{\left(\left(x - y\right) \cdot x\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if y < 4.30000000000000013e-240Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around inf 0
Simplified0
if 4.30000000000000013e-240 < y Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
(FPCore (x y) :precision binary64 (if (<= y 2.1e-239) (pow (* x x) 0.25) (sqrt y)))
double code(double x, double y) {
double tmp;
if (y <= 2.1e-239) {
tmp = pow((x * x), 0.25);
} else {
tmp = sqrt(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.1d-239) then
tmp = (x * x) ** 0.25d0
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.1e-239) {
tmp = Math.pow((x * x), 0.25);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.1e-239: tmp = math.pow((x * x), 0.25) else: tmp = math.sqrt(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.1e-239) tmp = Float64(x * x) ^ 0.25; else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.1e-239) tmp = (x * x) ^ 0.25; else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.1e-239], N[Power[N[(x * x), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{-239}:\\
\;\;\;\;{\left(x \cdot x\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if y < 2.1000000000000002e-239Initial program 100.0%
Taylor expanded in x around inf 0
Simplified0
Applied egg-rr0
if 2.1000000000000002e-239 < y Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
(FPCore (x y) :precision binary64 (sqrt y))
double code(double x, double y) {
return sqrt(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(y)
end function
public static double code(double x, double y) {
return Math.sqrt(y);
}
def code(x, y): return math.sqrt(y)
function code(x, y) return sqrt(y) end
function tmp = code(x, y) tmp = sqrt(y); end
code[x_, y_] := N[Sqrt[y], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{y}
\end{array}
Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
(FPCore (x y) :precision binary64 (sqrt x))
double code(double x, double y) {
return sqrt(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x)
end function
public static double code(double x, double y) {
return Math.sqrt(x);
}
def code(x, y): return math.sqrt(x)
function code(x, y) return sqrt(x) end
function tmp = code(x, y) tmp = sqrt(x); end
code[x_, y_] := N[Sqrt[x], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x}
\end{array}
Initial program 100.0%
Applied egg-rr0
Taylor expanded in x around inf 0
Simplified0
herbie shell --seed 2024110
(FPCore (x y)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, C"
:precision binary64
(sqrt (fabs (- x y))))