\[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\sqrt{re \cdot re + im \cdot im} - re \leq 0:\\
\;\;\;\;0.5 \cdot \left(\begin{array}{l}
\mathbf{if}\;\frac{1}{re} \ne 0:\\
\;\;\;\;\frac{1}{{\left(\frac{1}{re}\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{re}}\\
\end{array} \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(re - \mathsf{hypot}\left(re, im\right)\right)}\\
\end{array}
\]
(FPCore (re im)
:precision binary64
(* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))
↓
(FPCore (re im)
:precision binary64
(if (<= (- (sqrt (+ (* re re) (* im im))) re) 0.0)
(*
0.5
(*
(if (!= (/ 1.0 re) 0.0) (/ 1.0 (pow (/ 1.0 re) -0.5)) (sqrt (/ 1.0 re)))
im))
(* 0.5 (sqrt (* -2.0 (- re (hypot re im)))))))double code(double re, double im) {
return 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
}
↓
double code(double re, double im) {
double tmp_1;
if ((sqrt(((re * re) + (im * im))) - re) <= 0.0) {
double tmp_2;
if ((1.0 / re) != 0.0) {
tmp_2 = 1.0 / pow((1.0 / re), -0.5);
} else {
tmp_2 = sqrt((1.0 / re));
}
tmp_1 = 0.5 * (tmp_2 * im);
} else {
tmp_1 = 0.5 * sqrt((-2.0 * (re - hypot(re, im))));
}
return tmp_1;
}
public static double code(double re, double im) {
return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((re * re) + (im * im))) - re)));
}
↓
public static double code(double re, double im) {
double tmp_1;
if ((Math.sqrt(((re * re) + (im * im))) - re) <= 0.0) {
double tmp_2;
if ((1.0 / re) != 0.0) {
tmp_2 = 1.0 / Math.pow((1.0 / re), -0.5);
} else {
tmp_2 = Math.sqrt((1.0 / re));
}
tmp_1 = 0.5 * (tmp_2 * im);
} else {
tmp_1 = 0.5 * Math.sqrt((-2.0 * (re - Math.hypot(re, im))));
}
return tmp_1;
}
def code(re, im):
return 0.5 * math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) - re)))
↓
def code(re, im):
tmp_1 = 0
if (math.sqrt(((re * re) + (im * im))) - re) <= 0.0:
tmp_2 = 0
if (1.0 / re) != 0.0:
tmp_2 = 1.0 / math.pow((1.0 / re), -0.5)
else:
tmp_2 = math.sqrt((1.0 / re))
tmp_1 = 0.5 * (tmp_2 * im)
else:
tmp_1 = 0.5 * math.sqrt((-2.0 * (re - math.hypot(re, im))))
return tmp_1
function code(re, im)
return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re))))
end
↓
function code(re, im)
tmp_1 = 0.0
if (Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re) <= 0.0)
tmp_2 = 0.0
if (Float64(1.0 / re) != 0.0)
tmp_2 = Float64(1.0 / (Float64(1.0 / re) ^ -0.5));
else
tmp_2 = sqrt(Float64(1.0 / re));
end
tmp_1 = Float64(0.5 * Float64(tmp_2 * im));
else
tmp_1 = Float64(0.5 * sqrt(Float64(-2.0 * Float64(re - hypot(re, im)))));
end
return tmp_1
end
function tmp = code(re, im)
tmp = 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
end
↓
function tmp_4 = code(re, im)
tmp_2 = 0.0;
if ((sqrt(((re * re) + (im * im))) - re) <= 0.0)
tmp_3 = 0.0;
if ((1.0 / re) ~= 0.0)
tmp_3 = 1.0 / ((1.0 / re) ^ -0.5);
else
tmp_3 = sqrt((1.0 / re));
end
tmp_2 = 0.5 * (tmp_3 * im);
else
tmp_2 = 0.5 * sqrt((-2.0 * (re - hypot(re, im))));
end
tmp_4 = tmp_2;
end
code[re_, im_] := N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
↓
code[re_, im_] := If[LessEqual[N[(N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision], 0.0], N[(0.5 * N[(If[Unequal[N[(1.0 / re), $MachinePrecision], 0.0], N[(1.0 / N[Power[N[(1.0 / re), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]] * im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(-2.0 * N[(re - N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}
↓
\begin{array}{l}
\mathbf{if}\;\sqrt{re \cdot re + im \cdot im} - re \leq 0:\\
\;\;\;\;0.5 \cdot \left(\begin{array}{l}
\mathbf{if}\;\frac{1}{re} \ne 0:\\
\;\;\;\;\frac{1}{{\left(\frac{1}{re}\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{re}}\\
\end{array} \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(re - \mathsf{hypot}\left(re, im\right)\right)}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 15.7 |
|---|
| Cost | 7564 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq -1.1 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(2 \cdot re\right)}\\
\mathbf{elif}\;re \leq 8 \cdot 10^{-107}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(re - im\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\begin{array}{l}
\mathbf{if}\;\frac{1}{re} \ne 0:\\
\;\;\;\;\frac{1}{{\left(\frac{1}{re}\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{re}}\\
\end{array} \cdot im\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 18.4 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq -1.1 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(2 \cdot re\right)}\\
\mathbf{elif}\;re \leq 5.1 \cdot 10^{+61}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(re - im\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot \frac{im}{re}}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 15.7 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq -5.8 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(2 \cdot re\right)}\\
\mathbf{elif}\;re \leq 7.6 \cdot 10^{-107}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(re - im\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{re}} \cdot im\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 15.7 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq -3.2 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(2 \cdot re\right)}\\
\mathbf{elif}\;re \leq 2.4 \cdot 10^{-109}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(re - im\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sqrt{\frac{1}{re}}\right) \cdot im\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 23.0 |
|---|
| Cost | 6980 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq -1.25 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot \sqrt{-2 \cdot \left(2 \cdot re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 64.0 |
|---|
| Cost | 6720 |
|---|
\[0.5 \cdot \sqrt{-2 \cdot im}
\]
| Alternative 7 |
|---|
| Error | 59.8 |
|---|
| Cost | 6720 |
|---|
\[0.5 \cdot \sqrt{-2 \cdot re}
\]
| Alternative 8 |
|---|
| Error | 30.4 |
|---|
| Cost | 6720 |
|---|
\[0.5 \cdot \sqrt{2 \cdot im}
\]