\[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;re \leq -1.046441282610084 \cdot 10^{+39}:\\
\;\;\;\;0.5 \cdot \left|im \cdot \sqrt{\frac{-1}{re}}\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 (<= re -1.046441282610084e+39)
(* 0.5 (fabs (* im (sqrt (/ -1.0 re)))))
(* 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;
if (re <= -1.046441282610084e+39) {
tmp = 0.5 * fabs((im * sqrt((-1.0 / re))));
} else {
tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
}
return tmp;
}
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;
if (re <= -1.046441282610084e+39) {
tmp = 0.5 * Math.abs((im * Math.sqrt((-1.0 / re))));
} else {
tmp = 0.5 * Math.sqrt((2.0 * (re + Math.hypot(re, im))));
}
return tmp;
}
def code(re, im):
return 0.5 * math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) + re)))
↓
def code(re, im):
tmp = 0
if re <= -1.046441282610084e+39:
tmp = 0.5 * math.fabs((im * math.sqrt((-1.0 / re))))
else:
tmp = 0.5 * math.sqrt((2.0 * (re + math.hypot(re, im))))
return tmp
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 = 0.0
if (re <= -1.046441282610084e+39)
tmp = Float64(0.5 * abs(Float64(im * sqrt(Float64(-1.0 / re)))));
else
tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re + hypot(re, im)))));
end
return tmp
end
function tmp = code(re, im)
tmp = 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) + re)));
end
↓
function tmp_2 = code(re, im)
tmp = 0.0;
if (re <= -1.046441282610084e+39)
tmp = 0.5 * abs((im * sqrt((-1.0 / re))));
else
tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
end
tmp_2 = tmp;
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[re, -1.046441282610084e+39], N[(0.5 * N[Abs[N[(im * N[Sqrt[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $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}\;re \leq -1.046441282610084 \cdot 10^{+39}:\\
\;\;\;\;0.5 \cdot \left|im \cdot \sqrt{\frac{-1}{re}}\right|\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 26.6 |
|---|
| Cost | 14172 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\
t_1 := 0.5 \cdot \left|im \cdot \sqrt{\frac{-1}{re}}\right|\\
t_2 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{if}\;im \leq -5.580850603196456 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -799693.4838634767:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -6.655822479294364 \cdot 10^{-103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -1.1289079449687082 \cdot 10^{-300}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 4.0628426208765444 \cdot 10^{-132}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 2.011744924990974 \cdot 10^{-62}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2.7563346312568003 \cdot 10^{-60}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{re + im} \cdot \sqrt{2}\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 26.6 |
|---|
| Cost | 14040 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\
t_1 := 0.5 \cdot \left|im \cdot \sqrt{\frac{-1}{re}}\right|\\
t_2 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{if}\;im \leq -5.580850603196456 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -799693.4838634767:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -6.655822479294364 \cdot 10^{-103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -1.1289079449687082 \cdot 10^{-300}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 4.0628426208765444 \cdot 10^{-132}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 2.011744924990974 \cdot 10^{-62}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2.7563346312568003 \cdot 10^{-60}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 26.5 |
|---|
| Cost | 7640 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\
t_1 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{if}\;im \leq -5.580850603196456 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -799693.4838634767:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -6.259835303791085 \cdot 10^{-191}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 4.0628426208765444 \cdot 10^{-132}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2.011744924990974 \cdot 10^{-62}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{\frac{-1}{re}}\right)\\
\mathbf{elif}\;im \leq 2.7563346312568003 \cdot 10^{-60}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 26.8 |
|---|
| Cost | 7512 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\
t_1 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{if}\;im \leq -5.580850603196456 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -799693.4838634767:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -6.259835303791085 \cdot 10^{-191}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 4.0628426208765444 \cdot 10^{-132}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2.011744924990974 \cdot 10^{-62}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{\frac{-1}{re}}\right)\\
\mathbf{elif}\;im \leq 2.7563346312568003 \cdot 10^{-60}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 26.9 |
|---|
| Cost | 7248 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\
t_1 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{if}\;im \leq -5.580850603196456 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -799693.4838634767:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -6.259835303791085 \cdot 10^{-191}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.7563346312568003 \cdot 10^{-60}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 35.7 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq -1.046441282610084 \cdot 10^{+39}:\\
\;\;\;\;0.5 \cdot \left(4 \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;re \leq 9.010547225204561 \cdot 10^{-83}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 43.9 |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq 6.395369297180332 \cdot 10^{-307}:\\
\;\;\;\;0.5 \cdot \left(4 \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 58.3 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;im \cdot im \leq 4 \cdot 10^{-305}:\\
\;\;\;\;0.5 \cdot \left(4 \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|im\right|\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 59.7 |
|---|
| Cost | 576 |
|---|
\[0.5 \cdot \left(-1 + \left(1 + \left(im + im\right)\right)\right)
\]
| Alternative 10 |
|---|
| Error | 59.6 |
|---|
| Cost | 448 |
|---|
\[0.5 \cdot \left(4 \cdot \left(im \cdot im\right)\right)
\]
| Alternative 11 |
|---|
| Error | 59.4 |
|---|
| Cost | 196 |
|---|
\[\begin{array}{l}
\mathbf{if}\;im \leq 1.011229484841618 \cdot 10^{-259}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;im\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 60.1 |
|---|
| Cost | 64 |
|---|
\[0
\]