
(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 7 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 (<= re 1.12e-54) (sqrt (* (- (hypot re im) re) 0.5)) (/ (* im 0.5) (sqrt re))))
double code(double re, double im) {
double tmp;
if (re <= 1.12e-54) {
tmp = sqrt(((hypot(re, im) - re) * 0.5));
} else {
tmp = (im * 0.5) / sqrt(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= 1.12e-54) {
tmp = Math.sqrt(((Math.hypot(re, im) - re) * 0.5));
} else {
tmp = (im * 0.5) / Math.sqrt(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.12e-54: tmp = math.sqrt(((math.hypot(re, im) - re) * 0.5)) else: tmp = (im * 0.5) / math.sqrt(re) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.12e-54) tmp = sqrt(Float64(Float64(hypot(re, im) - re) * 0.5)); else tmp = Float64(Float64(im * 0.5) / sqrt(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.12e-54) tmp = sqrt(((hypot(re, im) - re) * 0.5)); else tmp = (im * 0.5) / sqrt(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.12e-54], N[Sqrt[N[(N[(N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision] - re), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[(N[(im * 0.5), $MachinePrecision] / N[Sqrt[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.12 \cdot 10^{-54}:\\
\;\;\;\;\sqrt{\left(\mathsf{hypot}\left(re, im\right) - re\right) \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{im \cdot 0.5}{\sqrt{re}}\\
\end{array}
\end{array}
if re < 1.11999999999999994e-54Initial program 57.3%
sub-neg57.3%
sqr-neg57.3%
sub-neg57.3%
sqr-neg57.3%
hypot-define96.8%
Simplified96.8%
*-commutative96.8%
hypot-define57.3%
*-commutative57.3%
add-sqr-sqrt56.9%
sqrt-unprod57.3%
*-commutative57.3%
*-commutative57.3%
swap-sqr57.3%
Applied egg-rr96.8%
associate-*l*96.8%
metadata-eval96.8%
Simplified96.8%
if 1.11999999999999994e-54 < re Initial program 18.3%
Taylor expanded in re around inf 48.1%
sqrt-div58.8%
sqrt-pow175.9%
metadata-eval75.9%
pow175.9%
associate-*r/75.9%
Applied egg-rr75.9%
*-commutative75.9%
Simplified75.9%
(FPCore (re im) :precision binary64 (if (<= re -7.2e+61) (sqrt (- re)) (if (<= re 5e-50) (sqrt (* 0.5 (- im re))) (/ (* im 0.5) (sqrt re)))))
double code(double re, double im) {
double tmp;
if (re <= -7.2e+61) {
tmp = sqrt(-re);
} else if (re <= 5e-50) {
tmp = sqrt((0.5 * (im - re)));
} else {
tmp = (im * 0.5) / sqrt(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-7.2d+61)) then
tmp = sqrt(-re)
else if (re <= 5d-50) then
tmp = sqrt((0.5d0 * (im - re)))
else
tmp = (im * 0.5d0) / sqrt(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -7.2e+61) {
tmp = Math.sqrt(-re);
} else if (re <= 5e-50) {
tmp = Math.sqrt((0.5 * (im - re)));
} else {
tmp = (im * 0.5) / Math.sqrt(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -7.2e+61: tmp = math.sqrt(-re) elif re <= 5e-50: tmp = math.sqrt((0.5 * (im - re))) else: tmp = (im * 0.5) / math.sqrt(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -7.2e+61) tmp = sqrt(Float64(-re)); elseif (re <= 5e-50) tmp = sqrt(Float64(0.5 * Float64(im - re))); else tmp = Float64(Float64(im * 0.5) / sqrt(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -7.2e+61) tmp = sqrt(-re); elseif (re <= 5e-50) tmp = sqrt((0.5 * (im - re))); else tmp = (im * 0.5) / sqrt(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -7.2e+61], N[Sqrt[(-re)], $MachinePrecision], If[LessEqual[re, 5e-50], N[Sqrt[N[(0.5 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(im * 0.5), $MachinePrecision] / N[Sqrt[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -7.2 \cdot 10^{+61}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{elif}\;re \leq 5 \cdot 10^{-50}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{im \cdot 0.5}{\sqrt{re}}\\
\end{array}
\end{array}
if re < -7.20000000000000021e61Initial program 36.8%
sub-neg36.8%
sqr-neg36.8%
sub-neg36.8%
sqr-neg36.8%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define36.8%
*-commutative36.8%
add-sqr-sqrt36.5%
sqrt-unprod36.8%
*-commutative36.8%
*-commutative36.8%
swap-sqr36.8%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 82.5%
neg-mul-182.5%
Simplified82.5%
if -7.20000000000000021e61 < re < 4.99999999999999968e-50Initial program 64.6%
sub-neg64.6%
sqr-neg64.6%
sub-neg64.6%
sqr-neg64.6%
hypot-define95.6%
Simplified95.6%
*-commutative95.6%
hypot-define64.6%
*-commutative64.6%
add-sqr-sqrt64.1%
sqrt-unprod64.6%
*-commutative64.6%
*-commutative64.6%
swap-sqr64.6%
Applied egg-rr95.6%
associate-*l*95.6%
metadata-eval95.6%
Simplified95.6%
Taylor expanded in re around 0 80.3%
neg-mul-180.3%
unsub-neg80.3%
Simplified80.3%
if 4.99999999999999968e-50 < re Initial program 18.3%
Taylor expanded in re around inf 48.1%
sqrt-div58.8%
sqrt-pow175.9%
metadata-eval75.9%
pow175.9%
associate-*r/75.9%
Applied egg-rr75.9%
*-commutative75.9%
Simplified75.9%
Final simplification79.4%
(FPCore (re im) :precision binary64 (if (<= re -3.1e+64) (sqrt (- re)) (if (<= re 1.26e-51) (sqrt (* 0.5 (- im re))) (* im (sqrt (/ 0.25 re))))))
double code(double re, double im) {
double tmp;
if (re <= -3.1e+64) {
tmp = sqrt(-re);
} else if (re <= 1.26e-51) {
tmp = sqrt((0.5 * (im - re)));
} else {
tmp = im * sqrt((0.25 / re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-3.1d+64)) then
tmp = sqrt(-re)
else if (re <= 1.26d-51) then
tmp = sqrt((0.5d0 * (im - re)))
else
tmp = im * sqrt((0.25d0 / re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -3.1e+64) {
tmp = Math.sqrt(-re);
} else if (re <= 1.26e-51) {
tmp = Math.sqrt((0.5 * (im - re)));
} else {
tmp = im * Math.sqrt((0.25 / re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -3.1e+64: tmp = math.sqrt(-re) elif re <= 1.26e-51: tmp = math.sqrt((0.5 * (im - re))) else: tmp = im * math.sqrt((0.25 / re)) return tmp
function code(re, im) tmp = 0.0 if (re <= -3.1e+64) tmp = sqrt(Float64(-re)); elseif (re <= 1.26e-51) tmp = sqrt(Float64(0.5 * Float64(im - re))); else tmp = Float64(im * sqrt(Float64(0.25 / re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -3.1e+64) tmp = sqrt(-re); elseif (re <= 1.26e-51) tmp = sqrt((0.5 * (im - re))); else tmp = im * sqrt((0.25 / re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -3.1e+64], N[Sqrt[(-re)], $MachinePrecision], If[LessEqual[re, 1.26e-51], N[Sqrt[N[(0.5 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(im * N[Sqrt[N[(0.25 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.1 \cdot 10^{+64}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{elif}\;re \leq 1.26 \cdot 10^{-51}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \sqrt{\frac{0.25}{re}}\\
\end{array}
\end{array}
if re < -3.0999999999999999e64Initial program 36.8%
sub-neg36.8%
sqr-neg36.8%
sub-neg36.8%
sqr-neg36.8%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define36.8%
*-commutative36.8%
add-sqr-sqrt36.5%
sqrt-unprod36.8%
*-commutative36.8%
*-commutative36.8%
swap-sqr36.8%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 82.5%
neg-mul-182.5%
Simplified82.5%
if -3.0999999999999999e64 < re < 1.2600000000000001e-51Initial program 64.6%
sub-neg64.6%
sqr-neg64.6%
sub-neg64.6%
sqr-neg64.6%
hypot-define95.6%
Simplified95.6%
*-commutative95.6%
hypot-define64.6%
*-commutative64.6%
add-sqr-sqrt64.1%
sqrt-unprod64.6%
*-commutative64.6%
*-commutative64.6%
swap-sqr64.6%
Applied egg-rr95.6%
associate-*l*95.6%
metadata-eval95.6%
Simplified95.6%
Taylor expanded in re around 0 80.3%
neg-mul-180.3%
unsub-neg80.3%
Simplified80.3%
if 1.2600000000000001e-51 < re Initial program 18.3%
Taylor expanded in re around inf 48.1%
sqrt-div58.8%
sqrt-pow175.9%
metadata-eval75.9%
pow175.9%
associate-*r/75.9%
Applied egg-rr75.9%
*-commutative75.9%
associate-/l*75.8%
Simplified75.8%
add-sqr-sqrt75.5%
sqrt-unprod75.8%
frac-times75.7%
metadata-eval75.7%
add-sqr-sqrt75.9%
Applied egg-rr75.9%
Final simplification79.4%
(FPCore (re im) :precision binary64 (if (<= re -1.8e+64) (sqrt (- re)) (if (<= re 1.08e+191) (sqrt (* 0.5 (- im re))) 0.0)))
double code(double re, double im) {
double tmp;
if (re <= -1.8e+64) {
tmp = sqrt(-re);
} else if (re <= 1.08e+191) {
tmp = sqrt((0.5 * (im - re)));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-1.8d+64)) then
tmp = sqrt(-re)
else if (re <= 1.08d+191) then
tmp = sqrt((0.5d0 * (im - re)))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.8e+64) {
tmp = Math.sqrt(-re);
} else if (re <= 1.08e+191) {
tmp = Math.sqrt((0.5 * (im - re)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.8e+64: tmp = math.sqrt(-re) elif re <= 1.08e+191: tmp = math.sqrt((0.5 * (im - re))) else: tmp = 0.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -1.8e+64) tmp = sqrt(Float64(-re)); elseif (re <= 1.08e+191) tmp = sqrt(Float64(0.5 * Float64(im - re))); else tmp = 0.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.8e+64) tmp = sqrt(-re); elseif (re <= 1.08e+191) tmp = sqrt((0.5 * (im - re))); else tmp = 0.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.8e+64], N[Sqrt[(-re)], $MachinePrecision], If[LessEqual[re, 1.08e+191], N[Sqrt[N[(0.5 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.8 \cdot 10^{+64}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{elif}\;re \leq 1.08 \cdot 10^{+191}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if re < -1.80000000000000007e64Initial program 36.8%
sub-neg36.8%
sqr-neg36.8%
sub-neg36.8%
sqr-neg36.8%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define36.8%
*-commutative36.8%
add-sqr-sqrt36.5%
sqrt-unprod36.8%
*-commutative36.8%
*-commutative36.8%
swap-sqr36.8%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 82.5%
neg-mul-182.5%
Simplified82.5%
if -1.80000000000000007e64 < re < 1.08000000000000002e191Initial program 54.9%
sub-neg54.9%
sqr-neg54.9%
sub-neg54.9%
sqr-neg54.9%
hypot-define84.0%
Simplified84.0%
*-commutative84.0%
hypot-define54.9%
*-commutative54.9%
add-sqr-sqrt54.4%
sqrt-unprod54.9%
*-commutative54.9%
*-commutative54.9%
swap-sqr54.9%
Applied egg-rr84.0%
associate-*l*84.0%
metadata-eval84.0%
Simplified84.0%
Taylor expanded in re around 0 70.0%
neg-mul-170.0%
unsub-neg70.0%
Simplified70.0%
if 1.08000000000000002e191 < re Initial program 2.3%
Taylor expanded in re around inf 23.8%
Taylor expanded in re around 0 23.8%
metadata-eval23.8%
Applied egg-rr23.8%
Final simplification67.1%
(FPCore (re im) :precision binary64 (if (<= re -8.5e-118) (sqrt (- re)) (if (<= re 1.28e+191) (sqrt (* im 0.5)) 0.0)))
double code(double re, double im) {
double tmp;
if (re <= -8.5e-118) {
tmp = sqrt(-re);
} else if (re <= 1.28e+191) {
tmp = sqrt((im * 0.5));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-8.5d-118)) then
tmp = sqrt(-re)
else if (re <= 1.28d+191) then
tmp = sqrt((im * 0.5d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -8.5e-118) {
tmp = Math.sqrt(-re);
} else if (re <= 1.28e+191) {
tmp = Math.sqrt((im * 0.5));
} else {
tmp = 0.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -8.5e-118: tmp = math.sqrt(-re) elif re <= 1.28e+191: tmp = math.sqrt((im * 0.5)) else: tmp = 0.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -8.5e-118) tmp = sqrt(Float64(-re)); elseif (re <= 1.28e+191) tmp = sqrt(Float64(im * 0.5)); else tmp = 0.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -8.5e-118) tmp = sqrt(-re); elseif (re <= 1.28e+191) tmp = sqrt((im * 0.5)); else tmp = 0.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -8.5e-118], N[Sqrt[(-re)], $MachinePrecision], If[LessEqual[re, 1.28e+191], N[Sqrt[N[(im * 0.5), $MachinePrecision]], $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -8.5 \cdot 10^{-118}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{elif}\;re \leq 1.28 \cdot 10^{+191}:\\
\;\;\;\;\sqrt{im \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if re < -8.50000000000000087e-118Initial program 54.5%
sub-neg54.5%
sqr-neg54.5%
sub-neg54.5%
sqr-neg54.5%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define54.5%
*-commutative54.5%
add-sqr-sqrt54.0%
sqrt-unprod54.5%
*-commutative54.5%
*-commutative54.5%
swap-sqr54.5%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 70.7%
neg-mul-170.7%
Simplified70.7%
if -8.50000000000000087e-118 < re < 1.28e191Initial program 49.3%
sub-neg49.3%
sqr-neg49.3%
sub-neg49.3%
sqr-neg49.3%
hypot-define80.5%
Simplified80.5%
*-commutative80.5%
hypot-define49.3%
*-commutative49.3%
add-sqr-sqrt48.9%
sqrt-unprod49.3%
*-commutative49.3%
*-commutative49.3%
swap-sqr49.3%
Applied egg-rr80.5%
associate-*l*80.5%
metadata-eval80.5%
Simplified80.5%
Taylor expanded in re around 0 73.1%
if 1.28e191 < re Initial program 2.3%
Taylor expanded in re around inf 23.8%
Taylor expanded in re around 0 23.8%
metadata-eval23.8%
Applied egg-rr23.8%
(FPCore (re im) :precision binary64 (if (<= re -2e-310) (sqrt (- re)) 0.0))
double code(double re, double im) {
double tmp;
if (re <= -2e-310) {
tmp = sqrt(-re);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-2d-310)) then
tmp = sqrt(-re)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2e-310) {
tmp = Math.sqrt(-re);
} else {
tmp = 0.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2e-310: tmp = math.sqrt(-re) else: tmp = 0.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -2e-310) tmp = sqrt(Float64(-re)); else tmp = 0.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2e-310) tmp = sqrt(-re); else tmp = 0.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2e-310], N[Sqrt[(-re)], $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if re < -1.999999999999994e-310Initial program 57.4%
sub-neg57.4%
sqr-neg57.4%
sub-neg57.4%
sqr-neg57.4%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define57.4%
*-commutative57.4%
add-sqr-sqrt56.9%
sqrt-unprod57.4%
*-commutative57.4%
*-commutative57.4%
swap-sqr57.4%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 49.7%
neg-mul-149.7%
Simplified49.7%
if -1.999999999999994e-310 < re Initial program 32.6%
Taylor expanded in re around inf 11.4%
Taylor expanded in re around 0 11.4%
metadata-eval11.4%
Applied egg-rr11.4%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 45.6%
Taylor expanded in re around inf 7.0%
Taylor expanded in re around 0 7.0%
metadata-eval7.0%
Applied egg-rr7.0%
herbie shell --seed 2024123
(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)))))