
(FPCore (re im) :precision binary64 (* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))
double code(double re, double im) {
return 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * sqrt((2.0d0 * (sqrt(((re * re) + (im * im))) - re)))
end function
public static double code(double re, double im) {
return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((re * re) + (im * im))) - re)));
}
def code(re, im): return 0.5 * math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) - re)))
function code(re, im) return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re)))) end
function tmp = code(re, im) tmp = 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re))); 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]
\begin{array}{l}
\\
0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))
double code(double re, double im) {
return 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * sqrt((2.0d0 * (sqrt(((re * re) + (im * im))) - re)))
end function
public static double code(double re, double im) {
return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((re * re) + (im * im))) - re)));
}
def code(re, im): return 0.5 * math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) - re)))
function code(re, im) return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re)))) end
function tmp = code(re, im) tmp = 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re))); 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]
\begin{array}{l}
\\
0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}
\end{array}
(FPCore (re im) :precision binary64 (if (<= (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re))) 0.0) (* 0.5 (* im (sqrt (/ 1.0 re)))) (* 0.5 (sqrt (* 2.0 (- (hypot re im) re))))))
double code(double re, double im) {
double tmp;
if (sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re))) <= 0.0) {
tmp = 0.5 * (im * sqrt((1.0 / re)));
} else {
tmp = 0.5 * sqrt((2.0 * (hypot(re, im) - re)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (Math.sqrt((2.0 * (Math.sqrt(((re * re) + (im * im))) - re))) <= 0.0) {
tmp = 0.5 * (im * Math.sqrt((1.0 / re)));
} else {
tmp = 0.5 * Math.sqrt((2.0 * (Math.hypot(re, im) - re)));
}
return tmp;
}
def code(re, im): tmp = 0 if math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) - re))) <= 0.0: tmp = 0.5 * (im * math.sqrt((1.0 / re))) else: tmp = 0.5 * math.sqrt((2.0 * (math.hypot(re, im) - re))) return tmp
function code(re, im) tmp = 0.0 if (sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re))) <= 0.0) tmp = Float64(0.5 * Float64(im * sqrt(Float64(1.0 / re)))); else tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(hypot(re, im) - re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re))) <= 0.0) tmp = 0.5 * (im * sqrt((1.0 / re))); else tmp = 0.5 * sqrt((2.0 * (hypot(re, im) - re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(0.5 * N[(im * N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \leq 0:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{\frac{1}{re}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\mathsf{hypot}\left(re, im\right) - re\right)}\\
\end{array}
\end{array}
if (sqrt.f64 (*.f64 #s(literal 2 binary64) (-.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re))) < 0.0Initial program 6.3%
add-cbrt-cube6.3%
pow1/36.3%
Applied egg-rr6.3%
pow-pow6.3%
metadata-eval6.3%
pow1/26.3%
sqrt-unprod6.3%
*-commutative6.3%
add-sqr-sqrt6.3%
associate-*l*6.3%
pow1/26.3%
metadata-eval6.3%
sqrt-pow16.3%
metadata-eval6.3%
metadata-eval6.3%
pow1/26.3%
metadata-eval6.3%
sqrt-pow16.3%
metadata-eval6.3%
metadata-eval6.3%
Applied egg-rr6.3%
Taylor expanded in re around inf 99.6%
if 0.0 < (sqrt.f64 (*.f64 #s(literal 2 binary64) (-.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re))) Initial program 49.7%
sub-neg49.7%
sqr-neg49.7%
sub-neg49.7%
sqr-neg49.7%
hypot-define89.5%
Simplified89.5%
Final simplification90.8%
(FPCore (re im)
:precision binary64
(if (<= re -1.65e-40)
(* 0.5 (sqrt (* re -4.0)))
(if (<= re 1.1e-79)
(* 0.5 (sqrt (* im (+ 2.0 (* (/ re im) -2.0)))))
(* 0.5 (* im (sqrt (/ 1.0 re)))))))
double code(double re, double im) {
double tmp;
if (re <= -1.65e-40) {
tmp = 0.5 * sqrt((re * -4.0));
} else if (re <= 1.1e-79) {
tmp = 0.5 * sqrt((im * (2.0 + ((re / im) * -2.0))));
} else {
tmp = 0.5 * (im * sqrt((1.0 / re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-1.65d-40)) then
tmp = 0.5d0 * sqrt((re * (-4.0d0)))
else if (re <= 1.1d-79) then
tmp = 0.5d0 * sqrt((im * (2.0d0 + ((re / im) * (-2.0d0)))))
else
tmp = 0.5d0 * (im * sqrt((1.0d0 / re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.65e-40) {
tmp = 0.5 * Math.sqrt((re * -4.0));
} else if (re <= 1.1e-79) {
tmp = 0.5 * Math.sqrt((im * (2.0 + ((re / im) * -2.0))));
} else {
tmp = 0.5 * (im * Math.sqrt((1.0 / re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.65e-40: tmp = 0.5 * math.sqrt((re * -4.0)) elif re <= 1.1e-79: tmp = 0.5 * math.sqrt((im * (2.0 + ((re / im) * -2.0)))) else: tmp = 0.5 * (im * math.sqrt((1.0 / re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.65e-40) tmp = Float64(0.5 * sqrt(Float64(re * -4.0))); elseif (re <= 1.1e-79) tmp = Float64(0.5 * sqrt(Float64(im * Float64(2.0 + Float64(Float64(re / im) * -2.0))))); else tmp = Float64(0.5 * Float64(im * sqrt(Float64(1.0 / re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.65e-40) tmp = 0.5 * sqrt((re * -4.0)); elseif (re <= 1.1e-79) tmp = 0.5 * sqrt((im * (2.0 + ((re / im) * -2.0)))); else tmp = 0.5 * (im * sqrt((1.0 / re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.65e-40], N[(0.5 * N[Sqrt[N[(re * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.1e-79], N[(0.5 * N[Sqrt[N[(im * N[(2.0 + N[(N[(re / im), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.65 \cdot 10^{-40}:\\
\;\;\;\;0.5 \cdot \sqrt{re \cdot -4}\\
\mathbf{elif}\;re \leq 1.1 \cdot 10^{-79}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot \left(2 + \frac{re}{im} \cdot -2\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{\frac{1}{re}}\right)\\
\end{array}
\end{array}
if re < -1.64999999999999996e-40Initial program 48.1%
sub-neg48.1%
sqr-neg48.1%
sub-neg48.1%
sqr-neg48.1%
hypot-define98.8%
Simplified98.8%
Taylor expanded in re around -inf 78.1%
*-commutative78.1%
Simplified78.1%
if -1.64999999999999996e-40 < re < 1.0999999999999999e-79Initial program 65.0%
sub-neg65.0%
sqr-neg65.0%
sub-neg65.0%
sqr-neg65.0%
hypot-define94.2%
Simplified94.2%
Taylor expanded in im around inf 84.4%
*-commutative84.4%
Simplified84.4%
if 1.0999999999999999e-79 < re Initial program 12.3%
add-cbrt-cube12.2%
pow1/311.8%
Applied egg-rr20.6%
pow-pow36.5%
metadata-eval36.5%
pow1/236.5%
sqrt-unprod36.3%
*-commutative36.3%
add-sqr-sqrt36.3%
associate-*l*36.4%
pow1/236.4%
metadata-eval36.4%
sqrt-pow136.4%
metadata-eval36.4%
metadata-eval36.4%
pow1/236.4%
metadata-eval36.4%
sqrt-pow136.4%
metadata-eval36.4%
metadata-eval36.4%
Applied egg-rr36.4%
Taylor expanded in re around inf 76.5%
Final simplification80.0%
(FPCore (re im)
:precision binary64
(if (<= re -4.2e-31)
(* 0.5 (sqrt (* re -4.0)))
(if (<= re 8.2e-80)
(* 0.5 (sqrt (* 2.0 (- im re))))
(* 0.5 (* im (sqrt (/ 1.0 re)))))))
double code(double re, double im) {
double tmp;
if (re <= -4.2e-31) {
tmp = 0.5 * sqrt((re * -4.0));
} else if (re <= 8.2e-80) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (im * sqrt((1.0 / re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-4.2d-31)) then
tmp = 0.5d0 * sqrt((re * (-4.0d0)))
else if (re <= 8.2d-80) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else
tmp = 0.5d0 * (im * sqrt((1.0d0 / re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.2e-31) {
tmp = 0.5 * Math.sqrt((re * -4.0));
} else if (re <= 8.2e-80) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (im * Math.sqrt((1.0 / re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.2e-31: tmp = 0.5 * math.sqrt((re * -4.0)) elif re <= 8.2e-80: tmp = 0.5 * math.sqrt((2.0 * (im - re))) else: tmp = 0.5 * (im * math.sqrt((1.0 / re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.2e-31) tmp = Float64(0.5 * sqrt(Float64(re * -4.0))); elseif (re <= 8.2e-80) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); else tmp = Float64(0.5 * Float64(im * sqrt(Float64(1.0 / re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.2e-31) tmp = 0.5 * sqrt((re * -4.0)); elseif (re <= 8.2e-80) tmp = 0.5 * sqrt((2.0 * (im - re))); else tmp = 0.5 * (im * sqrt((1.0 / re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.2e-31], N[(0.5 * N[Sqrt[N[(re * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.2e-80], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.2 \cdot 10^{-31}:\\
\;\;\;\;0.5 \cdot \sqrt{re \cdot -4}\\
\mathbf{elif}\;re \leq 8.2 \cdot 10^{-80}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{\frac{1}{re}}\right)\\
\end{array}
\end{array}
if re < -4.19999999999999982e-31Initial program 48.1%
sub-neg48.1%
sqr-neg48.1%
sub-neg48.1%
sqr-neg48.1%
hypot-define98.8%
Simplified98.8%
Taylor expanded in re around -inf 78.1%
*-commutative78.1%
Simplified78.1%
if -4.19999999999999982e-31 < re < 8.1999999999999999e-80Initial program 65.0%
Taylor expanded in re around 0 84.4%
if 8.1999999999999999e-80 < re Initial program 12.3%
add-cbrt-cube12.2%
pow1/311.8%
Applied egg-rr20.6%
pow-pow36.5%
metadata-eval36.5%
pow1/236.5%
sqrt-unprod36.3%
*-commutative36.3%
add-sqr-sqrt36.3%
associate-*l*36.4%
pow1/236.4%
metadata-eval36.4%
sqrt-pow136.4%
metadata-eval36.4%
metadata-eval36.4%
pow1/236.4%
metadata-eval36.4%
sqrt-pow136.4%
metadata-eval36.4%
metadata-eval36.4%
Applied egg-rr36.4%
Taylor expanded in re around inf 76.5%
Final simplification80.0%
(FPCore (re im) :precision binary64 (if (<= im 1.75e-232) (* 0.5 (sqrt 0.0)) (* 0.5 (sqrt (* 2.0 im)))))
double code(double re, double im) {
double tmp;
if (im <= 1.75e-232) {
tmp = 0.5 * sqrt(0.0);
} else {
tmp = 0.5 * sqrt((2.0 * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.75d-232) then
tmp = 0.5d0 * sqrt(0.0d0)
else
tmp = 0.5d0 * sqrt((2.0d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.75e-232) {
tmp = 0.5 * Math.sqrt(0.0);
} else {
tmp = 0.5 * Math.sqrt((2.0 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.75e-232: tmp = 0.5 * math.sqrt(0.0) else: tmp = 0.5 * math.sqrt((2.0 * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.75e-232) tmp = Float64(0.5 * sqrt(0.0)); else tmp = Float64(0.5 * sqrt(Float64(2.0 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.75e-232) tmp = 0.5 * sqrt(0.0); else tmp = 0.5 * sqrt((2.0 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.75e-232], N[(0.5 * N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(2.0 * im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.75 \cdot 10^{-232}:\\
\;\;\;\;0.5 \cdot \sqrt{0}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
\end{array}
\end{array}
if im < 1.7499999999999999e-232Initial program 40.2%
add-sqr-sqrt38.9%
add-sqr-sqrt2.7%
difference-of-squares2.7%
hypot-define2.7%
hypot-define13.7%
Applied egg-rr13.7%
Taylor expanded in re around inf 15.7%
if 1.7499999999999999e-232 < im Initial program 44.9%
sub-neg44.9%
sqr-neg44.9%
sub-neg44.9%
sqr-neg44.9%
hypot-define79.9%
Simplified79.9%
Taylor expanded in re around 0 57.8%
*-commutative57.8%
Simplified57.8%
Final simplification50.4%
(FPCore (re im) :precision binary64 (if (<= re -9.2e-29) (* 0.5 (sqrt (* re -4.0))) (* 0.5 (sqrt (* 2.0 im)))))
double code(double re, double im) {
double tmp;
if (re <= -9.2e-29) {
tmp = 0.5 * sqrt((re * -4.0));
} else {
tmp = 0.5 * sqrt((2.0 * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-9.2d-29)) then
tmp = 0.5d0 * sqrt((re * (-4.0d0)))
else
tmp = 0.5d0 * sqrt((2.0d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -9.2e-29) {
tmp = 0.5 * Math.sqrt((re * -4.0));
} else {
tmp = 0.5 * Math.sqrt((2.0 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -9.2e-29: tmp = 0.5 * math.sqrt((re * -4.0)) else: tmp = 0.5 * math.sqrt((2.0 * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -9.2e-29) tmp = Float64(0.5 * sqrt(Float64(re * -4.0))); else tmp = Float64(0.5 * sqrt(Float64(2.0 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -9.2e-29) tmp = 0.5 * sqrt((re * -4.0)); else tmp = 0.5 * sqrt((2.0 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -9.2e-29], N[(0.5 * N[Sqrt[N[(re * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(2.0 * im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -9.2 \cdot 10^{-29}:\\
\;\;\;\;0.5 \cdot \sqrt{re \cdot -4}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
\end{array}
\end{array}
if re < -9.19999999999999965e-29Initial program 48.1%
sub-neg48.1%
sqr-neg48.1%
sub-neg48.1%
sqr-neg48.1%
hypot-define98.8%
Simplified98.8%
Taylor expanded in re around -inf 78.1%
*-commutative78.1%
Simplified78.1%
if -9.19999999999999965e-29 < re Initial program 42.2%
sub-neg42.2%
sqr-neg42.2%
sub-neg42.2%
sqr-neg42.2%
hypot-define69.2%
Simplified69.2%
Taylor expanded in re around 0 59.2%
*-commutative59.2%
Simplified59.2%
Final simplification65.3%
(FPCore (re im) :precision binary64 (* 0.5 (sqrt 0.0)))
double code(double re, double im) {
return 0.5 * sqrt(0.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * sqrt(0.0d0)
end function
public static double code(double re, double im) {
return 0.5 * Math.sqrt(0.0);
}
def code(re, im): return 0.5 * math.sqrt(0.0)
function code(re, im) return Float64(0.5 * sqrt(0.0)) end
function tmp = code(re, im) tmp = 0.5 * sqrt(0.0); end
code[re_, im_] := N[(0.5 * N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \sqrt{0}
\end{array}
Initial program 44.1%
add-sqr-sqrt43.7%
add-sqr-sqrt14.0%
difference-of-squares14.0%
hypot-define14.0%
hypot-define26.0%
Applied egg-rr26.0%
Taylor expanded in re around inf 5.5%
Final simplification5.5%
herbie shell --seed 2024059
(FPCore (re im)
:name "math.sqrt on complex, imaginary part, im greater than 0 branch"
:precision binary64
:pre (> im 0.0)
(* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))