(FPCore (xre xim) :precision binary64 (* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* xre xre) (* xim xim))) xre)))))
double code(double xre, double xim) { return 0.5 * sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))); }
real(8) function code(xre, xim) real(8), intent (in) :: xre real(8), intent (in) :: xim code = 0.5d0 * sqrt((2.0d0 * (sqrt(((xre * xre) + (xim * xim))) + xre))) end function
public static double code(double xre, double xim) { return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((xre * xre) + (xim * xim))) + xre))); }
def code(xre, xim): return 0.5 * math.sqrt((2.0 * (math.sqrt(((xre * xre) + (xim * xim))) + xre)))
function code(xre, xim) return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(xre * xre) + Float64(xim * xim))) + xre)))) end
function tmp = code(xre, xim) tmp = 0.5 * sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))); end
code[xre_, xim_] := N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(xre * xre), $MachinePrecision] + N[(xim * xim), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (xre xim) :precision binary64 (* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* xre xre) (* xim xim))) xre)))))
double code(double xre, double xim) { return 0.5 * sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))); }
real(8) function code(xre, xim) real(8), intent (in) :: xre real(8), intent (in) :: xim code = 0.5d0 * sqrt((2.0d0 * (sqrt(((xre * xre) + (xim * xim))) + xre))) end function
public static double code(double xre, double xim) { return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((xre * xre) + (xim * xim))) + xre))); }
def code(xre, xim): return 0.5 * math.sqrt((2.0 * (math.sqrt(((xre * xre) + (xim * xim))) + xre)))
function code(xre, xim) return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(xre * xre) + Float64(xim * xim))) + xre)))) end
function tmp = code(xre, xim) tmp = 0.5 * sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))); end
code[xre_, xim_] := N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(xre * xre), $MachinePrecision] + N[(xim * xim), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)} \end{array}
(FPCore (xre xim) :precision binary64 (if (<= (sqrt (* 2.0 (+ (sqrt (+ (* xre xre) (* xim xim))) xre))) 0.0) (* (sqrt (/ (* (- xim) xim) xre)) 0.5) (* (sqrt (* (+ (hypot xim xre) xre) 2.0)) 0.5)))
double code(double xre, double xim) { double tmp; if (sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))) <= 0.0) { tmp = sqrt(((-xim * xim) / xre)) * 0.5; } else { tmp = sqrt(((hypot(xim, xre) + xre) * 2.0)) * 0.5; } return tmp; }
public static double code(double xre, double xim) { double tmp; if (Math.sqrt((2.0 * (Math.sqrt(((xre * xre) + (xim * xim))) + xre))) <= 0.0) { tmp = Math.sqrt(((-xim * xim) / xre)) * 0.5; } else { tmp = Math.sqrt(((Math.hypot(xim, xre) + xre) * 2.0)) * 0.5; } return tmp; }
def code(xre, xim): tmp = 0 if math.sqrt((2.0 * (math.sqrt(((xre * xre) + (xim * xim))) + xre))) <= 0.0: tmp = math.sqrt(((-xim * xim) / xre)) * 0.5 else: tmp = math.sqrt(((math.hypot(xim, xre) + xre) * 2.0)) * 0.5 return tmp
function code(xre, xim) tmp = 0.0 if (sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(xre * xre) + Float64(xim * xim))) + xre))) <= 0.0) tmp = Float64(sqrt(Float64(Float64(Float64(-xim) * xim) / xre)) * 0.5); else tmp = Float64(sqrt(Float64(Float64(hypot(xim, xre) + xre) * 2.0)) * 0.5); end return tmp end
function tmp_2 = code(xre, xim) tmp = 0.0; if (sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))) <= 0.0) tmp = sqrt(((-xim * xim) / xre)) * 0.5; else tmp = sqrt(((hypot(xim, xre) + xre) * 2.0)) * 0.5; end tmp_2 = tmp; end
code[xre_, xim_] := If[LessEqual[N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(xre * xre), $MachinePrecision] + N[(xim * xim), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[Sqrt[N[(N[((-xim) * xim), $MachinePrecision] / xre), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[Sqrt[N[(N[(N[Sqrt[xim ^ 2 + xre ^ 2], $MachinePrecision] + xre), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sqrt{2 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)} \leq 0:\\ \;\;\;\;\sqrt{\frac{\left(-xim\right) \cdot xim}{xre}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\mathsf{hypot}\left(xim, xre\right) + xre\right) \cdot 2} \cdot 0.5\\ \end{array} \end{array}
if (sqrt.f64 (*.f64 #s(literal 2 binary64) (+.f64 (sqrt.f64 (+.f64 (*.f64 xre xre) (*.f64 xim xim))) xre))) < 0.0
Initial program 8.9%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
8.9
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
8.9
lift-sqrt.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lower-hypot.f64
8.9
Applied rewrites8.9%
Taylor expanded in xre around -inf
associate-*r/
N/A
lower-/.f64
N/A
unpow2
N/A
associate-*r*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
lower-neg.f64
53.3
Applied rewrites53.3%
if 0.0 < (sqrt.f64 (*.f64 #s(literal 2 binary64) (+.f64 (sqrt.f64 (+.f64 (*.f64 xre xre) (*.f64 xim xim))) xre)))
Initial program 42.3%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
42.3
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
42.3
lift-sqrt.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lower-hypot.f64
89.6
Applied rewrites89.6%
(FPCore (xre xim) :precision binary64 (if (<= xre -1.3e+74) (* (sqrt (/ (* (- xim) xim) xre)) 0.5) (if (<= xre 2.3e-100) (* (sqrt (fma (+ (/ xre xim) 2.0) xre (* 2.0 xim))) 0.5) (if (<= xre 2.7e+86) (* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* xre xre) (* xim xim))) xre)))) (sqrt xre)))))
double code(double xre, double xim) { double tmp; if (xre <= -1.3e+74) { tmp = sqrt(((-xim * xim) / xre)) * 0.5; } else if (xre <= 2.3e-100) { tmp = sqrt(fma(((xre / xim) + 2.0), xre, (2.0 * xim))) * 0.5; } else if (xre <= 2.7e+86) { tmp = 0.5 * sqrt((2.0 * (sqrt(((xre * xre) + (xim * xim))) + xre))); } else { tmp = sqrt(xre); } return tmp; }
function code(xre, xim) tmp = 0.0 if (xre <= -1.3e+74) tmp = Float64(sqrt(Float64(Float64(Float64(-xim) * xim) / xre)) * 0.5); elseif (xre <= 2.3e-100) tmp = Float64(sqrt(fma(Float64(Float64(xre / xim) + 2.0), xre, Float64(2.0 * xim))) * 0.5); elseif (xre <= 2.7e+86) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(xre * xre) + Float64(xim * xim))) + xre)))); else tmp = sqrt(xre); end return tmp end
code[xre_, xim_] := If[LessEqual[xre, -1.3e+74], N[(N[Sqrt[N[(N[((-xim) * xim), $MachinePrecision] / xre), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[xre, 2.3e-100], N[(N[Sqrt[N[(N[(N[(xre / xim), $MachinePrecision] + 2.0), $MachinePrecision] * xre + N[(2.0 * xim), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[xre, 2.7e+86], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(xre * xre), $MachinePrecision] + N[(xim * xim), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[xre], $MachinePrecision]]]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;xre \leq -1.3 \cdot 10^{+74}:\\ \;\;\;\;\sqrt{\frac{\left(-xim\right) \cdot xim}{xre}} \cdot 0.5\\ \mathbf{elif}\;xre \leq 2.3 \cdot 10^{-100}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{xre}{xim} + 2, xre, 2 \cdot xim\right)} \cdot 0.5\\ \mathbf{elif}\;xre \leq 2.7 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{xre}\\ \end{array} \end{array}
if xre < -1.3e74
Initial program 5.4%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
5.4
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
5.4
lift-sqrt.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lower-hypot.f64
39.4
Applied rewrites39.4%
Taylor expanded in xre around -inf
associate-*r/
N/A
lower-/.f64
N/A
unpow2
N/A
associate-*r*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
lower-neg.f64
48.5
Applied rewrites48.5%
if -1.3e74 < xre < 2.29999999999999994e-100
Initial program 50.3%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
50.3
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
50.3
lift-sqrt.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lower-hypot.f64
83.0
Applied rewrites83.0%
Taylor expanded in xre around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-+.f64
N/A
lower-/.f64
N/A
lower-*.f64
77.3
Applied rewrites77.3%
if 2.29999999999999994e-100 < xre < 2.70000000000000018e86
Initial program 74.8%
if 2.70000000000000018e86 < xre
Initial program 21.1%
Taylor expanded in xre around inf
*-commutative
N/A
associate-*r*
N/A
unpow2
N/A
rem-square-sqrt
N/A
metadata-eval
N/A
*-lft-identity
N/A
lower-sqrt.f64
80.6
Applied rewrites80.6%
(FPCore (xre xim) :precision binary64 (if (<= xre -1.3e+74) (* (sqrt (/ (* (- xim) xim) xre)) 0.5) (if (<= xre 2.25e+86) (* 0.5 (sqrt (* 2.0 (+ xim xre)))) (sqrt xre))))
double code(double xre, double xim) { double tmp; if (xre <= -1.3e+74) { tmp = sqrt(((-xim * xim) / xre)) * 0.5; } else if (xre <= 2.25e+86) { tmp = 0.5 * sqrt((2.0 * (xim + xre))); } else { tmp = sqrt(xre); } return tmp; }
real(8) function code(xre, xim) real(8), intent (in) :: xre real(8), intent (in) :: xim real(8) :: tmp if (xre <= (-1.3d+74)) then tmp = sqrt(((-xim * xim) / xre)) * 0.5d0 else if (xre <= 2.25d+86) then tmp = 0.5d0 * sqrt((2.0d0 * (xim + xre))) else tmp = sqrt(xre) end if code = tmp end function
public static double code(double xre, double xim) { double tmp; if (xre <= -1.3e+74) { tmp = Math.sqrt(((-xim * xim) / xre)) * 0.5; } else if (xre <= 2.25e+86) { tmp = 0.5 * Math.sqrt((2.0 * (xim + xre))); } else { tmp = Math.sqrt(xre); } return tmp; }
def code(xre, xim): tmp = 0 if xre <= -1.3e+74: tmp = math.sqrt(((-xim * xim) / xre)) * 0.5 elif xre <= 2.25e+86: tmp = 0.5 * math.sqrt((2.0 * (xim + xre))) else: tmp = math.sqrt(xre) return tmp
function code(xre, xim) tmp = 0.0 if (xre <= -1.3e+74) tmp = Float64(sqrt(Float64(Float64(Float64(-xim) * xim) / xre)) * 0.5); elseif (xre <= 2.25e+86) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(xim + xre)))); else tmp = sqrt(xre); end return tmp end
function tmp_2 = code(xre, xim) tmp = 0.0; if (xre <= -1.3e+74) tmp = sqrt(((-xim * xim) / xre)) * 0.5; elseif (xre <= 2.25e+86) tmp = 0.5 * sqrt((2.0 * (xim + xre))); else tmp = sqrt(xre); end tmp_2 = tmp; end
code[xre_, xim_] := If[LessEqual[xre, -1.3e+74], N[(N[Sqrt[N[(N[((-xim) * xim), $MachinePrecision] / xre), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[xre, 2.25e+86], N[(0.5 * N[Sqrt[N[(2.0 * N[(xim + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[xre], $MachinePrecision]]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;xre \leq -1.3 \cdot 10^{+74}:\\ \;\;\;\;\sqrt{\frac{\left(-xim\right) \cdot xim}{xre}} \cdot 0.5\\ \mathbf{elif}\;xre \leq 2.25 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(xim + xre\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{xre}\\ \end{array} \end{array}
if xre < -1.3e74
Initial program 5.4%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
5.4
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
5.4
lift-sqrt.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lower-hypot.f64
39.4
Applied rewrites39.4%
Taylor expanded in xre around -inf
associate-*r/
N/A
lower-/.f64
N/A
unpow2
N/A
associate-*r*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
lower-neg.f64
48.5
Applied rewrites48.5%
if -1.3e74 < xre < 2.24999999999999996e86
Initial program 56.6%
Taylor expanded in xre around 0
lower-+.f64
73.2
Applied rewrites73.2%
if 2.24999999999999996e86 < xre
Initial program 21.1%
Taylor expanded in xre around inf
*-commutative
N/A
associate-*r*
N/A
unpow2
N/A
rem-square-sqrt
N/A
metadata-eval
N/A
*-lft-identity
N/A
lower-sqrt.f64
80.6
Applied rewrites80.6%
(FPCore (xre xim) :precision binary64 (if (<= xre -1.75e+148) (* 0.5 (sqrt (* 2.0 (+ (- xre) xre)))) (if (<= xre 2.25e+86) (* 0.5 (sqrt (* 2.0 (+ xim xre)))) (sqrt xre))))
double code(double xre, double xim) { double tmp; if (xre <= -1.75e+148) { tmp = 0.5 * sqrt((2.0 * (-xre + xre))); } else if (xre <= 2.25e+86) { tmp = 0.5 * sqrt((2.0 * (xim + xre))); } else { tmp = sqrt(xre); } return tmp; }
real(8) function code(xre, xim) real(8), intent (in) :: xre real(8), intent (in) :: xim real(8) :: tmp if (xre <= (-1.75d+148)) then tmp = 0.5d0 * sqrt((2.0d0 * (-xre + xre))) else if (xre <= 2.25d+86) then tmp = 0.5d0 * sqrt((2.0d0 * (xim + xre))) else tmp = sqrt(xre) end if code = tmp end function
public static double code(double xre, double xim) { double tmp; if (xre <= -1.75e+148) { tmp = 0.5 * Math.sqrt((2.0 * (-xre + xre))); } else if (xre <= 2.25e+86) { tmp = 0.5 * Math.sqrt((2.0 * (xim + xre))); } else { tmp = Math.sqrt(xre); } return tmp; }
def code(xre, xim): tmp = 0 if xre <= -1.75e+148: tmp = 0.5 * math.sqrt((2.0 * (-xre + xre))) elif xre <= 2.25e+86: tmp = 0.5 * math.sqrt((2.0 * (xim + xre))) else: tmp = math.sqrt(xre) return tmp
function code(xre, xim) tmp = 0.0 if (xre <= -1.75e+148) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(Float64(-xre) + xre)))); elseif (xre <= 2.25e+86) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(xim + xre)))); else tmp = sqrt(xre); end return tmp end
function tmp_2 = code(xre, xim) tmp = 0.0; if (xre <= -1.75e+148) tmp = 0.5 * sqrt((2.0 * (-xre + xre))); elseif (xre <= 2.25e+86) tmp = 0.5 * sqrt((2.0 * (xim + xre))); else tmp = sqrt(xre); end tmp_2 = tmp; end
code[xre_, xim_] := If[LessEqual[xre, -1.75e+148], N[(0.5 * N[Sqrt[N[(2.0 * N[((-xre) + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[xre, 2.25e+86], N[(0.5 * N[Sqrt[N[(2.0 * N[(xim + xre), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[xre], $MachinePrecision]]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;xre \leq -1.75 \cdot 10^{+148}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\left(-xre\right) + xre\right)}\\ \mathbf{elif}\;xre \leq 2.25 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(xim + xre\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{xre}\\ \end{array} \end{array}
if xre < -1.7499999999999999e148
Initial program 2.8%
Taylor expanded in xre around -inf
mul-1-neg
N/A
lower-neg.f64
26.4
Applied rewrites26.4%
if -1.7499999999999999e148 < xre < 2.24999999999999996e86
Initial program 52.5%
Taylor expanded in xre around 0
lower-+.f64
68.9
Applied rewrites68.9%
if 2.24999999999999996e86 < xre
Initial program 21.1%
Taylor expanded in xre around inf
*-commutative
N/A
associate-*r*
N/A
unpow2
N/A
rem-square-sqrt
N/A
metadata-eval
N/A
*-lft-identity
N/A
lower-sqrt.f64
80.6
Applied rewrites80.6%
(FPCore (xre xim) :precision binary64 (if (<= xre 1.9e+86) (* (sqrt (* 2.0 xim)) 0.5) (sqrt xre)))
double code(double xre, double xim) { double tmp; if (xre <= 1.9e+86) { tmp = sqrt((2.0 * xim)) * 0.5; } else { tmp = sqrt(xre); } return tmp; }
real(8) function code(xre, xim) real(8), intent (in) :: xre real(8), intent (in) :: xim real(8) :: tmp if (xre <= 1.9d+86) then tmp = sqrt((2.0d0 * xim)) * 0.5d0 else tmp = sqrt(xre) end if code = tmp end function
public static double code(double xre, double xim) { double tmp; if (xre <= 1.9e+86) { tmp = Math.sqrt((2.0 * xim)) * 0.5; } else { tmp = Math.sqrt(xre); } return tmp; }
def code(xre, xim): tmp = 0 if xre <= 1.9e+86: tmp = math.sqrt((2.0 * xim)) * 0.5 else: tmp = math.sqrt(xre) return tmp
function code(xre, xim) tmp = 0.0 if (xre <= 1.9e+86) tmp = Float64(sqrt(Float64(2.0 * xim)) * 0.5); else tmp = sqrt(xre); end return tmp end
function tmp_2 = code(xre, xim) tmp = 0.0; if (xre <= 1.9e+86) tmp = sqrt((2.0 * xim)) * 0.5; else tmp = sqrt(xre); end tmp_2 = tmp; end
code[xre_, xim_] := If[LessEqual[xre, 1.9e+86], N[(N[Sqrt[N[(2.0 * xim), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[Sqrt[xre], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;xre \leq 1.9 \cdot 10^{+86}:\\ \;\;\;\;\sqrt{2 \cdot xim} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\sqrt{xre}\\ \end{array} \end{array}
if xre < 1.89999999999999989e86
Initial program 43.7%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
43.7
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
43.7
lift-sqrt.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lower-hypot.f64
75.3
Applied rewrites75.3%
Taylor expanded in xre around 0
lower-*.f64
59.0
Applied rewrites59.0%
if 1.89999999999999989e86 < xre
Initial program 21.1%
Taylor expanded in xre around inf
*-commutative
N/A
associate-*r*
N/A
unpow2
N/A
rem-square-sqrt
N/A
metadata-eval
N/A
*-lft-identity
N/A
lower-sqrt.f64
80.6
Applied rewrites80.6%
(FPCore (xre xim) :precision binary64 (sqrt xre))
double code(double xre, double xim) { return sqrt(xre); }
real(8) function code(xre, xim) real(8), intent (in) :: xre real(8), intent (in) :: xim code = sqrt(xre) end function
public static double code(double xre, double xim) { return Math.sqrt(xre); }
def code(xre, xim): return math.sqrt(xre)
function code(xre, xim) return sqrt(xre) end
function tmp = code(xre, xim) tmp = sqrt(xre); end
code[xre_, xim_] := N[Sqrt[xre], $MachinePrecision]
\begin{array}{l} \\ \sqrt{xre} \end{array}
Initial program 38.7%
Taylor expanded in xre around inf
*-commutative
N/A
associate-*r*
N/A
unpow2
N/A
rem-square-sqrt
N/A
metadata-eval
N/A
*-lft-identity
N/A
lower-sqrt.f64
28.0
Applied rewrites28.0%
herbie shell --seed 1
(FPCore (xre xim)
:name "0.5 * sqrt(2.0 * (sqrt(xre * xre + xim * xim) + xre))"
:precision binary64
:pre (and (and (<= -1.79e+308 xre) (<= xre 1.79e+308)) (and (<= 0.0 xim) (<= xim 1.79e+308)))
(* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* xre xre) (* xim xim))) xre)))))