
(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) (/ (* im 0.5) (sqrt re)) (sqrt (* 0.5 (- (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 = (im * 0.5) / sqrt(re);
} else {
tmp = sqrt((0.5 * (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 = (im * 0.5) / Math.sqrt(re);
} else {
tmp = Math.sqrt((0.5 * (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 = (im * 0.5) / math.sqrt(re) else: tmp = math.sqrt((0.5 * (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(Float64(im * 0.5) / sqrt(re)); else tmp = sqrt(Float64(0.5 * 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 = (im * 0.5) / sqrt(re); else tmp = sqrt((0.5 * (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[(N[(im * 0.5), $MachinePrecision] / N[Sqrt[re], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(0.5 * N[(N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision] - re), $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:\\
\;\;\;\;\frac{im \cdot 0.5}{\sqrt{re}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \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 11.2%
Taylor expanded in re around inf 98.1%
associate-*r*98.1%
sqrt-div98.2%
metadata-eval98.2%
un-div-inv98.1%
sqrt-unprod99.8%
metadata-eval99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-commutative99.8%
Applied egg-rr99.8%
if 0.0 < (sqrt.f64 (*.f64 #s(literal 2 binary64) (-.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re))) Initial program 41.9%
sub-neg41.9%
sqr-neg41.9%
sub-neg41.9%
sqr-neg41.9%
hypot-define90.2%
Simplified90.2%
*-commutative90.2%
hypot-define41.9%
*-commutative41.9%
add-sqr-sqrt41.6%
sqrt-unprod41.9%
*-commutative41.9%
*-commutative41.9%
swap-sqr41.9%
Applied egg-rr90.2%
associate-*l*90.2%
metadata-eval90.2%
Simplified90.2%
Final simplification91.3%
(FPCore (re im) :precision binary64 (if (<= re -8.4e+34) (sqrt (- re)) (if (<= re 2.05e-16) (sqrt (* 0.5 (- im re))) (/ (* im 0.5) (sqrt re)))))
double code(double re, double im) {
double tmp;
if (re <= -8.4e+34) {
tmp = sqrt(-re);
} else if (re <= 2.05e-16) {
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 <= (-8.4d+34)) then
tmp = sqrt(-re)
else if (re <= 2.05d-16) 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 <= -8.4e+34) {
tmp = Math.sqrt(-re);
} else if (re <= 2.05e-16) {
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 <= -8.4e+34: tmp = math.sqrt(-re) elif re <= 2.05e-16: 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 <= -8.4e+34) tmp = sqrt(Float64(-re)); elseif (re <= 2.05e-16) 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 <= -8.4e+34) tmp = sqrt(-re); elseif (re <= 2.05e-16) tmp = sqrt((0.5 * (im - re))); else tmp = (im * 0.5) / sqrt(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -8.4e+34], N[Sqrt[(-re)], $MachinePrecision], If[LessEqual[re, 2.05e-16], 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 -8.4 \cdot 10^{+34}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{elif}\;re \leq 2.05 \cdot 10^{-16}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{im \cdot 0.5}{\sqrt{re}}\\
\end{array}
\end{array}
if re < -8.4000000000000007e34Initial program 33.7%
sub-neg33.7%
sqr-neg33.7%
sub-neg33.7%
sqr-neg33.7%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define33.7%
*-commutative33.7%
add-sqr-sqrt33.5%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 81.1%
neg-mul-181.1%
Simplified81.1%
if -8.4000000000000007e34 < re < 2.05000000000000003e-16Initial program 58.4%
sub-neg58.4%
sqr-neg58.4%
sub-neg58.4%
sqr-neg58.4%
hypot-define91.5%
Simplified91.5%
*-commutative91.5%
hypot-define58.4%
*-commutative58.4%
add-sqr-sqrt58.0%
sqrt-unprod58.4%
*-commutative58.4%
*-commutative58.4%
swap-sqr58.4%
Applied egg-rr91.5%
associate-*l*91.5%
metadata-eval91.5%
Simplified91.5%
Taylor expanded in re around 0 79.5%
neg-mul-179.5%
sub-neg79.5%
Simplified79.5%
if 2.05000000000000003e-16 < re Initial program 9.5%
Taylor expanded in re around inf 77.7%
associate-*r*77.7%
sqrt-div77.7%
metadata-eval77.7%
un-div-inv77.7%
sqrt-unprod78.8%
metadata-eval78.8%
metadata-eval78.8%
*-rgt-identity78.8%
*-commutative78.8%
Applied egg-rr78.8%
Final simplification79.8%
(FPCore (re im) :precision binary64 (if (<= re -5.8e+33) (sqrt (- re)) (if (<= re 2.75e-16) (sqrt (* 0.5 (- im re))) (/ 0.5 (/ (sqrt re) im)))))
double code(double re, double im) {
double tmp;
if (re <= -5.8e+33) {
tmp = sqrt(-re);
} else if (re <= 2.75e-16) {
tmp = sqrt((0.5 * (im - re)));
} else {
tmp = 0.5 / (sqrt(re) / im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-5.8d+33)) then
tmp = sqrt(-re)
else if (re <= 2.75d-16) then
tmp = sqrt((0.5d0 * (im - re)))
else
tmp = 0.5d0 / (sqrt(re) / im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -5.8e+33) {
tmp = Math.sqrt(-re);
} else if (re <= 2.75e-16) {
tmp = Math.sqrt((0.5 * (im - re)));
} else {
tmp = 0.5 / (Math.sqrt(re) / im);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -5.8e+33: tmp = math.sqrt(-re) elif re <= 2.75e-16: tmp = math.sqrt((0.5 * (im - re))) else: tmp = 0.5 / (math.sqrt(re) / im) return tmp
function code(re, im) tmp = 0.0 if (re <= -5.8e+33) tmp = sqrt(Float64(-re)); elseif (re <= 2.75e-16) tmp = sqrt(Float64(0.5 * Float64(im - re))); else tmp = Float64(0.5 / Float64(sqrt(re) / im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -5.8e+33) tmp = sqrt(-re); elseif (re <= 2.75e-16) tmp = sqrt((0.5 * (im - re))); else tmp = 0.5 / (sqrt(re) / im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -5.8e+33], N[Sqrt[(-re)], $MachinePrecision], If[LessEqual[re, 2.75e-16], N[Sqrt[N[(0.5 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(0.5 / N[(N[Sqrt[re], $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -5.8 \cdot 10^{+33}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{elif}\;re \leq 2.75 \cdot 10^{-16}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\frac{\sqrt{re}}{im}}\\
\end{array}
\end{array}
if re < -5.80000000000000049e33Initial program 33.7%
sub-neg33.7%
sqr-neg33.7%
sub-neg33.7%
sqr-neg33.7%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define33.7%
*-commutative33.7%
add-sqr-sqrt33.5%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 81.1%
neg-mul-181.1%
Simplified81.1%
if -5.80000000000000049e33 < re < 2.74999999999999982e-16Initial program 58.4%
sub-neg58.4%
sqr-neg58.4%
sub-neg58.4%
sqr-neg58.4%
hypot-define91.5%
Simplified91.5%
*-commutative91.5%
hypot-define58.4%
*-commutative58.4%
add-sqr-sqrt58.0%
sqrt-unprod58.4%
*-commutative58.4%
*-commutative58.4%
swap-sqr58.4%
Applied egg-rr91.5%
associate-*l*91.5%
metadata-eval91.5%
Simplified91.5%
Taylor expanded in re around 0 79.5%
neg-mul-179.5%
sub-neg79.5%
Simplified79.5%
if 2.74999999999999982e-16 < re Initial program 9.5%
Taylor expanded in re around inf 77.7%
associate-*r*77.7%
sqrt-div77.7%
metadata-eval77.7%
un-div-inv77.7%
sqrt-unprod78.8%
metadata-eval78.8%
metadata-eval78.8%
*-rgt-identity78.8%
*-commutative78.8%
Applied egg-rr78.8%
associate-/l*78.6%
Applied egg-rr78.6%
*-commutative78.6%
associate-/r/78.3%
Simplified78.3%
Final simplification79.7%
(FPCore (re im) :precision binary64 (if (<= re -3.4e+33) (sqrt (- re)) (sqrt (* im 0.5))))
double code(double re, double im) {
double tmp;
if (re <= -3.4e+33) {
tmp = sqrt(-re);
} else {
tmp = sqrt((im * 0.5));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-3.4d+33)) then
tmp = sqrt(-re)
else
tmp = sqrt((im * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -3.4e+33) {
tmp = Math.sqrt(-re);
} else {
tmp = Math.sqrt((im * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -3.4e+33: tmp = math.sqrt(-re) else: tmp = math.sqrt((im * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -3.4e+33) tmp = sqrt(Float64(-re)); else tmp = sqrt(Float64(im * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -3.4e+33) tmp = sqrt(-re); else tmp = sqrt((im * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -3.4e+33], N[Sqrt[(-re)], $MachinePrecision], N[Sqrt[N[(im * 0.5), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.4 \cdot 10^{+33}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{im \cdot 0.5}\\
\end{array}
\end{array}
if re < -3.3999999999999999e33Initial program 33.7%
sub-neg33.7%
sqr-neg33.7%
sub-neg33.7%
sqr-neg33.7%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define33.7%
*-commutative33.7%
add-sqr-sqrt33.5%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 81.1%
neg-mul-181.1%
Simplified81.1%
if -3.3999999999999999e33 < re Initial program 40.3%
sub-neg40.3%
sqr-neg40.3%
sub-neg40.3%
sqr-neg40.3%
hypot-define72.5%
Simplified72.5%
*-commutative72.5%
hypot-define40.3%
*-commutative40.3%
add-sqr-sqrt40.0%
sqrt-unprod40.3%
*-commutative40.3%
*-commutative40.3%
swap-sqr40.3%
Applied egg-rr72.5%
associate-*l*72.5%
metadata-eval72.5%
Simplified72.5%
Taylor expanded in re around 0 59.2%
*-commutative59.2%
Simplified59.2%
(FPCore (re im) :precision binary64 (if (<= re -1e-310) (sqrt (- re)) (sqrt re)))
double code(double re, double im) {
double tmp;
if (re <= -1e-310) {
tmp = sqrt(-re);
} else {
tmp = 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 <= (-1d-310)) then
tmp = sqrt(-re)
else
tmp = sqrt(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1e-310) {
tmp = Math.sqrt(-re);
} else {
tmp = Math.sqrt(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1e-310: tmp = math.sqrt(-re) else: tmp = math.sqrt(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -1e-310) tmp = sqrt(Float64(-re)); else tmp = sqrt(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1e-310) tmp = sqrt(-re); else tmp = sqrt(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1e-310], N[Sqrt[(-re)], $MachinePrecision], N[Sqrt[re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{-re}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{re}\\
\end{array}
\end{array}
if re < -9.999999999999969e-311Initial program 48.1%
sub-neg48.1%
sqr-neg48.1%
sub-neg48.1%
sqr-neg48.1%
hypot-define100.0%
Simplified100.0%
*-commutative100.0%
hypot-define48.1%
*-commutative48.1%
add-sqr-sqrt47.8%
sqrt-unprod48.1%
*-commutative48.1%
*-commutative48.1%
swap-sqr48.1%
Applied egg-rr100.0%
associate-*l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around -inf 57.6%
neg-mul-157.6%
Simplified57.6%
if -9.999999999999969e-311 < re Initial program 26.2%
sub-neg26.2%
sqr-neg26.2%
sub-neg26.2%
sqr-neg26.2%
hypot-define57.5%
Simplified57.5%
*-commutative57.5%
hypot-define26.2%
*-commutative26.2%
add-sqr-sqrt26.0%
sqrt-unprod26.2%
*-commutative26.2%
*-commutative26.2%
swap-sqr26.2%
Applied egg-rr57.5%
associate-*l*57.5%
metadata-eval57.5%
Simplified57.5%
Taylor expanded in re around -inf 0.0%
neg-mul-10.0%
Simplified0.0%
Taylor expanded in re around 0 0.0%
mul-1-neg0.0%
rem-square-sqrt0.0%
distribute-lft-neg-out0.0%
neg-mul-10.0%
rem-square-sqrt0.0%
unpow1/20.0%
metadata-eval0.0%
pow-sqr0.0%
unswap-sqr0.0%
fabs-sqr0.0%
unswap-sqr0.0%
rem-square-sqrt5.5%
pow-sqr5.5%
metadata-eval5.5%
unpow1/25.5%
neg-mul-15.5%
fabs-neg5.5%
unpow1/25.5%
metadata-eval5.5%
pow-sqr5.5%
fabs-sqr5.5%
pow-sqr5.5%
metadata-eval5.5%
unpow1/25.5%
Simplified5.5%
(FPCore (re im) :precision binary64 (sqrt re))
double code(double re, double im) {
return sqrt(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sqrt(re)
end function
public static double code(double re, double im) {
return Math.sqrt(re);
}
def code(re, im): return math.sqrt(re)
function code(re, im) return sqrt(re) end
function tmp = code(re, im) tmp = sqrt(re); end
code[re_, im_] := N[Sqrt[re], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{re}
\end{array}
Initial program 38.3%
sub-neg38.3%
sqr-neg38.3%
sub-neg38.3%
sqr-neg38.3%
hypot-define80.9%
Simplified80.9%
*-commutative80.9%
hypot-define38.3%
*-commutative38.3%
add-sqr-sqrt38.0%
sqrt-unprod38.3%
*-commutative38.3%
*-commutative38.3%
swap-sqr38.3%
Applied egg-rr80.9%
associate-*l*80.9%
metadata-eval80.9%
Simplified80.9%
Taylor expanded in re around -inf 31.7%
neg-mul-131.7%
Simplified31.7%
Taylor expanded in re around 0 31.7%
mul-1-neg31.7%
rem-square-sqrt0.0%
distribute-lft-neg-out0.0%
neg-mul-10.0%
rem-square-sqrt0.0%
unpow1/20.0%
metadata-eval0.0%
pow-sqr0.0%
unswap-sqr0.0%
fabs-sqr0.0%
unswap-sqr0.0%
rem-square-sqrt2.5%
pow-sqr2.5%
metadata-eval2.5%
unpow1/22.5%
neg-mul-12.5%
fabs-neg2.5%
unpow1/22.5%
metadata-eval2.5%
pow-sqr2.5%
fabs-sqr2.5%
pow-sqr2.5%
metadata-eval2.5%
unpow1/22.5%
Simplified2.5%
herbie shell --seed 2024121
(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)))))