
(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 5 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}
NOTE: im should be positive before calling this function (FPCore (re im) :precision binary64 (if (<= (+ re (sqrt (+ (* re re) (* im im)))) 0.0) (* 0.5 (/ im (sqrt (- re)))) (* 0.5 (sqrt (* 2.0 (+ re (hypot re im)))))))
im = abs(im);
double code(double re, double im) {
double tmp;
if ((re + sqrt(((re * re) + (im * im)))) <= 0.0) {
tmp = 0.5 * (im / sqrt(-re));
} else {
tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
}
return tmp;
}
im = Math.abs(im);
public static double code(double re, double im) {
double tmp;
if ((re + Math.sqrt(((re * re) + (im * im)))) <= 0.0) {
tmp = 0.5 * (im / Math.sqrt(-re));
} else {
tmp = 0.5 * Math.sqrt((2.0 * (re + Math.hypot(re, im))));
}
return tmp;
}
im = abs(im) def code(re, im): tmp = 0 if (re + math.sqrt(((re * re) + (im * im)))) <= 0.0: tmp = 0.5 * (im / math.sqrt(-re)) else: tmp = 0.5 * math.sqrt((2.0 * (re + math.hypot(re, im)))) return tmp
im = abs(im) function code(re, im) tmp = 0.0 if (Float64(re + sqrt(Float64(Float64(re * re) + Float64(im * im)))) <= 0.0) tmp = Float64(0.5 * Float64(im / sqrt(Float64(-re)))); else tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re + hypot(re, im))))); end return tmp end
im = abs(im) function tmp_2 = code(re, im) tmp = 0.0; if ((re + sqrt(((re * re) + (im * im)))) <= 0.0) tmp = 0.5 * (im / sqrt(-re)); else tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im)))); end tmp_2 = tmp; end
NOTE: im should be positive before calling this function code[re_, im_] := If[LessEqual[N[(re + N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[(im / N[Sqrt[(-re)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(2.0 * N[(re + N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;re + \sqrt{re \cdot re + im \cdot im} \leq 0:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{-re}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\
\end{array}
\end{array}
if (+.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re) < 0.0Initial program 12.1%
Simplified18.1%
Taylor expanded in re around -inf 44.9%
associate-*r/44.9%
associate-/l*44.9%
Simplified44.9%
*-un-lft-identity44.9%
unpow244.9%
times-frac67.3%
Applied egg-rr67.3%
associate-*r/67.3%
metadata-eval67.3%
frac-times44.9%
*-un-lft-identity44.9%
unpow244.9%
associate-/l*44.9%
neg-mul-144.9%
frac-2neg44.9%
sqrt-div47.2%
remove-double-neg47.2%
unpow247.2%
sqrt-prod47.4%
add-sqr-sqrt53.1%
Applied egg-rr53.1%
if 0.0 < (+.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re) Initial program 50.9%
Simplified93.2%
Final simplification86.3%
NOTE: im should be positive before calling this function
(FPCore (re im)
:precision binary64
(if (<= re -6.6e-34)
(* 0.5 (/ im (sqrt (- re))))
(if (<= re 3.9e-36)
(* 0.5 (sqrt (* 2.0 (+ re im))))
(* 0.5 (* 2.0 (sqrt re))))))im = abs(im);
double code(double re, double im) {
double tmp;
if (re <= -6.6e-34) {
tmp = 0.5 * (im / sqrt(-re));
} else if (re <= 3.9e-36) {
tmp = 0.5 * sqrt((2.0 * (re + im)));
} else {
tmp = 0.5 * (2.0 * sqrt(re));
}
return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-6.6d-34)) then
tmp = 0.5d0 * (im / sqrt(-re))
else if (re <= 3.9d-36) then
tmp = 0.5d0 * sqrt((2.0d0 * (re + im)))
else
tmp = 0.5d0 * (2.0d0 * sqrt(re))
end if
code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
double tmp;
if (re <= -6.6e-34) {
tmp = 0.5 * (im / Math.sqrt(-re));
} else if (re <= 3.9e-36) {
tmp = 0.5 * Math.sqrt((2.0 * (re + im)));
} else {
tmp = 0.5 * (2.0 * Math.sqrt(re));
}
return tmp;
}
im = abs(im) def code(re, im): tmp = 0 if re <= -6.6e-34: tmp = 0.5 * (im / math.sqrt(-re)) elif re <= 3.9e-36: tmp = 0.5 * math.sqrt((2.0 * (re + im))) else: tmp = 0.5 * (2.0 * math.sqrt(re)) return tmp
im = abs(im) function code(re, im) tmp = 0.0 if (re <= -6.6e-34) tmp = Float64(0.5 * Float64(im / sqrt(Float64(-re)))); elseif (re <= 3.9e-36) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re + im)))); else tmp = Float64(0.5 * Float64(2.0 * sqrt(re))); end return tmp end
im = abs(im) function tmp_2 = code(re, im) tmp = 0.0; if (re <= -6.6e-34) tmp = 0.5 * (im / sqrt(-re)); elseif (re <= 3.9e-36) tmp = 0.5 * sqrt((2.0 * (re + im))); else tmp = 0.5 * (2.0 * sqrt(re)); end tmp_2 = tmp; end
NOTE: im should be positive before calling this function code[re_, im_] := If[LessEqual[re, -6.6e-34], N[(0.5 * N[(im / N[Sqrt[(-re)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.9e-36], N[(0.5 * N[Sqrt[N[(2.0 * N[(re + im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 * N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.6 \cdot 10^{-34}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{-re}}\\
\mathbf{elif}\;re \leq 3.9 \cdot 10^{-36}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\end{array}
\end{array}
if re < -6.59999999999999965e-34Initial program 20.8%
Simplified42.5%
Taylor expanded in re around -inf 45.4%
associate-*r/45.4%
associate-/l*45.4%
Simplified45.4%
*-un-lft-identity45.4%
unpow245.4%
times-frac50.9%
Applied egg-rr50.9%
associate-*r/50.9%
metadata-eval50.9%
frac-times45.4%
*-un-lft-identity45.4%
unpow245.4%
associate-/l*45.4%
neg-mul-145.4%
frac-2neg45.4%
sqrt-div52.1%
remove-double-neg52.1%
unpow252.1%
sqrt-prod34.7%
add-sqr-sqrt39.2%
Applied egg-rr39.2%
if -6.59999999999999965e-34 < re < 3.9000000000000001e-36Initial program 55.0%
Simplified86.3%
Taylor expanded in re around 0 39.9%
distribute-lft-out39.9%
*-commutative39.9%
Simplified39.9%
if 3.9000000000000001e-36 < re Initial program 46.0%
Simplified100.0%
Taylor expanded in im around 0 75.5%
*-commutative75.5%
unpow275.5%
rem-square-sqrt76.9%
Simplified76.9%
Final simplification51.3%
NOTE: im should be positive before calling this function (FPCore (re im) :precision binary64 (if (<= re -5.4e-34) (* 0.5 (/ im (sqrt (- re)))) (if (<= re 3.65e-37) (* 0.5 (sqrt (* im 2.0))) (* 0.5 (* 2.0 (sqrt re))))))
im = abs(im);
double code(double re, double im) {
double tmp;
if (re <= -5.4e-34) {
tmp = 0.5 * (im / sqrt(-re));
} else if (re <= 3.65e-37) {
tmp = 0.5 * sqrt((im * 2.0));
} else {
tmp = 0.5 * (2.0 * sqrt(re));
}
return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-5.4d-34)) then
tmp = 0.5d0 * (im / sqrt(-re))
else if (re <= 3.65d-37) then
tmp = 0.5d0 * sqrt((im * 2.0d0))
else
tmp = 0.5d0 * (2.0d0 * sqrt(re))
end if
code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
double tmp;
if (re <= -5.4e-34) {
tmp = 0.5 * (im / Math.sqrt(-re));
} else if (re <= 3.65e-37) {
tmp = 0.5 * Math.sqrt((im * 2.0));
} else {
tmp = 0.5 * (2.0 * Math.sqrt(re));
}
return tmp;
}
im = abs(im) def code(re, im): tmp = 0 if re <= -5.4e-34: tmp = 0.5 * (im / math.sqrt(-re)) elif re <= 3.65e-37: tmp = 0.5 * math.sqrt((im * 2.0)) else: tmp = 0.5 * (2.0 * math.sqrt(re)) return tmp
im = abs(im) function code(re, im) tmp = 0.0 if (re <= -5.4e-34) tmp = Float64(0.5 * Float64(im / sqrt(Float64(-re)))); elseif (re <= 3.65e-37) tmp = Float64(0.5 * sqrt(Float64(im * 2.0))); else tmp = Float64(0.5 * Float64(2.0 * sqrt(re))); end return tmp end
im = abs(im) function tmp_2 = code(re, im) tmp = 0.0; if (re <= -5.4e-34) tmp = 0.5 * (im / sqrt(-re)); elseif (re <= 3.65e-37) tmp = 0.5 * sqrt((im * 2.0)); else tmp = 0.5 * (2.0 * sqrt(re)); end tmp_2 = tmp; end
NOTE: im should be positive before calling this function code[re_, im_] := If[LessEqual[re, -5.4e-34], N[(0.5 * N[(im / N[Sqrt[(-re)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.65e-37], N[(0.5 * N[Sqrt[N[(im * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 * N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;re \leq -5.4 \cdot 10^{-34}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{-re}}\\
\mathbf{elif}\;re \leq 3.65 \cdot 10^{-37}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\end{array}
\end{array}
if re < -5.40000000000000034e-34Initial program 20.8%
Simplified42.5%
Taylor expanded in re around -inf 45.4%
associate-*r/45.4%
associate-/l*45.4%
Simplified45.4%
*-un-lft-identity45.4%
unpow245.4%
times-frac50.9%
Applied egg-rr50.9%
associate-*r/50.9%
metadata-eval50.9%
frac-times45.4%
*-un-lft-identity45.4%
unpow245.4%
associate-/l*45.4%
neg-mul-145.4%
frac-2neg45.4%
sqrt-div52.1%
remove-double-neg52.1%
unpow252.1%
sqrt-prod34.7%
add-sqr-sqrt39.2%
Applied egg-rr39.2%
if -5.40000000000000034e-34 < re < 3.6499999999999998e-37Initial program 55.0%
Simplified86.3%
Taylor expanded in re around 0 38.3%
*-commutative38.3%
Simplified38.3%
if 3.6499999999999998e-37 < re Initial program 46.0%
Simplified100.0%
Taylor expanded in im around 0 75.5%
*-commutative75.5%
unpow275.5%
rem-square-sqrt76.9%
Simplified76.9%
Final simplification50.6%
NOTE: im should be positive before calling this function (FPCore (re im) :precision binary64 (if (<= re 8.5e-37) (* 0.5 (sqrt (* im 2.0))) (* 0.5 (* 2.0 (sqrt re)))))
im = abs(im);
double code(double re, double im) {
double tmp;
if (re <= 8.5e-37) {
tmp = 0.5 * sqrt((im * 2.0));
} else {
tmp = 0.5 * (2.0 * sqrt(re));
}
return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 8.5d-37) then
tmp = 0.5d0 * sqrt((im * 2.0d0))
else
tmp = 0.5d0 * (2.0d0 * sqrt(re))
end if
code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
double tmp;
if (re <= 8.5e-37) {
tmp = 0.5 * Math.sqrt((im * 2.0));
} else {
tmp = 0.5 * (2.0 * Math.sqrt(re));
}
return tmp;
}
im = abs(im) def code(re, im): tmp = 0 if re <= 8.5e-37: tmp = 0.5 * math.sqrt((im * 2.0)) else: tmp = 0.5 * (2.0 * math.sqrt(re)) return tmp
im = abs(im) function code(re, im) tmp = 0.0 if (re <= 8.5e-37) tmp = Float64(0.5 * sqrt(Float64(im * 2.0))); else tmp = Float64(0.5 * Float64(2.0 * sqrt(re))); end return tmp end
im = abs(im) function tmp_2 = code(re, im) tmp = 0.0; if (re <= 8.5e-37) tmp = 0.5 * sqrt((im * 2.0)); else tmp = 0.5 * (2.0 * sqrt(re)); end tmp_2 = tmp; end
NOTE: im should be positive before calling this function code[re_, im_] := If[LessEqual[re, 8.5e-37], N[(0.5 * N[Sqrt[N[(im * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 * N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;re \leq 8.5 \cdot 10^{-37}:\\
\;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\
\end{array}
\end{array}
if re < 8.5000000000000007e-37Initial program 43.4%
Simplified71.4%
Taylor expanded in re around 0 28.9%
*-commutative28.9%
Simplified28.9%
if 8.5000000000000007e-37 < re Initial program 46.0%
Simplified100.0%
Taylor expanded in im around 0 75.5%
*-commutative75.5%
unpow275.5%
rem-square-sqrt76.9%
Simplified76.9%
Final simplification43.9%
NOTE: im should be positive before calling this function (FPCore (re im) :precision binary64 (* 0.5 (sqrt (* im 2.0))))
im = abs(im);
double code(double re, double im) {
return 0.5 * sqrt((im * 2.0));
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * sqrt((im * 2.0d0))
end function
im = Math.abs(im);
public static double code(double re, double im) {
return 0.5 * Math.sqrt((im * 2.0));
}
im = abs(im) def code(re, im): return 0.5 * math.sqrt((im * 2.0))
im = abs(im) function code(re, im) return Float64(0.5 * sqrt(Float64(im * 2.0))) end
im = abs(im) function tmp = code(re, im) tmp = 0.5 * sqrt((im * 2.0)); end
NOTE: im should be positive before calling this function code[re_, im_] := N[(0.5 * N[Sqrt[N[(im * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im = |im|\\
\\
0.5 \cdot \sqrt{im \cdot 2}
\end{array}
Initial program 44.2%
Simplified80.3%
Taylor expanded in re around 0 25.0%
*-commutative25.0%
Simplified25.0%
Final simplification25.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (sqrt (+ (* re re) (* im im)))))
(if (< re 0.0)
(* 0.5 (* (sqrt 2.0) (sqrt (/ (* im im) (- t_0 re)))))
(* 0.5 (sqrt (* 2.0 (+ t_0 re)))))))
double code(double re, double im) {
double t_0 = sqrt(((re * re) + (im * im)));
double tmp;
if (re < 0.0) {
tmp = 0.5 * (sqrt(2.0) * sqrt(((im * im) / (t_0 - re))));
} else {
tmp = 0.5 * sqrt((2.0 * (t_0 + re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((re * re) + (im * im)))
if (re < 0.0d0) then
tmp = 0.5d0 * (sqrt(2.0d0) * sqrt(((im * im) / (t_0 - re))))
else
tmp = 0.5d0 * sqrt((2.0d0 * (t_0 + re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.sqrt(((re * re) + (im * im)));
double tmp;
if (re < 0.0) {
tmp = 0.5 * (Math.sqrt(2.0) * Math.sqrt(((im * im) / (t_0 - re))));
} else {
tmp = 0.5 * Math.sqrt((2.0 * (t_0 + re)));
}
return tmp;
}
def code(re, im): t_0 = math.sqrt(((re * re) + (im * im))) tmp = 0 if re < 0.0: tmp = 0.5 * (math.sqrt(2.0) * math.sqrt(((im * im) / (t_0 - re)))) else: tmp = 0.5 * math.sqrt((2.0 * (t_0 + re))) return tmp
function code(re, im) t_0 = sqrt(Float64(Float64(re * re) + Float64(im * im))) tmp = 0.0 if (re < 0.0) tmp = Float64(0.5 * Float64(sqrt(2.0) * sqrt(Float64(Float64(im * im) / Float64(t_0 - re))))); else tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(t_0 + re)))); end return tmp end
function tmp_2 = code(re, im) t_0 = sqrt(((re * re) + (im * im))); tmp = 0.0; if (re < 0.0) tmp = 0.5 * (sqrt(2.0) * sqrt(((im * im) / (t_0 - re)))); else tmp = 0.5 * sqrt((2.0 * (t_0 + re))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[re, 0.0], N[(0.5 * N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(N[(im * im), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(2.0 * N[(t$95$0 + re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{re \cdot re + im \cdot im}\\
\mathbf{if}\;re < 0:\\
\;\;\;\;0.5 \cdot \left(\sqrt{2} \cdot \sqrt{\frac{im \cdot im}{t_0 - re}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(t_0 + re\right)}\\
\end{array}
\end{array}
herbie shell --seed 2023320
(FPCore (re im)
:name "math.sqrt on complex, real part"
:precision binary64
:herbie-target
(if (< re 0.0) (* 0.5 (* (sqrt 2.0) (sqrt (/ (* im im) (- (sqrt (+ (* re re) (* im im))) re))))) (* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* re re) (* im im))) re)))))
(* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* re re) (* im im))) re)))))