?

Average Accuracy: 40.0% → 82.2%
Time: 12.1s
Precision: binary64
Cost: 39757

?

\[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]
\[\begin{array}{l} \mathbf{if}\;re \leq -2.9 \cdot 10^{+162}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -5.3 \cdot 10^{+91} \lor \neg \left(re \leq -2.2 \cdot 10^{+53}\right):\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left({\left(e^{0.25 \cdot \left(\log \left(\frac{-1}{re}\right) + \log \left(0.5 \cdot {im}^{2}\right)\right)}\right)}^{2} \cdot \sqrt{2}\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 -2.9e+162)
   (sqrt (* (* im (/ im re)) -0.25))
   (if (or (<= re -5.3e+91) (not (<= re -2.2e+53)))
     (* 0.5 (sqrt (* 2.0 (+ re (hypot re im)))))
     (*
      0.5
      (*
       (pow
        (exp (* 0.25 (+ (log (/ -1.0 re)) (log (* 0.5 (pow im 2.0))))))
        2.0)
       (sqrt 2.0))))))
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 <= -2.9e+162) {
		tmp = sqrt(((im * (im / re)) * -0.25));
	} else if ((re <= -5.3e+91) || !(re <= -2.2e+53)) {
		tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
	} else {
		tmp = 0.5 * (pow(exp((0.25 * (log((-1.0 / re)) + log((0.5 * pow(im, 2.0)))))), 2.0) * sqrt(2.0));
	}
	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 <= -2.9e+162) {
		tmp = Math.sqrt(((im * (im / re)) * -0.25));
	} else if ((re <= -5.3e+91) || !(re <= -2.2e+53)) {
		tmp = 0.5 * Math.sqrt((2.0 * (re + Math.hypot(re, im))));
	} else {
		tmp = 0.5 * (Math.pow(Math.exp((0.25 * (Math.log((-1.0 / re)) + Math.log((0.5 * Math.pow(im, 2.0)))))), 2.0) * Math.sqrt(2.0));
	}
	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 <= -2.9e+162:
		tmp = math.sqrt(((im * (im / re)) * -0.25))
	elif (re <= -5.3e+91) or not (re <= -2.2e+53):
		tmp = 0.5 * math.sqrt((2.0 * (re + math.hypot(re, im))))
	else:
		tmp = 0.5 * (math.pow(math.exp((0.25 * (math.log((-1.0 / re)) + math.log((0.5 * math.pow(im, 2.0)))))), 2.0) * math.sqrt(2.0))
	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 <= -2.9e+162)
		tmp = sqrt(Float64(Float64(im * Float64(im / re)) * -0.25));
	elseif ((re <= -5.3e+91) || !(re <= -2.2e+53))
		tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re + hypot(re, im)))));
	else
		tmp = Float64(0.5 * Float64((exp(Float64(0.25 * Float64(log(Float64(-1.0 / re)) + log(Float64(0.5 * (im ^ 2.0)))))) ^ 2.0) * sqrt(2.0)));
	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 <= -2.9e+162)
		tmp = sqrt(((im * (im / re)) * -0.25));
	elseif ((re <= -5.3e+91) || ~((re <= -2.2e+53)))
		tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
	else
		tmp = 0.5 * ((exp((0.25 * (log((-1.0 / re)) + log((0.5 * (im ^ 2.0)))))) ^ 2.0) * sqrt(2.0));
	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, -2.9e+162], N[Sqrt[N[(N[(im * N[(im / re), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[re, -5.3e+91], N[Not[LessEqual[re, -2.2e+53]], $MachinePrecision]], N[(0.5 * N[Sqrt[N[(2.0 * N[(re + N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Power[N[Exp[N[(0.25 * 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], 2.0], $MachinePrecision] * N[Sqrt[2.0], $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 -2.9 \cdot 10^{+162}:\\
\;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\

\mathbf{elif}\;re \leq -5.3 \cdot 10^{+91} \lor \neg \left(re \leq -2.2 \cdot 10^{+53}\right):\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left({\left(e^{0.25 \cdot \left(\log \left(\frac{-1}{re}\right) + \log \left(0.5 \cdot {im}^{2}\right)\right)}\right)}^{2} \cdot \sqrt{2}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.0%
Target47.8%
Herbie82.2%
\[\begin{array}{l} \mathbf{if}\;re < 0:\\ \;\;\;\;0.5 \cdot \left(\sqrt{2} \cdot \sqrt{\frac{im \cdot im}{\sqrt{re \cdot re + im \cdot im} - re}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if re < -2.90000000000000006e162

    1. Initial program 0.0%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]
    2. Simplified34.3%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}} \]
      Proof

      [Start]0.0

      \[ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]

      +-commutative [=>]0.0

      \[ 0.5 \cdot \sqrt{2 \cdot \color{blue}{\left(re + \sqrt{re \cdot re + im \cdot im}\right)}} \]

      hypot-def [=>]34.3

      \[ 0.5 \cdot \sqrt{2 \cdot \left(re + \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)} \]
    3. Taylor expanded in re around -inf 50.1%

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \color{blue}{\left(-0.5 \cdot \frac{{im}^{2}}{re}\right)}} \]
    4. Simplified50.1%

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \color{blue}{\left(\frac{im \cdot im}{re} \cdot -0.5\right)}} \]
      Proof

      [Start]50.1

      \[ 0.5 \cdot \sqrt{2 \cdot \left(-0.5 \cdot \frac{{im}^{2}}{re}\right)} \]

      *-commutative [=>]50.1

      \[ 0.5 \cdot \sqrt{2 \cdot \color{blue}{\left(\frac{{im}^{2}}{re} \cdot -0.5\right)}} \]

      unpow2 [=>]50.1

      \[ 0.5 \cdot \sqrt{2 \cdot \left(\frac{\color{blue}{im \cdot im}}{re} \cdot -0.5\right)} \]
    5. Applied egg-rr50.0%

      \[\leadsto \color{blue}{\sqrt{\frac{im \cdot \left(-im\right)}{re} \cdot 0.25}} \]
      Proof

      [Start]50.1

      \[ 0.5 \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)} \]

      add-sqr-sqrt [=>]49.9

      \[ \color{blue}{\sqrt{0.5 \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)}} \cdot \sqrt{0.5 \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)}}} \]

      sqrt-unprod [=>]50.0

      \[ \color{blue}{\sqrt{\left(0.5 \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)}\right) \cdot \left(0.5 \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)}\right)}} \]

      *-commutative [=>]50.0

      \[ \sqrt{\color{blue}{\left(\sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)} \cdot 0.5\right)} \cdot \left(0.5 \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)}\right)} \]

      *-commutative [=>]50.0

      \[ \sqrt{\left(\sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)} \cdot 0.5\right) \cdot \color{blue}{\left(\sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)} \cdot 0.5\right)}} \]

      swap-sqr [=>]50.0

      \[ \sqrt{\color{blue}{\left(\sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)} \cdot \sqrt{2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)}\right) \cdot \left(0.5 \cdot 0.5\right)}} \]

      add-sqr-sqrt [<=]50.0

      \[ \sqrt{\color{blue}{\left(2 \cdot \left(\frac{im \cdot im}{re} \cdot -0.5\right)\right)} \cdot \left(0.5 \cdot 0.5\right)} \]

      *-commutative [=>]50.0

      \[ \sqrt{\left(2 \cdot \color{blue}{\left(-0.5 \cdot \frac{im \cdot im}{re}\right)}\right) \cdot \left(0.5 \cdot 0.5\right)} \]

      associate-*r* [=>]50.0

      \[ \sqrt{\color{blue}{\left(\left(2 \cdot -0.5\right) \cdot \frac{im \cdot im}{re}\right)} \cdot \left(0.5 \cdot 0.5\right)} \]

      associate-*r/ [=>]50.0

      \[ \sqrt{\color{blue}{\frac{\left(2 \cdot -0.5\right) \cdot \left(im \cdot im\right)}{re}} \cdot \left(0.5 \cdot 0.5\right)} \]

      metadata-eval [=>]50.0

      \[ \sqrt{\frac{\color{blue}{-1} \cdot \left(im \cdot im\right)}{re} \cdot \left(0.5 \cdot 0.5\right)} \]

      neg-mul-1 [<=]50.0

      \[ \sqrt{\frac{\color{blue}{-im \cdot im}}{re} \cdot \left(0.5 \cdot 0.5\right)} \]

      distribute-rgt-neg-in [=>]50.0

      \[ \sqrt{\frac{\color{blue}{im \cdot \left(-im\right)}}{re} \cdot \left(0.5 \cdot 0.5\right)} \]

      metadata-eval [=>]50.0

      \[ \sqrt{\frac{im \cdot \left(-im\right)}{re} \cdot \color{blue}{0.25}} \]
    6. Simplified62.6%

      \[\leadsto \color{blue}{\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}} \]
      Proof

      [Start]50.0

      \[ \sqrt{\frac{im \cdot \left(-im\right)}{re} \cdot 0.25} \]

      distribute-rgt-neg-out [=>]50.0

      \[ \sqrt{\frac{\color{blue}{-im \cdot im}}{re} \cdot 0.25} \]

      distribute-frac-neg [=>]50.0

      \[ \sqrt{\color{blue}{\left(-\frac{im \cdot im}{re}\right)} \cdot 0.25} \]

      associate-*r/ [<=]62.6

      \[ \sqrt{\left(-\color{blue}{im \cdot \frac{im}{re}}\right) \cdot 0.25} \]

      mul-1-neg [<=]62.6

      \[ \sqrt{\color{blue}{\left(-1 \cdot \left(im \cdot \frac{im}{re}\right)\right)} \cdot 0.25} \]

      *-commutative [=>]62.6

      \[ \sqrt{\color{blue}{\left(\left(im \cdot \frac{im}{re}\right) \cdot -1\right)} \cdot 0.25} \]

      associate-*l* [=>]62.6

      \[ \sqrt{\color{blue}{\left(im \cdot \frac{im}{re}\right) \cdot \left(-1 \cdot 0.25\right)}} \]

      metadata-eval [=>]62.6

      \[ \sqrt{\left(im \cdot \frac{im}{re}\right) \cdot \color{blue}{-0.25}} \]

    if -2.90000000000000006e162 < re < -5.29999999999999997e91 or -2.19999999999999999e53 < re

    1. Initial program 46.2%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]
    2. Simplified86.5%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}} \]
      Proof

      [Start]46.2

      \[ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]

      +-commutative [=>]46.2

      \[ 0.5 \cdot \sqrt{2 \cdot \color{blue}{\left(re + \sqrt{re \cdot re + im \cdot im}\right)}} \]

      hypot-def [=>]86.5

      \[ 0.5 \cdot \sqrt{2 \cdot \left(re + \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)} \]

    if -5.29999999999999997e91 < re < -2.19999999999999999e53

    1. Initial program 21.2%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]
    2. Simplified47.7%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}} \]
      Proof

      [Start]21.2

      \[ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]

      +-commutative [=>]21.2

      \[ 0.5 \cdot \sqrt{2 \cdot \color{blue}{\left(re + \sqrt{re \cdot re + im \cdot im}\right)}} \]

      hypot-def [=>]47.7

      \[ 0.5 \cdot \sqrt{2 \cdot \left(re + \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)} \]
    3. Applied egg-rr47.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{re + \mathsf{hypot}\left(re, im\right)} \cdot \sqrt{2}\right)} \]
      Proof

      [Start]47.7

      \[ 0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)} \]

      sqrt-prod [=>]47.4

      \[ 0.5 \cdot \color{blue}{\left(\sqrt{2} \cdot \sqrt{re + \mathsf{hypot}\left(re, im\right)}\right)} \]

      *-commutative [=>]47.4

      \[ 0.5 \cdot \color{blue}{\left(\sqrt{re + \mathsf{hypot}\left(re, im\right)} \cdot \sqrt{2}\right)} \]
    4. Applied egg-rr47.3%

      \[\leadsto 0.5 \cdot \left(\color{blue}{{\left({\left(re + \mathsf{hypot}\left(re, im\right)\right)}^{0.25}\right)}^{2}} \cdot \sqrt{2}\right) \]
      Proof

      [Start]47.4

      \[ 0.5 \cdot \left(\sqrt{re + \mathsf{hypot}\left(re, im\right)} \cdot \sqrt{2}\right) \]

      add-sqr-sqrt [=>]47.2

      \[ 0.5 \cdot \left(\color{blue}{\left(\sqrt{\sqrt{re + \mathsf{hypot}\left(re, im\right)}} \cdot \sqrt{\sqrt{re + \mathsf{hypot}\left(re, im\right)}}\right)} \cdot \sqrt{2}\right) \]

      pow2 [=>]47.2

      \[ 0.5 \cdot \left(\color{blue}{{\left(\sqrt{\sqrt{re + \mathsf{hypot}\left(re, im\right)}}\right)}^{2}} \cdot \sqrt{2}\right) \]

      pow1/2 [=>]47.2

      \[ 0.5 \cdot \left({\left(\sqrt{\color{blue}{{\left(re + \mathsf{hypot}\left(re, im\right)\right)}^{0.5}}}\right)}^{2} \cdot \sqrt{2}\right) \]

      sqrt-pow1 [=>]47.3

      \[ 0.5 \cdot \left({\color{blue}{\left({\left(re + \mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} \cdot \sqrt{2}\right) \]

      metadata-eval [=>]47.3

      \[ 0.5 \cdot \left({\left({\left(re + \mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{0.25}}\right)}^{2} \cdot \sqrt{2}\right) \]
    5. Taylor expanded in re around -inf 40.9%

      \[\leadsto 0.5 \cdot \left(\color{blue}{{\left(e^{0.25 \cdot \left(\log \left(\frac{-1}{re}\right) + \log \left(0.5 \cdot {im}^{2}\right)\right)}\right)}^{2}} \cdot \sqrt{2}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -2.9 \cdot 10^{+162}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -5.3 \cdot 10^{+91} \lor \neg \left(re \leq -2.2 \cdot 10^{+53}\right):\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left({\left(e^{0.25 \cdot \left(\log \left(\frac{-1}{re}\right) + \log \left(0.5 \cdot {im}^{2}\right)\right)}\right)}^{2} \cdot \sqrt{2}\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy52.5%
Cost13908
\[\begin{array}{l} t_0 := 0.5 \cdot \sqrt{im \cdot -2}\\ \mathbf{if}\;re \leq -3.65 \cdot 10^{-10}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -3.8 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq -1 \cdot 10^{-305}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \mathbf{elif}\;re \leq 4.2 \cdot 10^{-243}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 9.2 \cdot 10^{-181}:\\ \;\;\;\;0.5 \cdot \left(\sqrt{2} \cdot \sqrt{re + im}\right)\\ \mathbf{elif}\;re \leq 4 \cdot 10^{-145}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\ \mathbf{elif}\;re \leq 3.3 \cdot 10^{-55}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 2
Accuracy52.5%
Cost13780
\[\begin{array}{l} t_0 := 0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\ \mathbf{if}\;re \leq -2.1 \cdot 10^{-12}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -4.6 \cdot 10^{-48}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot -2}\\ \mathbf{elif}\;re \leq -1.05 \cdot 10^{-305}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \mathbf{elif}\;re \leq 7.6 \cdot 10^{-233}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 2 \cdot 10^{-178}:\\ \;\;\;\;0.5 \cdot \left(\sqrt{2} \cdot \sqrt{im}\right)\\ \mathbf{elif}\;re \leq 2.35 \cdot 10^{-145}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 1.9 \cdot 10^{-55}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 3
Accuracy82.4%
Cost13444
\[\begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+163}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\ \end{array} \]
Alternative 4
Accuracy52.3%
Cost7772
\[\begin{array}{l} t_0 := 0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\ t_1 := 0.5 \cdot \sqrt{im \cdot -2}\\ \mathbf{if}\;re \leq -2.75 \cdot 10^{-10}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -4 \cdot 10^{-48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq -8.5 \cdot 10^{-306}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \mathbf{elif}\;re \leq 10^{-237}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq 9.2 \cdot 10^{-178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 7.8 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq 10^{-54}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 5
Accuracy52.5%
Cost7772
\[\begin{array}{l} t_0 := 0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\ t_1 := 0.5 \cdot \sqrt{im \cdot -2}\\ \mathbf{if}\;re \leq -8.1 \cdot 10^{-10}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -1.35 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq -1 \cdot 10^{-305}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \mathbf{elif}\;re \leq 2.05 \cdot 10^{-243}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq 4.6 \cdot 10^{-179}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 2 \cdot 10^{-144}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\ \mathbf{elif}\;re \leq 3.6 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 6
Accuracy51.9%
Cost7644
\[\begin{array}{l} t_0 := 0.5 \cdot \sqrt{im \cdot 2}\\ t_1 := 0.5 \cdot \sqrt{im \cdot -2}\\ \mathbf{if}\;re \leq -2.6 \cdot 10^{-14}:\\ \;\;\;\;\sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -0.25}\\ \mathbf{elif}\;re \leq -9.6 \cdot 10^{-48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq -5 \cdot 10^{-306}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 2.7 \cdot 10^{-235}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq 6 \cdot 10^{-178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 5.6 \cdot 10^{-146}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;re \leq 4.8 \cdot 10^{-56}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 7
Accuracy59.5%
Cost6984
\[\begin{array}{l} \mathbf{if}\;im \leq -1.4 \cdot 10^{-143}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot -2}\\ \mathbf{elif}\;im \leq 1.18 \cdot 10^{-164}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \end{array} \]
Alternative 8
Accuracy43.5%
Cost6852
\[\begin{array}{l} \mathbf{if}\;re \leq 1.85 \cdot 10^{-56}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 9
Accuracy27.7%
Cost6720
\[0.5 \cdot \sqrt{im \cdot 2} \]

Error

Reproduce?

herbie shell --seed 2023131 
(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)))))