
(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 8 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) (* 0.5 (* im (pow re -0.5))) (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 = 0.5 * (im * pow(re, -0.5));
} 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 = 0.5 * (im * Math.pow(re, -0.5));
} 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 = 0.5 * (im * math.pow(re, -0.5)) 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(0.5 * Float64(im * (re ^ -0.5))); 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 = 0.5 * (im * (re ^ -0.5)); 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[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $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:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(\mathsf{hypot}\left(re, im\right) - re\right)}\\
\end{array}
\end{array}
if (sqrt.f64 (*.f64 2 (-.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re))) < 0.0Initial program 8.6%
*-commutative8.6%
hypot-udef8.6%
sqrt-prod8.6%
Applied egg-rr8.6%
Taylor expanded in im around 0 98.9%
associate-*l*98.8%
Simplified98.8%
expm1-log1p-u98.7%
expm1-udef15.6%
Applied egg-rr15.6%
expm1-def99.4%
expm1-log1p99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*l/99.6%
metadata-eval99.6%
unpow1/299.6%
exp-to-pow93.9%
log-rec93.9%
*-commutative93.9%
neg-mul-193.9%
associate-*r*93.9%
metadata-eval93.9%
log-pow93.9%
rem-exp-log99.8%
Simplified99.8%
if 0.0 < (sqrt.f64 (*.f64 2 (-.f64 (sqrt.f64 (+.f64 (*.f64 re re) (*.f64 im im))) re))) Initial program 39.8%
sqr-neg39.8%
sqr-neg39.8%
hypot-def90.2%
Simplified90.2%
add-sqr-sqrt89.5%
sqrt-unprod90.2%
*-commutative90.2%
*-commutative90.2%
swap-sqr90.2%
add-sqr-sqrt90.2%
metadata-eval90.2%
Applied egg-rr90.2%
*-commutative90.2%
associate-*r*90.2%
metadata-eval90.2%
Simplified90.2%
Final simplification91.4%
(FPCore (re im)
:precision binary64
(if (<= re -2.6e+53)
(* 0.5 (sqrt (* 2.0 (- (- (* -0.5 (/ im (/ re im))) re) re))))
(if (<= re 8.2e-54)
(* 0.5 (sqrt (* 2.0 (- im re))))
(if (<= re 4.5e-28)
(* 0.5 (* im (pow re -0.5)))
(if (<= re 1.18e+46)
(* 0.5 (* (sqrt im) (sqrt 2.0)))
(* 0.5 (* im (sqrt (* 2.0 (/ 0.5 re))))))))))
double code(double re, double im) {
double tmp;
if (re <= -2.6e+53) {
tmp = 0.5 * sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re)));
} else if (re <= 8.2e-54) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else if (re <= 4.5e-28) {
tmp = 0.5 * (im * pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = 0.5 * (sqrt(im) * sqrt(2.0));
} else {
tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-2.6d+53)) then
tmp = 0.5d0 * sqrt((2.0d0 * ((((-0.5d0) * (im / (re / im))) - re) - re)))
else if (re <= 8.2d-54) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else if (re <= 4.5d-28) then
tmp = 0.5d0 * (im * (re ** (-0.5d0)))
else if (re <= 1.18d+46) then
tmp = 0.5d0 * (sqrt(im) * sqrt(2.0d0))
else
tmp = 0.5d0 * (im * sqrt((2.0d0 * (0.5d0 / re))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.6e+53) {
tmp = 0.5 * Math.sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re)));
} else if (re <= 8.2e-54) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else if (re <= 4.5e-28) {
tmp = 0.5 * (im * Math.pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = 0.5 * (Math.sqrt(im) * Math.sqrt(2.0));
} else {
tmp = 0.5 * (im * Math.sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.6e+53: tmp = 0.5 * math.sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re))) elif re <= 8.2e-54: tmp = 0.5 * math.sqrt((2.0 * (im - re))) elif re <= 4.5e-28: tmp = 0.5 * (im * math.pow(re, -0.5)) elif re <= 1.18e+46: tmp = 0.5 * (math.sqrt(im) * math.sqrt(2.0)) else: tmp = 0.5 * (im * math.sqrt((2.0 * (0.5 / re)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.6e+53) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(Float64(Float64(-0.5 * Float64(im / Float64(re / im))) - re) - re)))); elseif (re <= 8.2e-54) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); elseif (re <= 4.5e-28) tmp = Float64(0.5 * Float64(im * (re ^ -0.5))); elseif (re <= 1.18e+46) tmp = Float64(0.5 * Float64(sqrt(im) * sqrt(2.0))); else tmp = Float64(0.5 * Float64(im * sqrt(Float64(2.0 * Float64(0.5 / re))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.6e+53) tmp = 0.5 * sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re))); elseif (re <= 8.2e-54) tmp = 0.5 * sqrt((2.0 * (im - re))); elseif (re <= 4.5e-28) tmp = 0.5 * (im * (re ^ -0.5)); elseif (re <= 1.18e+46) tmp = 0.5 * (sqrt(im) * sqrt(2.0)); else tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.6e+53], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[(N[(-0.5 * N[(im / N[(re / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.2e-54], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 4.5e-28], N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.18e+46], N[(0.5 * N[(N[Sqrt[im], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Sqrt[N[(2.0 * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.6 \cdot 10^{+53}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\left(-0.5 \cdot \frac{im}{\frac{re}{im}} - re\right) - re\right)}\\
\mathbf{elif}\;re \leq 8.2 \cdot 10^{-54}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{elif}\;re \leq 4.5 \cdot 10^{-28}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\mathbf{elif}\;re \leq 1.18 \cdot 10^{+46}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{im} \cdot \sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{2 \cdot \frac{0.5}{re}}\right)\\
\end{array}
\end{array}
if re < -2.59999999999999998e53Initial program 32.0%
Taylor expanded in re around -inf 75.9%
neg-mul-175.9%
+-commutative75.9%
unsub-neg75.9%
*-commutative75.9%
unpow275.9%
associate-/l*81.7%
Simplified81.7%
if -2.59999999999999998e53 < re < 8.2000000000000001e-54Initial program 53.3%
Taylor expanded in re around 0 70.3%
if 8.2000000000000001e-54 < re < 4.4999999999999998e-28Initial program 4.7%
*-commutative4.7%
hypot-udef4.7%
sqrt-prod4.7%
Applied egg-rr4.7%
Taylor expanded in im around 0 98.8%
associate-*l*98.4%
Simplified98.4%
expm1-log1p-u98.4%
expm1-udef4.7%
Applied egg-rr4.7%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*l/99.7%
metadata-eval99.7%
unpow1/299.7%
exp-to-pow94.9%
log-rec94.9%
*-commutative94.9%
neg-mul-194.9%
associate-*r*94.9%
metadata-eval94.9%
log-pow94.9%
rem-exp-log100.0%
Simplified100.0%
if 4.4999999999999998e-28 < re < 1.1800000000000001e46Initial program 23.5%
Taylor expanded in re around 0 68.6%
if 1.1800000000000001e46 < re Initial program 10.2%
*-commutative10.2%
hypot-udef46.8%
sqrt-prod46.6%
Applied egg-rr46.6%
Taylor expanded in im around 0 73.5%
associate-*l*73.6%
Simplified73.6%
expm1-log1p-u73.2%
expm1-udef33.5%
Applied egg-rr33.5%
expm1-def73.5%
expm1-log1p74.0%
*-commutative74.0%
associate-*r/74.0%
metadata-eval74.0%
Simplified74.0%
Final simplification74.2%
(FPCore (re im)
:precision binary64
(if (<= re -6.1e+96)
(* 0.5 (sqrt (* 2.0 (* re -2.0))))
(if (<= re 3.95e-53)
(* 0.5 (sqrt (* 2.0 (- im re))))
(if (<= re 7e-18)
(* 0.5 (* im (pow re -0.5)))
(if (<= re 1.18e+46)
(* 0.5 (sqrt (* 2.0 (- (+ im (* 0.5 (/ (* re re) im))) re))))
(* 0.5 (* im (sqrt (* 2.0 (/ 0.5 re))))))))))
double code(double re, double im) {
double tmp;
if (re <= -6.1e+96) {
tmp = 0.5 * sqrt((2.0 * (re * -2.0)));
} else if (re <= 3.95e-53) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else if (re <= 7e-18) {
tmp = 0.5 * (im * pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = 0.5 * sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re)));
} else {
tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-6.1d+96)) then
tmp = 0.5d0 * sqrt((2.0d0 * (re * (-2.0d0))))
else if (re <= 3.95d-53) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else if (re <= 7d-18) then
tmp = 0.5d0 * (im * (re ** (-0.5d0)))
else if (re <= 1.18d+46) then
tmp = 0.5d0 * sqrt((2.0d0 * ((im + (0.5d0 * ((re * re) / im))) - re)))
else
tmp = 0.5d0 * (im * sqrt((2.0d0 * (0.5d0 / re))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -6.1e+96) {
tmp = 0.5 * Math.sqrt((2.0 * (re * -2.0)));
} else if (re <= 3.95e-53) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else if (re <= 7e-18) {
tmp = 0.5 * (im * Math.pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = 0.5 * Math.sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re)));
} else {
tmp = 0.5 * (im * Math.sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -6.1e+96: tmp = 0.5 * math.sqrt((2.0 * (re * -2.0))) elif re <= 3.95e-53: tmp = 0.5 * math.sqrt((2.0 * (im - re))) elif re <= 7e-18: tmp = 0.5 * (im * math.pow(re, -0.5)) elif re <= 1.18e+46: tmp = 0.5 * math.sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re))) else: tmp = 0.5 * (im * math.sqrt((2.0 * (0.5 / re)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -6.1e+96) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re * -2.0)))); elseif (re <= 3.95e-53) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); elseif (re <= 7e-18) tmp = Float64(0.5 * Float64(im * (re ^ -0.5))); elseif (re <= 1.18e+46) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(Float64(im + Float64(0.5 * Float64(Float64(re * re) / im))) - re)))); else tmp = Float64(0.5 * Float64(im * sqrt(Float64(2.0 * Float64(0.5 / re))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -6.1e+96) tmp = 0.5 * sqrt((2.0 * (re * -2.0))); elseif (re <= 3.95e-53) tmp = 0.5 * sqrt((2.0 * (im - re))); elseif (re <= 7e-18) tmp = 0.5 * (im * (re ^ -0.5)); elseif (re <= 1.18e+46) tmp = 0.5 * sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re))); else tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -6.1e+96], N[(0.5 * N[Sqrt[N[(2.0 * N[(re * -2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.95e-53], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 7e-18], N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.18e+46], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[(im + N[(0.5 * N[(N[(re * re), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Sqrt[N[(2.0 * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.1 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re \cdot -2\right)}\\
\mathbf{elif}\;re \leq 3.95 \cdot 10^{-53}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{elif}\;re \leq 7 \cdot 10^{-18}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\mathbf{elif}\;re \leq 1.18 \cdot 10^{+46}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\left(im + 0.5 \cdot \frac{re \cdot re}{im}\right) - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{2 \cdot \frac{0.5}{re}}\right)\\
\end{array}
\end{array}
if re < -6.09999999999999984e96Initial program 27.0%
Taylor expanded in re around -inf 85.5%
*-commutative85.5%
Simplified85.5%
if -6.09999999999999984e96 < re < 3.9499999999999999e-53Initial program 53.6%
Taylor expanded in re around 0 69.3%
if 3.9499999999999999e-53 < re < 6.9999999999999997e-18Initial program 4.7%
*-commutative4.7%
hypot-udef4.7%
sqrt-prod4.7%
Applied egg-rr4.7%
Taylor expanded in im around 0 98.8%
associate-*l*98.4%
Simplified98.4%
expm1-log1p-u98.4%
expm1-udef4.7%
Applied egg-rr4.7%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*l/99.7%
metadata-eval99.7%
unpow1/299.7%
exp-to-pow94.9%
log-rec94.9%
*-commutative94.9%
neg-mul-194.9%
associate-*r*94.9%
metadata-eval94.9%
log-pow94.9%
rem-exp-log100.0%
Simplified100.0%
if 6.9999999999999997e-18 < re < 1.1800000000000001e46Initial program 23.5%
Taylor expanded in re around 0 68.1%
unpow268.1%
Simplified68.1%
if 1.1800000000000001e46 < re Initial program 10.2%
*-commutative10.2%
hypot-udef46.8%
sqrt-prod46.6%
Applied egg-rr46.6%
Taylor expanded in im around 0 73.5%
associate-*l*73.6%
Simplified73.6%
expm1-log1p-u73.2%
expm1-udef33.5%
Applied egg-rr33.5%
expm1-def73.5%
expm1-log1p74.0%
*-commutative74.0%
associate-*r/74.0%
metadata-eval74.0%
Simplified74.0%
Final simplification73.9%
(FPCore (re im)
:precision binary64
(if (<= re -2.7e+53)
(* 0.5 (sqrt (* 2.0 (- (- (* -0.5 (/ im (/ re im))) re) re))))
(if (<= re 2.15e-54)
(* 0.5 (sqrt (* 2.0 (- im re))))
(if (<= re 1.02e-23)
(* 0.5 (* im (pow re -0.5)))
(if (<= re 1.18e+46)
(* 0.5 (sqrt (* 2.0 (- (+ im (* 0.5 (/ (* re re) im))) re))))
(* 0.5 (* im (sqrt (* 2.0 (/ 0.5 re))))))))))
double code(double re, double im) {
double tmp;
if (re <= -2.7e+53) {
tmp = 0.5 * sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re)));
} else if (re <= 2.15e-54) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else if (re <= 1.02e-23) {
tmp = 0.5 * (im * pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = 0.5 * sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re)));
} else {
tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-2.7d+53)) then
tmp = 0.5d0 * sqrt((2.0d0 * ((((-0.5d0) * (im / (re / im))) - re) - re)))
else if (re <= 2.15d-54) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else if (re <= 1.02d-23) then
tmp = 0.5d0 * (im * (re ** (-0.5d0)))
else if (re <= 1.18d+46) then
tmp = 0.5d0 * sqrt((2.0d0 * ((im + (0.5d0 * ((re * re) / im))) - re)))
else
tmp = 0.5d0 * (im * sqrt((2.0d0 * (0.5d0 / re))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.7e+53) {
tmp = 0.5 * Math.sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re)));
} else if (re <= 2.15e-54) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else if (re <= 1.02e-23) {
tmp = 0.5 * (im * Math.pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = 0.5 * Math.sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re)));
} else {
tmp = 0.5 * (im * Math.sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.7e+53: tmp = 0.5 * math.sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re))) elif re <= 2.15e-54: tmp = 0.5 * math.sqrt((2.0 * (im - re))) elif re <= 1.02e-23: tmp = 0.5 * (im * math.pow(re, -0.5)) elif re <= 1.18e+46: tmp = 0.5 * math.sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re))) else: tmp = 0.5 * (im * math.sqrt((2.0 * (0.5 / re)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.7e+53) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(Float64(Float64(-0.5 * Float64(im / Float64(re / im))) - re) - re)))); elseif (re <= 2.15e-54) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); elseif (re <= 1.02e-23) tmp = Float64(0.5 * Float64(im * (re ^ -0.5))); elseif (re <= 1.18e+46) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(Float64(im + Float64(0.5 * Float64(Float64(re * re) / im))) - re)))); else tmp = Float64(0.5 * Float64(im * sqrt(Float64(2.0 * Float64(0.5 / re))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.7e+53) tmp = 0.5 * sqrt((2.0 * (((-0.5 * (im / (re / im))) - re) - re))); elseif (re <= 2.15e-54) tmp = 0.5 * sqrt((2.0 * (im - re))); elseif (re <= 1.02e-23) tmp = 0.5 * (im * (re ^ -0.5)); elseif (re <= 1.18e+46) tmp = 0.5 * sqrt((2.0 * ((im + (0.5 * ((re * re) / im))) - re))); else tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.7e+53], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[(N[(-0.5 * N[(im / N[(re / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.15e-54], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.02e-23], N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.18e+46], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[(im + N[(0.5 * N[(N[(re * re), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Sqrt[N[(2.0 * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.7 \cdot 10^{+53}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\left(-0.5 \cdot \frac{im}{\frac{re}{im}} - re\right) - re\right)}\\
\mathbf{elif}\;re \leq 2.15 \cdot 10^{-54}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{elif}\;re \leq 1.02 \cdot 10^{-23}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\mathbf{elif}\;re \leq 1.18 \cdot 10^{+46}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\left(im + 0.5 \cdot \frac{re \cdot re}{im}\right) - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{2 \cdot \frac{0.5}{re}}\right)\\
\end{array}
\end{array}
if re < -2.70000000000000019e53Initial program 32.0%
Taylor expanded in re around -inf 75.9%
neg-mul-175.9%
+-commutative75.9%
unsub-neg75.9%
*-commutative75.9%
unpow275.9%
associate-/l*81.7%
Simplified81.7%
if -2.70000000000000019e53 < re < 2.15e-54Initial program 53.3%
Taylor expanded in re around 0 70.3%
if 2.15e-54 < re < 1.02000000000000005e-23Initial program 4.7%
*-commutative4.7%
hypot-udef4.7%
sqrt-prod4.7%
Applied egg-rr4.7%
Taylor expanded in im around 0 98.8%
associate-*l*98.4%
Simplified98.4%
expm1-log1p-u98.4%
expm1-udef4.7%
Applied egg-rr4.7%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*l/99.7%
metadata-eval99.7%
unpow1/299.7%
exp-to-pow94.9%
log-rec94.9%
*-commutative94.9%
neg-mul-194.9%
associate-*r*94.9%
metadata-eval94.9%
log-pow94.9%
rem-exp-log100.0%
Simplified100.0%
if 1.02000000000000005e-23 < re < 1.1800000000000001e46Initial program 23.5%
Taylor expanded in re around 0 68.1%
unpow268.1%
Simplified68.1%
if 1.1800000000000001e46 < re Initial program 10.2%
*-commutative10.2%
hypot-udef46.8%
sqrt-prod46.6%
Applied egg-rr46.6%
Taylor expanded in im around 0 73.5%
associate-*l*73.6%
Simplified73.6%
expm1-log1p-u73.2%
expm1-udef33.5%
Applied egg-rr33.5%
expm1-def73.5%
expm1-log1p74.0%
*-commutative74.0%
associate-*r/74.0%
metadata-eval74.0%
Simplified74.0%
Final simplification74.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sqrt (* 2.0 (- im re))))))
(if (<= re -9.2e+96)
(* 0.5 (sqrt (* 2.0 (* re -2.0))))
(if (<= re 3.5e-55)
t_0
(if (<= re 9.5e-17)
(* 0.5 (* im (pow re -0.5)))
(if (<= re 1.18e+46)
t_0
(* 0.5 (* im (sqrt (* 2.0 (/ 0.5 re)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * sqrt((2.0 * (im - re)));
double tmp;
if (re <= -9.2e+96) {
tmp = 0.5 * sqrt((2.0 * (re * -2.0)));
} else if (re <= 3.5e-55) {
tmp = t_0;
} else if (re <= 9.5e-17) {
tmp = 0.5 * (im * pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = t_0;
} else {
tmp = 0.5 * (im * sqrt((2.0 * (0.5 / 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 = 0.5d0 * sqrt((2.0d0 * (im - re)))
if (re <= (-9.2d+96)) then
tmp = 0.5d0 * sqrt((2.0d0 * (re * (-2.0d0))))
else if (re <= 3.5d-55) then
tmp = t_0
else if (re <= 9.5d-17) then
tmp = 0.5d0 * (im * (re ** (-0.5d0)))
else if (re <= 1.18d+46) then
tmp = t_0
else
tmp = 0.5d0 * (im * sqrt((2.0d0 * (0.5d0 / re))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sqrt((2.0 * (im - re)));
double tmp;
if (re <= -9.2e+96) {
tmp = 0.5 * Math.sqrt((2.0 * (re * -2.0)));
} else if (re <= 3.5e-55) {
tmp = t_0;
} else if (re <= 9.5e-17) {
tmp = 0.5 * (im * Math.pow(re, -0.5));
} else if (re <= 1.18e+46) {
tmp = t_0;
} else {
tmp = 0.5 * (im * Math.sqrt((2.0 * (0.5 / re))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sqrt((2.0 * (im - re))) tmp = 0 if re <= -9.2e+96: tmp = 0.5 * math.sqrt((2.0 * (re * -2.0))) elif re <= 3.5e-55: tmp = t_0 elif re <= 9.5e-17: tmp = 0.5 * (im * math.pow(re, -0.5)) elif re <= 1.18e+46: tmp = t_0 else: tmp = 0.5 * (im * math.sqrt((2.0 * (0.5 / re)))) return tmp
function code(re, im) t_0 = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))) tmp = 0.0 if (re <= -9.2e+96) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re * -2.0)))); elseif (re <= 3.5e-55) tmp = t_0; elseif (re <= 9.5e-17) tmp = Float64(0.5 * Float64(im * (re ^ -0.5))); elseif (re <= 1.18e+46) tmp = t_0; else tmp = Float64(0.5 * Float64(im * sqrt(Float64(2.0 * Float64(0.5 / re))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sqrt((2.0 * (im - re))); tmp = 0.0; if (re <= -9.2e+96) tmp = 0.5 * sqrt((2.0 * (re * -2.0))); elseif (re <= 3.5e-55) tmp = t_0; elseif (re <= 9.5e-17) tmp = 0.5 * (im * (re ^ -0.5)); elseif (re <= 1.18e+46) tmp = t_0; else tmp = 0.5 * (im * sqrt((2.0 * (0.5 / re)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -9.2e+96], N[(0.5 * N[Sqrt[N[(2.0 * N[(re * -2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.5e-55], t$95$0, If[LessEqual[re, 9.5e-17], N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.18e+46], t$95$0, N[(0.5 * N[(im * N[Sqrt[N[(2.0 * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{if}\;re \leq -9.2 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re \cdot -2\right)}\\
\mathbf{elif}\;re \leq 3.5 \cdot 10^{-55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 9.5 \cdot 10^{-17}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\mathbf{elif}\;re \leq 1.18 \cdot 10^{+46}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \sqrt{2 \cdot \frac{0.5}{re}}\right)\\
\end{array}
\end{array}
if re < -9.2000000000000006e96Initial program 27.0%
Taylor expanded in re around -inf 85.5%
*-commutative85.5%
Simplified85.5%
if -9.2000000000000006e96 < re < 3.50000000000000025e-55 or 9.50000000000000029e-17 < re < 1.1800000000000001e46Initial program 50.5%
Taylor expanded in re around 0 69.0%
if 3.50000000000000025e-55 < re < 9.50000000000000029e-17Initial program 4.7%
*-commutative4.7%
hypot-udef4.7%
sqrt-prod4.7%
Applied egg-rr4.7%
Taylor expanded in im around 0 98.8%
associate-*l*98.4%
Simplified98.4%
expm1-log1p-u98.4%
expm1-udef4.7%
Applied egg-rr4.7%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*l/99.7%
metadata-eval99.7%
unpow1/299.7%
exp-to-pow94.9%
log-rec94.9%
*-commutative94.9%
neg-mul-194.9%
associate-*r*94.9%
metadata-eval94.9%
log-pow94.9%
rem-exp-log100.0%
Simplified100.0%
if 1.1800000000000001e46 < re Initial program 10.2%
*-commutative10.2%
hypot-udef46.8%
sqrt-prod46.6%
Applied egg-rr46.6%
Taylor expanded in im around 0 73.5%
associate-*l*73.6%
Simplified73.6%
expm1-log1p-u73.2%
expm1-udef33.5%
Applied egg-rr33.5%
expm1-def73.5%
expm1-log1p74.0%
*-commutative74.0%
associate-*r/74.0%
metadata-eval74.0%
Simplified74.0%
Final simplification73.9%
(FPCore (re im)
:precision binary64
(if (<= re -6.4e+96)
(* 0.5 (sqrt (* 2.0 (* re -2.0))))
(if (or (<= re 9e-53) (and (not (<= re 1e-20)) (<= re 1.18e+46)))
(* 0.5 (sqrt (* 2.0 (- im re))))
(* 0.5 (* im (pow re -0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -6.4e+96) {
tmp = 0.5 * sqrt((2.0 * (re * -2.0)));
} else if ((re <= 9e-53) || (!(re <= 1e-20) && (re <= 1.18e+46))) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (im * pow(re, -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 <= (-6.4d+96)) then
tmp = 0.5d0 * sqrt((2.0d0 * (re * (-2.0d0))))
else if ((re <= 9d-53) .or. (.not. (re <= 1d-20)) .and. (re <= 1.18d+46)) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else
tmp = 0.5d0 * (im * (re ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -6.4e+96) {
tmp = 0.5 * Math.sqrt((2.0 * (re * -2.0)));
} else if ((re <= 9e-53) || (!(re <= 1e-20) && (re <= 1.18e+46))) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (im * Math.pow(re, -0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -6.4e+96: tmp = 0.5 * math.sqrt((2.0 * (re * -2.0))) elif (re <= 9e-53) or (not (re <= 1e-20) and (re <= 1.18e+46)): tmp = 0.5 * math.sqrt((2.0 * (im - re))) else: tmp = 0.5 * (im * math.pow(re, -0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -6.4e+96) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re * -2.0)))); elseif ((re <= 9e-53) || (!(re <= 1e-20) && (re <= 1.18e+46))) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); else tmp = Float64(0.5 * Float64(im * (re ^ -0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -6.4e+96) tmp = 0.5 * sqrt((2.0 * (re * -2.0))); elseif ((re <= 9e-53) || (~((re <= 1e-20)) && (re <= 1.18e+46))) tmp = 0.5 * sqrt((2.0 * (im - re))); else tmp = 0.5 * (im * (re ^ -0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -6.4e+96], N[(0.5 * N[Sqrt[N[(2.0 * N[(re * -2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 9e-53], And[N[Not[LessEqual[re, 1e-20]], $MachinePrecision], LessEqual[re, 1.18e+46]]], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.4 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re \cdot -2\right)}\\
\mathbf{elif}\;re \leq 9 \cdot 10^{-53} \lor \neg \left(re \leq 10^{-20}\right) \land re \leq 1.18 \cdot 10^{+46}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\end{array}
\end{array}
if re < -6.40000000000000013e96Initial program 27.0%
Taylor expanded in re around -inf 85.5%
*-commutative85.5%
Simplified85.5%
if -6.40000000000000013e96 < re < 8.9999999999999997e-53 or 9.99999999999999945e-21 < re < 1.1800000000000001e46Initial program 50.5%
Taylor expanded in re around 0 69.0%
if 8.9999999999999997e-53 < re < 9.99999999999999945e-21 or 1.1800000000000001e46 < re Initial program 9.7%
*-commutative9.7%
hypot-udef42.9%
sqrt-prod42.8%
Applied egg-rr42.8%
Taylor expanded in im around 0 75.8%
associate-*l*75.8%
Simplified75.8%
expm1-log1p-u75.5%
expm1-udef30.9%
Applied egg-rr30.9%
expm1-def75.9%
expm1-log1p76.3%
associate-*r/76.3%
metadata-eval76.3%
associate-*l/76.3%
metadata-eval76.3%
unpow1/276.3%
exp-to-pow71.9%
log-rec71.9%
*-commutative71.9%
neg-mul-171.9%
associate-*r*71.9%
metadata-eval71.9%
log-pow71.9%
rem-exp-log76.3%
Simplified76.3%
Final simplification73.9%
(FPCore (re im) :precision binary64 (if (<= re -5e-310) (* 0.5 (sqrt (* 2.0 (* re -2.0)))) (* 0.5 (* im (pow re -0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -5e-310) {
tmp = 0.5 * sqrt((2.0 * (re * -2.0)));
} else {
tmp = 0.5 * (im * pow(re, -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 <= (-5d-310)) then
tmp = 0.5d0 * sqrt((2.0d0 * (re * (-2.0d0))))
else
tmp = 0.5d0 * (im * (re ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -5e-310) {
tmp = 0.5 * Math.sqrt((2.0 * (re * -2.0)));
} else {
tmp = 0.5 * (im * Math.pow(re, -0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -5e-310: tmp = 0.5 * math.sqrt((2.0 * (re * -2.0))) else: tmp = 0.5 * (im * math.pow(re, -0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -5e-310) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(re * -2.0)))); else tmp = Float64(0.5 * Float64(im * (re ^ -0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -5e-310) tmp = 0.5 * sqrt((2.0 * (re * -2.0))); else tmp = 0.5 * (im * (re ^ -0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -5e-310], N[(0.5 * N[Sqrt[N[(2.0 * N[(re * -2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -5 \cdot 10^{-310}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(re \cdot -2\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{-0.5}\right)\\
\end{array}
\end{array}
if re < -4.999999999999985e-310Initial program 48.3%
Taylor expanded in re around -inf 60.9%
*-commutative60.9%
Simplified60.9%
if -4.999999999999985e-310 < re Initial program 23.9%
*-commutative23.9%
hypot-udef60.5%
sqrt-prod60.2%
Applied egg-rr60.2%
Taylor expanded in im around 0 51.8%
associate-*l*51.7%
Simplified51.7%
expm1-log1p-u51.6%
expm1-udef17.9%
Applied egg-rr17.9%
expm1-def51.9%
expm1-log1p52.1%
associate-*r/52.1%
metadata-eval52.1%
associate-*l/52.1%
metadata-eval52.1%
unpow1/252.1%
exp-to-pow49.1%
log-rec49.1%
*-commutative49.1%
neg-mul-149.1%
associate-*r*49.1%
metadata-eval49.1%
log-pow49.1%
rem-exp-log52.1%
Simplified52.1%
Final simplification56.3%
(FPCore (re im) :precision binary64 (* 0.5 (* im (pow re -0.5))))
double code(double re, double im) {
return 0.5 * (im * pow(re, -0.5));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (im * (re ** (-0.5d0)))
end function
public static double code(double re, double im) {
return 0.5 * (im * Math.pow(re, -0.5));
}
def code(re, im): return 0.5 * (im * math.pow(re, -0.5))
function code(re, im) return Float64(0.5 * Float64(im * (re ^ -0.5))) end
function tmp = code(re, im) tmp = 0.5 * (im * (re ^ -0.5)); end
code[re_, im_] := N[(0.5 * N[(im * N[Power[re, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(im \cdot {re}^{-0.5}\right)
\end{array}
Initial program 35.8%
*-commutative35.8%
hypot-udef79.6%
sqrt-prod79.1%
Applied egg-rr79.1%
Taylor expanded in im around 0 26.7%
associate-*l*26.7%
Simplified26.7%
expm1-log1p-u26.6%
expm1-udef9.2%
Applied egg-rr9.2%
expm1-def26.7%
expm1-log1p26.8%
associate-*r/26.8%
metadata-eval26.8%
associate-*l/26.8%
metadata-eval26.8%
unpow1/226.8%
exp-to-pow25.3%
log-rec25.3%
*-commutative25.3%
neg-mul-125.3%
associate-*r*25.3%
metadata-eval25.3%
log-pow25.3%
rem-exp-log26.9%
Simplified26.9%
Final simplification26.9%
herbie shell --seed 2023292
(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)))))