\[\left(\left(0 \leq d \land d \leq 1000000000\right) \land \left(0 \leq y \land y \leq 1000000000\right)\right) \land \left(0 \leq x \land x \leq 1000000000\right)\]
Math FPCore C Java Python Julia MATLAB Wolfram TeX \[\sqrt{{d}^{2} + {y}^{2}} - \sqrt{{d}^{2} + {x}^{2}}
\]
↓
\[\begin{array}{l}
t_0 := \sqrt{{d}^{2} + {y}^{2}} - \sqrt{{d}^{2} + {x}^{2}}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-161}:\\
\;\;\;\;\mathsf{hypot}\left(d, y\right) - \mathsf{hypot}\left(d, x\right)\\
\mathbf{elif}\;t_0 \leq 10^{-164}:\\
\;\;\;\;0.5 \cdot \left(\left(y - x\right) \cdot \frac{y + x}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(d, y\right) - e^{\log \left(\mathsf{hypot}\left(d, x\right)\right)}\\
\end{array}
\]
(FPCore (d y x)
:precision binary64
(- (sqrt (+ (pow d 2.0) (pow y 2.0))) (sqrt (+ (pow d 2.0) (pow x 2.0))))) ↓
(FPCore (d y x)
:precision binary64
(let* ((t_0
(-
(sqrt (+ (pow d 2.0) (pow y 2.0)))
(sqrt (+ (pow d 2.0) (pow x 2.0))))))
(if (<= t_0 -5e-161)
(- (hypot d y) (hypot d x))
(if (<= t_0 1e-164)
(* 0.5 (* (- y x) (/ (+ y x) d)))
(- (hypot d y) (exp (log (hypot d x)))))))) double code(double d, double y, double x) {
return sqrt((pow(d, 2.0) + pow(y, 2.0))) - sqrt((pow(d, 2.0) + pow(x, 2.0)));
}
↓
double code(double d, double y, double x) {
double t_0 = sqrt((pow(d, 2.0) + pow(y, 2.0))) - sqrt((pow(d, 2.0) + pow(x, 2.0)));
double tmp;
if (t_0 <= -5e-161) {
tmp = hypot(d, y) - hypot(d, x);
} else if (t_0 <= 1e-164) {
tmp = 0.5 * ((y - x) * ((y + x) / d));
} else {
tmp = hypot(d, y) - exp(log(hypot(d, x)));
}
return tmp;
}
public static double code(double d, double y, double x) {
return Math.sqrt((Math.pow(d, 2.0) + Math.pow(y, 2.0))) - Math.sqrt((Math.pow(d, 2.0) + Math.pow(x, 2.0)));
}
↓
public static double code(double d, double y, double x) {
double t_0 = Math.sqrt((Math.pow(d, 2.0) + Math.pow(y, 2.0))) - Math.sqrt((Math.pow(d, 2.0) + Math.pow(x, 2.0)));
double tmp;
if (t_0 <= -5e-161) {
tmp = Math.hypot(d, y) - Math.hypot(d, x);
} else if (t_0 <= 1e-164) {
tmp = 0.5 * ((y - x) * ((y + x) / d));
} else {
tmp = Math.hypot(d, y) - Math.exp(Math.log(Math.hypot(d, x)));
}
return tmp;
}
def code(d, y, x):
return math.sqrt((math.pow(d, 2.0) + math.pow(y, 2.0))) - math.sqrt((math.pow(d, 2.0) + math.pow(x, 2.0)))
↓
def code(d, y, x):
t_0 = math.sqrt((math.pow(d, 2.0) + math.pow(y, 2.0))) - math.sqrt((math.pow(d, 2.0) + math.pow(x, 2.0)))
tmp = 0
if t_0 <= -5e-161:
tmp = math.hypot(d, y) - math.hypot(d, x)
elif t_0 <= 1e-164:
tmp = 0.5 * ((y - x) * ((y + x) / d))
else:
tmp = math.hypot(d, y) - math.exp(math.log(math.hypot(d, x)))
return tmp
function code(d, y, x)
return Float64(sqrt(Float64((d ^ 2.0) + (y ^ 2.0))) - sqrt(Float64((d ^ 2.0) + (x ^ 2.0))))
end
↓
function code(d, y, x)
t_0 = Float64(sqrt(Float64((d ^ 2.0) + (y ^ 2.0))) - sqrt(Float64((d ^ 2.0) + (x ^ 2.0))))
tmp = 0.0
if (t_0 <= -5e-161)
tmp = Float64(hypot(d, y) - hypot(d, x));
elseif (t_0 <= 1e-164)
tmp = Float64(0.5 * Float64(Float64(y - x) * Float64(Float64(y + x) / d)));
else
tmp = Float64(hypot(d, y) - exp(log(hypot(d, x))));
end
return tmp
end
function tmp = code(d, y, x)
tmp = sqrt(((d ^ 2.0) + (y ^ 2.0))) - sqrt(((d ^ 2.0) + (x ^ 2.0)));
end
↓
function tmp_2 = code(d, y, x)
t_0 = sqrt(((d ^ 2.0) + (y ^ 2.0))) - sqrt(((d ^ 2.0) + (x ^ 2.0)));
tmp = 0.0;
if (t_0 <= -5e-161)
tmp = hypot(d, y) - hypot(d, x);
elseif (t_0 <= 1e-164)
tmp = 0.5 * ((y - x) * ((y + x) / d));
else
tmp = hypot(d, y) - exp(log(hypot(d, x)));
end
tmp_2 = tmp;
end
code[d_, y_, x_] := N[(N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
↓
code[d_, y_, x_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-161], N[(N[Sqrt[d ^ 2 + y ^ 2], $MachinePrecision] - N[Sqrt[d ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-164], N[(0.5 * N[(N[(y - x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[d ^ 2 + y ^ 2], $MachinePrecision] - N[Exp[N[Log[N[Sqrt[d ^ 2 + x ^ 2], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\sqrt{{d}^{2} + {y}^{2}} - \sqrt{{d}^{2} + {x}^{2}}
↓
\begin{array}{l}
t_0 := \sqrt{{d}^{2} + {y}^{2}} - \sqrt{{d}^{2} + {x}^{2}}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-161}:\\
\;\;\;\;\mathsf{hypot}\left(d, y\right) - \mathsf{hypot}\left(d, x\right)\\
\mathbf{elif}\;t_0 \leq 10^{-164}:\\
\;\;\;\;0.5 \cdot \left(\left(y - x\right) \cdot \frac{y + x}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(d, y\right) - e^{\log \left(\mathsf{hypot}\left(d, x\right)\right)}\\
\end{array}
Alternatives Alternative 1 Error 10.3 Cost 14344
\[\begin{array}{l}
t_0 := \mathsf{hypot}\left(d, y\right) - \mathsf{hypot}\left(d, x\right)\\
\mathbf{if}\;d \leq 1.2319179570799131 \cdot 10^{-88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 8.9492477663499 \cdot 10^{-63}:\\
\;\;\;\;\mathsf{fma}\left(y + x, \left(y - x\right) \cdot \frac{0.5}{d}, \frac{0.5}{d} \cdot \mathsf{fma}\left(x, -x, x \cdot x\right)\right)\\
\mathbf{elif}\;d \leq 3.322343319429862 \cdot 10^{-54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y - x\right) \cdot \frac{y + x}{d}\right)\\
\end{array}
\]
Alternative 2 Error 10.3 Cost 13516
\[\begin{array}{l}
t_0 := \mathsf{hypot}\left(d, y\right) - \mathsf{hypot}\left(d, x\right)\\
t_1 := 0.5 \cdot \left(\left(y - x\right) \cdot \frac{y + x}{d}\right)\\
\mathbf{if}\;d \leq 1.2319179570799131 \cdot 10^{-88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 8.9492477663499 \cdot 10^{-63}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 3.322343319429862 \cdot 10^{-54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 3 Error 14.1 Cost 1100
\[\begin{array}{l}
t_0 := \frac{0.5 \cdot \left(y \cdot y - x \cdot x\right)}{d}\\
\mathbf{if}\;d \leq 1.2319179570799131 \cdot 10^{-88}:\\
\;\;\;\;y - x\\
\mathbf{elif}\;d \leq 8.9492477663499 \cdot 10^{-63}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.322343319429862 \cdot 10^{-54}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 4 Error 13.2 Cost 1100
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(y - x\right) \cdot \frac{y + x}{d}\right)\\
\mathbf{if}\;d \leq 4.298715974037927 \cdot 10^{-89}:\\
\;\;\;\;y - x\\
\mathbf{elif}\;d \leq 8.9492477663499 \cdot 10^{-63}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.322343319429862 \cdot 10^{-54}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 5 Error 18.1 Cost 976
\[\begin{array}{l}
t_0 := x \cdot \frac{-0.5}{\frac{d}{x}}\\
\mathbf{if}\;d \leq 1.2319179570799131 \cdot 10^{-88}:\\
\;\;\;\;y - x\\
\mathbf{elif}\;d \leq 8.9492477663499 \cdot 10^{-63}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.3218755534067286 \cdot 10^{-50}:\\
\;\;\;\;y - x\\
\mathbf{elif}\;d \leq 1.1168624181670499 \cdot 10^{-10}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{\frac{d}{y}}\\
\end{array}
\]
Alternative 6 Error 17.8 Cost 580
\[\begin{array}{l}
\mathbf{if}\;d \leq 1.3218755534067286 \cdot 10^{-50}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{d} \cdot \left(y \cdot y\right)\\
\end{array}
\]
Alternative 7 Error 17.6 Cost 580
\[\begin{array}{l}
\mathbf{if}\;d \leq 1.3218755534067286 \cdot 10^{-50}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 0.5}{\frac{d}{y}}\\
\end{array}
\]
Alternative 8 Error 31.4 Cost 524
\[\begin{array}{l}
\mathbf{if}\;x \leq 4.595984908234627 \cdot 10^{-162}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \leq 3.7908572321525334 \cdot 10^{-129}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 1.165 \cdot 10^{-113}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\]
Alternative 9 Error 21.5 Cost 192
\[y - x
\]
Alternative 10 Error 41.8 Cost 64
\[y
\]