math.sqrt on complex, real part

?

Percentage Accurate: 40.6% → 80.8%
Time: 9.0s
Precision: binary64
Cost: 13709

?

\[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)} \]
\[\begin{array}{l} \mathbf{if}\;re \leq -1.05 \cdot 10^{+224}:\\ \;\;\;\;0.5 \cdot \sqrt{\left(-im\right) \cdot \frac{im}{re}}\\ \mathbf{elif}\;re \leq -4.4 \cdot 10^{+72} \lor \neg \left(re \leq -1.06 \cdot 10^{-10}\right):\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{im \cdot im}{-re}}\\ \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.05e+224)
   (* 0.5 (sqrt (* (- im) (/ im re))))
   (if (or (<= re -4.4e+72) (not (<= re -1.06e-10)))
     (* 0.5 (sqrt (* 2.0 (+ re (hypot re im)))))
     (* 0.5 (sqrt (/ (* im im) (- re)))))))
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.05e+224) {
		tmp = 0.5 * sqrt((-im * (im / re)));
	} else if ((re <= -4.4e+72) || !(re <= -1.06e-10)) {
		tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
	} else {
		tmp = 0.5 * sqrt(((im * im) / -re));
	}
	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.05e+224) {
		tmp = 0.5 * Math.sqrt((-im * (im / re)));
	} else if ((re <= -4.4e+72) || !(re <= -1.06e-10)) {
		tmp = 0.5 * Math.sqrt((2.0 * (re + Math.hypot(re, im))));
	} else {
		tmp = 0.5 * Math.sqrt(((im * im) / -re));
	}
	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.05e+224:
		tmp = 0.5 * math.sqrt((-im * (im / re)))
	elif (re <= -4.4e+72) or not (re <= -1.06e-10):
		tmp = 0.5 * math.sqrt((2.0 * (re + math.hypot(re, im))))
	else:
		tmp = 0.5 * math.sqrt(((im * im) / -re))
	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.05e+224)
		tmp = Float64(0.5 * sqrt(Float64(Float64(-im) * Float64(im / re))));
	elseif ((re <= -4.4e+72) || !(re <= -1.06e-10))
		tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re + hypot(re, im)))));
	else
		tmp = Float64(0.5 * sqrt(Float64(Float64(im * im) / Float64(-re))));
	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.05e+224)
		tmp = 0.5 * sqrt((-im * (im / re)));
	elseif ((re <= -4.4e+72) || ~((re <= -1.06e-10)))
		tmp = 0.5 * sqrt((2.0 * (re + hypot(re, im))));
	else
		tmp = 0.5 * sqrt(((im * im) / -re));
	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.05e+224], N[(0.5 * N[Sqrt[N[((-im) * N[(im / re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, -4.4e+72], N[Not[LessEqual[re, -1.06e-10]], $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[Sqrt[N[(N[(im * im), $MachinePrecision] / (-re)), $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.05 \cdot 10^{+224}:\\
\;\;\;\;0.5 \cdot \sqrt{\left(-im\right) \cdot \frac{im}{re}}\\

\mathbf{elif}\;re \leq -4.4 \cdot 10^{+72} \lor \neg \left(re \leq -1.06 \cdot 10^{-10}\right):\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{im \cdot im}{-re}}\\


\end{array}

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.6%
Target48.0%
Herbie80.8%
\[\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 < -1.0500000000000001e224

    1. Initial program 2.4%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}} \]
      Step-by-step derivation

      [Start]2.4

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

      +-commutative [=>]2.4

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

      hypot-def [=>]45.8

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

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

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

      [Start]64.0

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

      *-commutative [=>]64.0

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

      unpow2 [=>]64.0

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

      associate-/l* [=>]88.0

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(0 + \sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -1}\right)} \]
      Step-by-step derivation

      [Start]88.0

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

      add-log-exp [=>]46.1

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

      *-un-lft-identity [=>]46.1

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

      log-prod [=>]46.1

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

      metadata-eval [=>]46.1

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

      add-log-exp [<=]88.0

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

      *-commutative [=>]88.0

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

      associate-*l* [=>]88.0

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

      associate-/r/ [=>]88.0

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

      *-commutative [<=]88.0

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

      metadata-eval [=>]88.0

      \[ 0.5 \cdot \left(0 + \sqrt{\left(im \cdot \frac{im}{re}\right) \cdot \color{blue}{-1}}\right) \]
    6. Simplified88.0%

      \[\leadsto 0.5 \cdot \color{blue}{\sqrt{im \cdot \frac{-im}{re}}} \]
      Step-by-step derivation

      [Start]88.0

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

      +-lft-identity [=>]88.0

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

      associate-*l* [=>]88.0

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

      associate-*l/ [=>]88.0

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

      *-commutative [<=]88.0

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

      neg-mul-1 [<=]88.0

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

    if -1.0500000000000001e224 < re < -4.4e72 or -1.06e-10 < re

    1. Initial program 46.1%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}} \]
      Step-by-step derivation

      [Start]46.1

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

      +-commutative [=>]46.1

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

      hypot-def [=>]90.3

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

    if -4.4e72 < re < -1.06e-10

    1. Initial program 14.8%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}} \]
      Step-by-step derivation

      [Start]14.8

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

      +-commutative [=>]14.8

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

      hypot-def [=>]23.9

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

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

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

      [Start]59.7

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

      *-commutative [=>]59.7

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

      unpow2 [=>]59.7

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

      associate-/l* [=>]59.7

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(0 + \sqrt{\left(im \cdot \frac{im}{re}\right) \cdot -1}\right)} \]
      Step-by-step derivation

      [Start]59.7

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

      add-log-exp [=>]16.9

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

      *-un-lft-identity [=>]16.9

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

      log-prod [=>]16.9

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

      metadata-eval [=>]16.9

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

      add-log-exp [<=]59.7

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

      *-commutative [=>]59.7

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

      associate-*l* [=>]59.7

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

      associate-/r/ [=>]59.7

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

      *-commutative [<=]59.7

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

      metadata-eval [=>]59.7

      \[ 0.5 \cdot \left(0 + \sqrt{\left(im \cdot \frac{im}{re}\right) \cdot \color{blue}{-1}}\right) \]
    6. Simplified59.7%

      \[\leadsto 0.5 \cdot \color{blue}{\sqrt{im \cdot \frac{-im}{re}}} \]
      Step-by-step derivation

      [Start]59.7

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

      +-lft-identity [=>]59.7

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

      associate-*l* [=>]59.7

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

      associate-*l/ [=>]59.7

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

      *-commutative [<=]59.7

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

      neg-mul-1 [<=]59.7

      \[ 0.5 \cdot \sqrt{im \cdot \frac{\color{blue}{-im}}{re}} \]
    7. Applied egg-rr59.7%

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{\frac{im \cdot im}{-re}}} \]
      Step-by-step derivation

      [Start]59.7

      \[ 0.5 \cdot \sqrt{im \cdot \frac{-im}{re}} \]

      associate-*r/ [=>]59.7

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

      frac-2neg [=>]59.7

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

      distribute-lft-neg-out [<=]59.7

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

      sqr-neg [=>]59.7

      \[ 0.5 \cdot \sqrt{\frac{\color{blue}{im \cdot im}}{-re}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.05 \cdot 10^{+224}:\\ \;\;\;\;0.5 \cdot \sqrt{\left(-im\right) \cdot \frac{im}{re}}\\ \mathbf{elif}\;re \leq -4.4 \cdot 10^{+72} \lor \neg \left(re \leq -1.06 \cdot 10^{-10}\right):\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + \mathsf{hypot}\left(re, im\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{im \cdot im}{-re}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy59.2%
Cost7112
\[\begin{array}{l} \mathbf{if}\;im \leq -9 \cdot 10^{-171}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot \left(-2\right)}\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{-37}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\ \end{array} \]
Alternative 2
Accuracy59.9%
Cost7112
\[\begin{array}{l} \mathbf{if}\;im \leq -4.3 \cdot 10^{-169}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re - im\right)}\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{-37}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re + im\right)}\\ \end{array} \]
Alternative 3
Accuracy30.7%
Cost6984
\[\begin{array}{l} \mathbf{if}\;im \leq -1.5 \cdot 10^{-182}:\\ \;\;\;\;0.018518518518518517\\ \mathbf{elif}\;im \leq 10^{-187}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \end{array} \]
Alternative 4
Accuracy43.7%
Cost6984
\[\begin{array}{l} \mathbf{if}\;re \leq -4.8 \cdot 10^{+102}:\\ \;\;\;\;0\\ \mathbf{elif}\;re \leq 2.5 \cdot 10^{-171}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \end{array} \]
Alternative 5
Accuracy58.9%
Cost6984
\[\begin{array}{l} \mathbf{if}\;im \leq -8.6 \cdot 10^{-171}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot \left(-2\right)}\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{-37}:\\ \;\;\;\;0.5 \cdot \left(2 \cdot \sqrt{re}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{im \cdot 2}\\ \end{array} \]
Alternative 6
Accuracy8.8%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -6 \cdot 10^{+94}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;4.885243819643157 \cdot 10^{-22}\\ \end{array} \]
Alternative 7
Accuracy8.8%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -2.3 \cdot 10^{+95}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;4.923200210024256 \cdot 10^{-15}\\ \end{array} \]
Alternative 8
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -6 \cdot 10^{+98}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;4.96145150637606 \cdot 10^{-8}\\ \end{array} \]
Alternative 9
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -7 \cdot 10^{+94}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;1.3395919067215363 \cdot 10^{-6}\\ \end{array} \]
Alternative 10
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -1.45 \cdot 10^{+97}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;3.616898148148148 \cdot 10^{-5}\\ \end{array} \]
Alternative 11
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -1.7 \cdot 10^{+98}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.0001220703125\\ \end{array} \]
Alternative 12
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -2.5 \cdot 10^{+95}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.0009765625\\ \end{array} \]
Alternative 13
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -1.7 \cdot 10^{+95}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.0023148148148148147\\ \end{array} \]
Alternative 14
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -5.5 \cdot 10^{+94}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.0078125\\ \end{array} \]
Alternative 15
Accuracy8.9%
Cost196
\[\begin{array}{l} \mathbf{if}\;re \leq -3.3 \cdot 10^{+94}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.018518518518518517\\ \end{array} \]
Alternative 16
Accuracy6.2%
Cost64
\[0 \]

Error

Reproduce?

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