
(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%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (pow (* x (+ x (* y -2.0))) 0.25)))
(if (<= (- x y) -6e+147)
(sqrt y)
(if (<= (- x y) -500000.0)
t_0
(if (<= (- x y) -5e-53)
(pow (* y y) 0.25)
(if (<= (- x y) -5e-130)
t_0
(if (<= (- x y) -2e-183) (sqrt y) (sqrt (- x y)))))))))
double code(double x, double y) {
double t_0 = pow((x * (x + (y * -2.0))), 0.25);
double tmp;
if ((x - y) <= -6e+147) {
tmp = sqrt(y);
} else if ((x - y) <= -500000.0) {
tmp = t_0;
} else if ((x - y) <= -5e-53) {
tmp = pow((y * y), 0.25);
} else if ((x - y) <= -5e-130) {
tmp = t_0;
} else if ((x - y) <= -2e-183) {
tmp = sqrt(y);
} else {
tmp = sqrt((x - 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 ((x - y) <= (-6d+147)) then
tmp = sqrt(y)
else if ((x - y) <= (-500000.0d0)) then
tmp = t_0
else if ((x - y) <= (-5d-53)) then
tmp = (y * y) ** 0.25d0
else if ((x - y) <= (-5d-130)) then
tmp = t_0
else if ((x - y) <= (-2d-183)) then
tmp = sqrt(y)
else
tmp = sqrt((x - 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 ((x - y) <= -6e+147) {
tmp = Math.sqrt(y);
} else if ((x - y) <= -500000.0) {
tmp = t_0;
} else if ((x - y) <= -5e-53) {
tmp = Math.pow((y * y), 0.25);
} else if ((x - y) <= -5e-130) {
tmp = t_0;
} else if ((x - y) <= -2e-183) {
tmp = Math.sqrt(y);
} else {
tmp = Math.sqrt((x - y));
}
return tmp;
}
def code(x, y): t_0 = math.pow((x * (x + (y * -2.0))), 0.25) tmp = 0 if (x - y) <= -6e+147: tmp = math.sqrt(y) elif (x - y) <= -500000.0: tmp = t_0 elif (x - y) <= -5e-53: tmp = math.pow((y * y), 0.25) elif (x - y) <= -5e-130: tmp = t_0 elif (x - y) <= -2e-183: tmp = math.sqrt(y) else: tmp = math.sqrt((x - y)) return tmp
function code(x, y) t_0 = Float64(x * Float64(x + Float64(y * -2.0))) ^ 0.25 tmp = 0.0 if (Float64(x - y) <= -6e+147) tmp = sqrt(y); elseif (Float64(x - y) <= -500000.0) tmp = t_0; elseif (Float64(x - y) <= -5e-53) tmp = Float64(y * y) ^ 0.25; elseif (Float64(x - y) <= -5e-130) tmp = t_0; elseif (Float64(x - y) <= -2e-183) tmp = sqrt(y); else tmp = sqrt(Float64(x - y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * (x + (y * -2.0))) ^ 0.25; tmp = 0.0; if ((x - y) <= -6e+147) tmp = sqrt(y); elseif ((x - y) <= -500000.0) tmp = t_0; elseif ((x - y) <= -5e-53) tmp = (y * y) ^ 0.25; elseif ((x - y) <= -5e-130) tmp = t_0; elseif ((x - y) <= -2e-183) tmp = sqrt(y); else tmp = sqrt((x - 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[N[(x - y), $MachinePrecision], -6e+147], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -500000.0], t$95$0, If[LessEqual[N[(x - y), $MachinePrecision], -5e-53], N[Power[N[(y * y), $MachinePrecision], 0.25], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -5e-130], t$95$0, If[LessEqual[N[(x - y), $MachinePrecision], -2e-183], N[Sqrt[y], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\
\mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{elif}\;x - y \leq -500000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x - y \leq -5 \cdot 10^{-53}:\\
\;\;\;\;{\left(y \cdot y\right)}^{0.25}\\
\mathbf{elif}\;x - y \leq -5 \cdot 10^{-130}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\
\end{array}
\end{array}
if (-.f64 x y) < -5.99999999999999987e147 or -4.9999999999999996e-130 < (-.f64 x y) < -2.00000000000000001e-183Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down11.2%
neg-fabs11.2%
neg-fabs11.2%
sqr-abs11.2%
sub-neg11.2%
+-commutative11.2%
distribute-neg-in11.2%
remove-double-neg11.2%
sub-neg11.2%
sub-neg11.2%
+-commutative11.2%
distribute-neg-in11.2%
remove-double-neg11.2%
sub-neg11.2%
metadata-eval11.2%
Applied egg-rr11.2%
Taylor expanded in x around 0 59.1%
pow-base-159.1%
*-lft-identity59.1%
Simplified59.1%
if -5.99999999999999987e147 < (-.f64 x y) < -5e5 or -5e-53 < (-.f64 x y) < -4.9999999999999996e-130Initial program 99.9%
fabs-sub99.9%
Simplified99.9%
pow1/299.9%
sqr-pow99.1%
pow-prod-down99.9%
neg-fabs99.9%
neg-fabs99.9%
sqr-abs99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
sqr-neg100.0%
cancel-sign-sub-inv100.0%
distribute-lft-out--100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 63.8%
+-commutative63.8%
unpow263.8%
*-commutative63.8%
associate-*l*63.8%
metadata-eval63.8%
distribute-rgt-out63.8%
mul-1-neg63.8%
fma-def63.8%
fma-neg63.8%
distribute-lft-out63.8%
fma-neg63.8%
fma-def63.8%
mul-1-neg63.8%
distribute-rgt-out63.8%
metadata-eval63.8%
Simplified63.8%
if -5e5 < (-.f64 x y) < -5e-53Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.5%
pow-prod-down100.0%
neg-fabs100.0%
neg-fabs100.0%
sqr-abs100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt-in100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
sqr-neg100.0%
cancel-sign-sub-inv100.0%
distribute-lft-out--100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 81.1%
unpow281.1%
Simplified81.1%
if -2.00000000000000001e-183 < (-.f64 x y) Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down54.6%
neg-fabs54.6%
neg-fabs54.6%
sqr-abs54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
remove-double-neg54.6%
sub-neg54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
remove-double-neg54.6%
sub-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
unpow-prod-down98.3%
pow-sqr99.2%
metadata-eval99.2%
unpow1/299.2%
Applied egg-rr99.2%
Final simplification80.1%
(FPCore (x y)
:precision binary64
(if (<= (- x y) -1e+155)
(sqrt y)
(if (<= (- x y) -1e-189)
(pow (+ (* y (- y x)) (* x (- x y))) 0.25)
(sqrt (- x y)))))
double code(double x, double y) {
double tmp;
if ((x - y) <= -1e+155) {
tmp = sqrt(y);
} else if ((x - y) <= -1e-189) {
tmp = pow(((y * (y - x)) + (x * (x - y))), 0.25);
} else {
tmp = sqrt((x - 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) <= (-1d+155)) then
tmp = sqrt(y)
else if ((x - y) <= (-1d-189)) then
tmp = ((y * (y - x)) + (x * (x - y))) ** 0.25d0
else
tmp = sqrt((x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x - y) <= -1e+155) {
tmp = Math.sqrt(y);
} else if ((x - y) <= -1e-189) {
tmp = Math.pow(((y * (y - x)) + (x * (x - y))), 0.25);
} else {
tmp = Math.sqrt((x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x - y) <= -1e+155: tmp = math.sqrt(y) elif (x - y) <= -1e-189: tmp = math.pow(((y * (y - x)) + (x * (x - y))), 0.25) else: tmp = math.sqrt((x - y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(x - y) <= -1e+155) tmp = sqrt(y); elseif (Float64(x - y) <= -1e-189) tmp = Float64(Float64(y * Float64(y - x)) + Float64(x * Float64(x - y))) ^ 0.25; else tmp = sqrt(Float64(x - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x - y) <= -1e+155) tmp = sqrt(y); elseif ((x - y) <= -1e-189) tmp = ((y * (y - x)) + (x * (x - y))) ^ 0.25; else tmp = sqrt((x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -1e+155], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -1e-189], N[Power[N[(N[(y * N[(y - x), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\
\;\;\;\;{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\
\end{array}
\end{array}
if (-.f64 x y) < -1.00000000000000001e155Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.3%
pow-prod-down4.3%
neg-fabs4.3%
neg-fabs4.3%
sqr-abs4.3%
sub-neg4.3%
+-commutative4.3%
distribute-neg-in4.3%
remove-double-neg4.3%
sub-neg4.3%
sub-neg4.3%
+-commutative4.3%
distribute-neg-in4.3%
remove-double-neg4.3%
sub-neg4.3%
metadata-eval4.3%
Applied egg-rr4.3%
Taylor expanded in x around 0 57.1%
pow-base-157.1%
*-lft-identity57.1%
Simplified57.1%
if -1.00000000000000001e155 < (-.f64 x y) < -1.00000000000000007e-189Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down94.8%
neg-fabs94.8%
neg-fabs94.8%
sqr-abs94.8%
sub-neg94.8%
+-commutative94.8%
distribute-neg-in94.8%
remove-double-neg94.8%
sub-neg94.8%
sub-neg94.8%
+-commutative94.8%
distribute-neg-in94.8%
remove-double-neg94.8%
sub-neg94.8%
metadata-eval94.8%
Applied egg-rr94.8%
sub-neg94.8%
+-commutative94.8%
distribute-rgt-in94.8%
sub-neg94.8%
+-commutative94.8%
distribute-lft-in94.8%
sqr-neg94.8%
cancel-sign-sub-inv94.8%
distribute-lft-out--94.8%
Applied egg-rr94.8%
if -1.00000000000000007e-189 < (-.f64 x y) Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down55.0%
neg-fabs55.0%
neg-fabs55.0%
sqr-abs55.0%
sub-neg55.0%
+-commutative55.0%
distribute-neg-in55.0%
remove-double-neg55.0%
sub-neg55.0%
sub-neg55.0%
+-commutative55.0%
distribute-neg-in55.0%
remove-double-neg55.0%
sub-neg55.0%
metadata-eval55.0%
Applied egg-rr55.0%
unpow-prod-down99.1%
pow-sqr100.0%
metadata-eval100.0%
unpow1/2100.0%
Applied egg-rr100.0%
Final simplification88.3%
(FPCore (x y) :precision binary64 (if (<= (- x y) -1e+155) (sqrt y) (if (<= (- x y) -1e-189) (pow (* (- x y) (- x y)) 0.25) (sqrt (- x y)))))
double code(double x, double y) {
double tmp;
if ((x - y) <= -1e+155) {
tmp = sqrt(y);
} else if ((x - y) <= -1e-189) {
tmp = pow(((x - y) * (x - y)), 0.25);
} else {
tmp = sqrt((x - 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) <= (-1d+155)) then
tmp = sqrt(y)
else if ((x - y) <= (-1d-189)) then
tmp = ((x - y) * (x - y)) ** 0.25d0
else
tmp = sqrt((x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x - y) <= -1e+155) {
tmp = Math.sqrt(y);
} else if ((x - y) <= -1e-189) {
tmp = Math.pow(((x - y) * (x - y)), 0.25);
} else {
tmp = Math.sqrt((x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x - y) <= -1e+155: tmp = math.sqrt(y) elif (x - y) <= -1e-189: tmp = math.pow(((x - y) * (x - y)), 0.25) else: tmp = math.sqrt((x - y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(x - y) <= -1e+155) tmp = sqrt(y); elseif (Float64(x - y) <= -1e-189) tmp = Float64(Float64(x - y) * Float64(x - y)) ^ 0.25; else tmp = sqrt(Float64(x - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x - y) <= -1e+155) tmp = sqrt(y); elseif ((x - y) <= -1e-189) tmp = ((x - y) * (x - y)) ^ 0.25; else tmp = sqrt((x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -1e+155], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -1e-189], N[Power[N[(N[(x - y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\
\;\;\;\;{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\
\end{array}
\end{array}
if (-.f64 x y) < -1.00000000000000001e155Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.3%
pow-prod-down4.3%
neg-fabs4.3%
neg-fabs4.3%
sqr-abs4.3%
sub-neg4.3%
+-commutative4.3%
distribute-neg-in4.3%
remove-double-neg4.3%
sub-neg4.3%
sub-neg4.3%
+-commutative4.3%
distribute-neg-in4.3%
remove-double-neg4.3%
sub-neg4.3%
metadata-eval4.3%
Applied egg-rr4.3%
Taylor expanded in x around 0 57.1%
pow-base-157.1%
*-lft-identity57.1%
Simplified57.1%
if -1.00000000000000001e155 < (-.f64 x y) < -1.00000000000000007e-189Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down94.8%
neg-fabs94.8%
neg-fabs94.8%
sqr-abs94.8%
sub-neg94.8%
+-commutative94.8%
distribute-neg-in94.8%
remove-double-neg94.8%
sub-neg94.8%
sub-neg94.8%
+-commutative94.8%
distribute-neg-in94.8%
remove-double-neg94.8%
sub-neg94.8%
metadata-eval94.8%
Applied egg-rr94.8%
if -1.00000000000000007e-189 < (-.f64 x y) Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down55.0%
neg-fabs55.0%
neg-fabs55.0%
sqr-abs55.0%
sub-neg55.0%
+-commutative55.0%
distribute-neg-in55.0%
remove-double-neg55.0%
sub-neg55.0%
sub-neg55.0%
+-commutative55.0%
distribute-neg-in55.0%
remove-double-neg55.0%
sub-neg55.0%
metadata-eval55.0%
Applied egg-rr55.0%
unpow-prod-down99.1%
pow-sqr100.0%
metadata-eval100.0%
unpow1/2100.0%
Applied egg-rr100.0%
Final simplification88.3%
(FPCore (x y)
:precision binary64
(if (<= (- x y) -6e+147)
(sqrt y)
(if (<= (- x y) -500000.0)
(pow (* x x) 0.25)
(if (<= (- x y) -2e-183) (sqrt y) (sqrt (- x y))))))
double code(double x, double y) {
double tmp;
if ((x - y) <= -6e+147) {
tmp = sqrt(y);
} else if ((x - y) <= -500000.0) {
tmp = pow((x * x), 0.25);
} else if ((x - y) <= -2e-183) {
tmp = sqrt(y);
} else {
tmp = sqrt((x - 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) <= (-6d+147)) then
tmp = sqrt(y)
else if ((x - y) <= (-500000.0d0)) then
tmp = (x * x) ** 0.25d0
else if ((x - y) <= (-2d-183)) then
tmp = sqrt(y)
else
tmp = sqrt((x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x - y) <= -6e+147) {
tmp = Math.sqrt(y);
} else if ((x - y) <= -500000.0) {
tmp = Math.pow((x * x), 0.25);
} else if ((x - y) <= -2e-183) {
tmp = Math.sqrt(y);
} else {
tmp = Math.sqrt((x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x - y) <= -6e+147: tmp = math.sqrt(y) elif (x - y) <= -500000.0: tmp = math.pow((x * x), 0.25) elif (x - y) <= -2e-183: tmp = math.sqrt(y) else: tmp = math.sqrt((x - y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(x - y) <= -6e+147) tmp = sqrt(y); elseif (Float64(x - y) <= -500000.0) tmp = Float64(x * x) ^ 0.25; elseif (Float64(x - y) <= -2e-183) tmp = sqrt(y); else tmp = sqrt(Float64(x - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x - y) <= -6e+147) tmp = sqrt(y); elseif ((x - y) <= -500000.0) tmp = (x * x) ^ 0.25; elseif ((x - y) <= -2e-183) tmp = sqrt(y); else tmp = sqrt((x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -6e+147], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -500000.0], N[Power[N[(x * x), $MachinePrecision], 0.25], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -2e-183], N[Sqrt[y], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{elif}\;x - y \leq -500000:\\
\;\;\;\;{\left(x \cdot x\right)}^{0.25}\\
\mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\
\end{array}
\end{array}
if (-.f64 x y) < -5.99999999999999987e147 or -5e5 < (-.f64 x y) < -2.00000000000000001e-183Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.3%
pow-prod-down32.6%
neg-fabs32.6%
neg-fabs32.6%
sqr-abs32.6%
sub-neg32.6%
+-commutative32.6%
distribute-neg-in32.6%
remove-double-neg32.6%
sub-neg32.6%
sub-neg32.6%
+-commutative32.6%
distribute-neg-in32.6%
remove-double-neg32.6%
sub-neg32.6%
metadata-eval32.6%
Applied egg-rr32.6%
Taylor expanded in x around 0 57.5%
pow-base-157.5%
*-lft-identity57.5%
Simplified57.5%
if -5.99999999999999987e147 < (-.f64 x y) < -5e5Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down100.0%
neg-fabs100.0%
neg-fabs100.0%
sqr-abs100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 63.1%
unpow263.1%
Simplified63.1%
if -2.00000000000000001e-183 < (-.f64 x y) Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down54.6%
neg-fabs54.6%
neg-fabs54.6%
sqr-abs54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
remove-double-neg54.6%
sub-neg54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
remove-double-neg54.6%
sub-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
unpow-prod-down98.3%
pow-sqr99.2%
metadata-eval99.2%
unpow1/299.2%
Applied egg-rr99.2%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (<= (- x y) -2e-183) (sqrt y) (sqrt (- x y))))
double code(double x, double y) {
double tmp;
if ((x - y) <= -2e-183) {
tmp = sqrt(y);
} else {
tmp = sqrt((x - 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) <= (-2d-183)) then
tmp = sqrt(y)
else
tmp = sqrt((x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x - y) <= -2e-183) {
tmp = Math.sqrt(y);
} else {
tmp = Math.sqrt((x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x - y) <= -2e-183: tmp = math.sqrt(y) else: tmp = math.sqrt((x - y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(x - y) <= -2e-183) tmp = sqrt(y); else tmp = sqrt(Float64(x - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x - y) <= -2e-183) tmp = sqrt(y); else tmp = sqrt((x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -2e-183], N[Sqrt[y], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\sqrt{y}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\
\end{array}
\end{array}
if (-.f64 x y) < -2.00000000000000001e-183Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down54.2%
neg-fabs54.2%
neg-fabs54.2%
sqr-abs54.2%
sub-neg54.2%
+-commutative54.2%
distribute-neg-in54.2%
remove-double-neg54.2%
sub-neg54.2%
sub-neg54.2%
+-commutative54.2%
distribute-neg-in54.2%
remove-double-neg54.2%
sub-neg54.2%
metadata-eval54.2%
Applied egg-rr54.2%
Taylor expanded in x around 0 51.3%
pow-base-151.3%
*-lft-identity51.3%
Simplified51.3%
if -2.00000000000000001e-183 < (-.f64 x y) Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down54.6%
neg-fabs54.6%
neg-fabs54.6%
sqr-abs54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
remove-double-neg54.6%
sub-neg54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
remove-double-neg54.6%
sub-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
unpow-prod-down98.3%
pow-sqr99.2%
metadata-eval99.2%
unpow1/299.2%
Applied egg-rr99.2%
Final simplification74.1%
(FPCore (x y) :precision binary64 (if (<= x 2.4e-164) 1.0 (sqrt x)))
double code(double x, double y) {
double tmp;
if (x <= 2.4e-164) {
tmp = 1.0;
} else {
tmp = sqrt(x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.4d-164) then
tmp = 1.0d0
else
tmp = sqrt(x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.4e-164) {
tmp = 1.0;
} else {
tmp = Math.sqrt(x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.4e-164: tmp = 1.0 else: tmp = math.sqrt(x) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.4e-164) tmp = 1.0; else tmp = sqrt(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.4e-164) tmp = 1.0; else tmp = sqrt(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.4e-164], 1.0, N[Sqrt[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-164}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x}\\
\end{array}
\end{array}
if x < 2.39999999999999983e-164Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down52.4%
neg-fabs52.4%
neg-fabs52.4%
sqr-abs52.4%
sub-neg52.4%
+-commutative52.4%
distribute-neg-in52.4%
remove-double-neg52.4%
sub-neg52.4%
sub-neg52.4%
+-commutative52.4%
distribute-neg-in52.4%
remove-double-neg52.4%
sub-neg52.4%
metadata-eval52.4%
Applied egg-rr52.4%
Taylor expanded in x around inf 25.2%
unpow225.2%
Simplified25.2%
Applied egg-rr6.9%
Simplified6.9%
if 2.39999999999999983e-164 < x Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down58.1%
neg-fabs58.1%
neg-fabs58.1%
sqr-abs58.1%
sub-neg58.1%
+-commutative58.1%
distribute-neg-in58.1%
remove-double-neg58.1%
sub-neg58.1%
sub-neg58.1%
+-commutative58.1%
distribute-neg-in58.1%
remove-double-neg58.1%
sub-neg58.1%
metadata-eval58.1%
Applied egg-rr58.1%
Taylor expanded in x around inf 67.4%
Final simplification28.4%
(FPCore (x y) :precision binary64 (if (<= y 3.2e-156) (sqrt x) (sqrt y)))
double code(double x, double y) {
double tmp;
if (y <= 3.2e-156) {
tmp = sqrt(x);
} 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 <= 3.2d-156) then
tmp = sqrt(x)
else
tmp = sqrt(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.2e-156) {
tmp = Math.sqrt(x);
} else {
tmp = Math.sqrt(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.2e-156: tmp = math.sqrt(x) else: tmp = math.sqrt(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.2e-156) tmp = sqrt(x); else tmp = sqrt(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.2e-156) tmp = sqrt(x); else tmp = sqrt(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.2e-156], N[Sqrt[x], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{-156}:\\
\;\;\;\;\sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\
\end{array}
\end{array}
if y < 3.19999999999999982e-156Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.1%
pow-prod-down59.0%
neg-fabs59.0%
neg-fabs59.0%
sqr-abs59.0%
sub-neg59.0%
+-commutative59.0%
distribute-neg-in59.0%
remove-double-neg59.0%
sub-neg59.0%
sub-neg59.0%
+-commutative59.0%
distribute-neg-in59.0%
remove-double-neg59.0%
sub-neg59.0%
metadata-eval59.0%
Applied egg-rr59.0%
Taylor expanded in x around inf 32.0%
if 3.19999999999999982e-156 < y Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.3%
pow-prod-down45.6%
neg-fabs45.6%
neg-fabs45.6%
sqr-abs45.6%
sub-neg45.6%
+-commutative45.6%
distribute-neg-in45.6%
remove-double-neg45.6%
sub-neg45.6%
sub-neg45.6%
+-commutative45.6%
distribute-neg-in45.6%
remove-double-neg45.6%
sub-neg45.6%
metadata-eval45.6%
Applied egg-rr45.6%
Taylor expanded in x around 0 75.8%
pow-base-175.8%
*-lft-identity75.8%
Simplified75.8%
Final simplification47.0%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
fabs-sub100.0%
Simplified100.0%
pow1/2100.0%
sqr-pow99.2%
pow-prod-down54.4%
neg-fabs54.4%
neg-fabs54.4%
sqr-abs54.4%
sub-neg54.4%
+-commutative54.4%
distribute-neg-in54.4%
remove-double-neg54.4%
sub-neg54.4%
sub-neg54.4%
+-commutative54.4%
distribute-neg-in54.4%
remove-double-neg54.4%
sub-neg54.4%
metadata-eval54.4%
Applied egg-rr54.4%
Taylor expanded in x around inf 31.3%
unpow231.3%
Simplified31.3%
Applied egg-rr7.0%
Simplified7.0%
Final simplification7.0%
herbie shell --seed 2023297
(FPCore (x y)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, C"
:precision binary64
(sqrt (fabs (- x y))))