\[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;re \leq -520000000000:\\
\;\;\;\;0.5 \cdot {\left({\left(\sqrt{2}\right)}^{0.3333333333333333} \cdot e^{0.16666666666666666 \cdot \left(\log \left(\frac{-1}{re}\right) + \log \left(0.5 \cdot {im}^{2}\right)\right)}\right)}^{3}\\
\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 -520000000000.0)
(*
0.5
(pow
(*
(pow (sqrt 2.0) 0.3333333333333333)
(exp
(*
0.16666666666666666
(+ (log (/ -1.0 re)) (log (* 0.5 (pow im 2.0)))))))
3.0))
(* 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 <= -520000000000.0) {
tmp = 0.5 * pow((pow(sqrt(2.0), 0.3333333333333333) * exp((0.16666666666666666 * (log((-1.0 / re)) + log((0.5 * pow(im, 2.0))))))), 3.0);
} 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 <= -520000000000.0) {
tmp = 0.5 * Math.pow((Math.pow(Math.sqrt(2.0), 0.3333333333333333) * Math.exp((0.16666666666666666 * (Math.log((-1.0 / re)) + Math.log((0.5 * Math.pow(im, 2.0))))))), 3.0);
} 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 <= -520000000000.0:
tmp = 0.5 * math.pow((math.pow(math.sqrt(2.0), 0.3333333333333333) * math.exp((0.16666666666666666 * (math.log((-1.0 / re)) + math.log((0.5 * math.pow(im, 2.0))))))), 3.0)
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 <= -520000000000.0)
tmp = Float64(0.5 * (Float64((sqrt(2.0) ^ 0.3333333333333333) * exp(Float64(0.16666666666666666 * Float64(log(Float64(-1.0 / re)) + log(Float64(0.5 * (im ^ 2.0))))))) ^ 3.0));
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 <= -520000000000.0)
tmp = 0.5 * (((sqrt(2.0) ^ 0.3333333333333333) * exp((0.16666666666666666 * (log((-1.0 / re)) + log((0.5 * (im ^ 2.0))))))) ^ 3.0);
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, -520000000000.0], N[(0.5 * N[Power[N[(N[Power[N[Sqrt[2.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] * N[Exp[N[(0.16666666666666666 * N[(N[Log[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision] + N[Log[N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $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 -520000000000:\\
\;\;\;\;0.5 \cdot {\left({\left(\sqrt{2}\right)}^{0.3333333333333333} \cdot e^{0.16666666666666666 \cdot \left(\log \left(\frac{-1}{re}\right) + \log \left(0.5 \cdot {im}^{2}\right)\right)}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 9.7 |
|---|
| Cost | 26884 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\sqrt{2 \cdot \left(re + \sqrt{re \cdot re + im \cdot im}\right)} \leq 0:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot \frac{-im}{re}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 27.0 |
|---|
| Cost | 7837 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
t_1 := \sqrt{-re}\\
\mathbf{if}\;im \leq -1.05 \cdot 10^{-15}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\
\mathbf{elif}\;im \leq -1.48 \cdot 10^{-266}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.3 \cdot 10^{-263}:\\
\;\;\;\;0.5 \cdot \frac{im}{t_1}\\
\mathbf{elif}\;im \leq 2.85 \cdot 10^{-226}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.9 \cdot 10^{-157} \lor \neg \left(im \leq 1.85 \cdot 10^{-84}\right) \land im \leq 4.3 \cdot 10^{-69}:\\
\;\;\;\;0.5 \cdot \frac{1}{\frac{t_1}{im}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 26.9 |
|---|
| Cost | 7837 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{-re}\\
\mathbf{if}\;im \leq -1.05 \cdot 10^{-15}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\
\mathbf{elif}\;im \leq -6.8 \cdot 10^{-271}:\\
\;\;\;\;0.5 \cdot {\left(im \cdot \frac{im}{re} + 2 \cdot \left(re \cdot 2\right)\right)}^{0.5}\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{-263}:\\
\;\;\;\;0.5 \cdot \frac{im}{t_0}\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{-227}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{-156} \lor \neg \left(im \leq 5.5 \cdot 10^{-88}\right) \land im \leq 2.2 \cdot 10^{-69}:\\
\;\;\;\;0.5 \cdot \frac{1}{\frac{t_0}{im}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 27.6 |
|---|
| Cost | 7773 |
|---|
\[\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.6 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -3.7 \cdot 10^{+25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -1.4 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -6.8 \cdot 10^{-271}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2.3 \cdot 10^{-157} \lor \neg \left(im \leq 6 \cdot 10^{-80}\right) \land im \leq 2.25 \cdot 10^{-69}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{-re}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 28.3 |
|---|
| Cost | 7708 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\
t_1 := 0.5 \cdot \frac{im}{\sqrt{-re}}\\
t_2 := 0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{if}\;im \leq -5.6 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -3.2 \cdot 10^{+25}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -1.05 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -6.8 \cdot 10^{-271}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 5.5 \cdot 10^{-184}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{-97}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 2.4 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 26.9 |
|---|
| Cost | 7509 |
|---|
\[\begin{array}{l}
\mathbf{if}\;im \leq -1.05 \cdot 10^{-15}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\
\mathbf{elif}\;im \leq -3.5 \cdot 10^{-270}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\mathbf{elif}\;im \leq 2.3 \cdot 10^{-157} \lor \neg \left(im \leq 5.4 \cdot 10^{-83}\right) \land im \leq 1.7 \cdot 10^{-69}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{-re}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 27.6 |
|---|
| 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.6 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -3.7 \cdot 10^{+25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -1.05 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{-65}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 36.4 |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;re \leq 3.6 \cdot 10^{-130}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 47.3 |
|---|
| Cost | 6720 |
|---|
\[0.5 \cdot \sqrt{2 \cdot im}
\]