
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x): return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt(x); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x + 1} - \sqrt{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x): return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt(x); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x + 1} - \sqrt{x}
\end{array}
(FPCore (x)
:precision binary64
(if (<= (- (sqrt (+ x 1.0)) (sqrt x)) 5e-5)
(- (/ -0.125 (pow x 1.5)) (* -0.5 (pow x -0.5)))
(*
(/ (+ x (- 1.0 x)) (+ (pow x 1.5) (pow (+ x 1.0) 1.5)))
(- (+ x (+ x 1.0)) (sqrt (* x (+ x 1.0)))))))
double code(double x) {
double tmp;
if ((sqrt((x + 1.0)) - sqrt(x)) <= 5e-5) {
tmp = (-0.125 / pow(x, 1.5)) - (-0.5 * pow(x, -0.5));
} else {
tmp = ((x + (1.0 - x)) / (pow(x, 1.5) + pow((x + 1.0), 1.5))) * ((x + (x + 1.0)) - sqrt((x * (x + 1.0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((sqrt((x + 1.0d0)) - sqrt(x)) <= 5d-5) then
tmp = ((-0.125d0) / (x ** 1.5d0)) - ((-0.5d0) * (x ** (-0.5d0)))
else
tmp = ((x + (1.0d0 - x)) / ((x ** 1.5d0) + ((x + 1.0d0) ** 1.5d0))) * ((x + (x + 1.0d0)) - sqrt((x * (x + 1.0d0))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((Math.sqrt((x + 1.0)) - Math.sqrt(x)) <= 5e-5) {
tmp = (-0.125 / Math.pow(x, 1.5)) - (-0.5 * Math.pow(x, -0.5));
} else {
tmp = ((x + (1.0 - x)) / (Math.pow(x, 1.5) + Math.pow((x + 1.0), 1.5))) * ((x + (x + 1.0)) - Math.sqrt((x * (x + 1.0))));
}
return tmp;
}
def code(x): tmp = 0 if (math.sqrt((x + 1.0)) - math.sqrt(x)) <= 5e-5: tmp = (-0.125 / math.pow(x, 1.5)) - (-0.5 * math.pow(x, -0.5)) else: tmp = ((x + (1.0 - x)) / (math.pow(x, 1.5) + math.pow((x + 1.0), 1.5))) * ((x + (x + 1.0)) - math.sqrt((x * (x + 1.0)))) return tmp
function code(x) tmp = 0.0 if (Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) <= 5e-5) tmp = Float64(Float64(-0.125 / (x ^ 1.5)) - Float64(-0.5 * (x ^ -0.5))); else tmp = Float64(Float64(Float64(x + Float64(1.0 - x)) / Float64((x ^ 1.5) + (Float64(x + 1.0) ^ 1.5))) * Float64(Float64(x + Float64(x + 1.0)) - sqrt(Float64(x * Float64(x + 1.0))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((sqrt((x + 1.0)) - sqrt(x)) <= 5e-5) tmp = (-0.125 / (x ^ 1.5)) - (-0.5 * (x ^ -0.5)); else tmp = ((x + (1.0 - x)) / ((x ^ 1.5) + ((x + 1.0) ^ 1.5))) * ((x + (x + 1.0)) - sqrt((x * (x + 1.0)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 5e-5], N[(N[(-0.125 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(x + N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{x + 1} - \sqrt{x} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{-0.125}{{x}^{1.5}} - -0.5 \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \left(1 - x\right)}{{x}^{1.5} + {\left(x + 1\right)}^{1.5}} \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{x \cdot \left(x + 1\right)}\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) < 5.00000000000000024e-5Initial program 4.7%
Taylor expanded in x around inf
/-lowering-/.f64N/A
remove-double-negN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.6%
div-subN/A
--lowering--.f64N/A
*-commutativeN/A
associate-/l*N/A
sqrt-divN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
rem-square-sqrtN/A
cube-multN/A
/-lowering-/.f64N/A
pow1/2N/A
pow-powN/A
pow-lowering-pow.f64N/A
metadata-evalN/A
*-rgt-identityN/A
times-fracN/A
Applied egg-rr100.0%
if 5.00000000000000024e-5 < (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) Initial program 88.4%
Applied egg-rr99.5%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (- t_0 (sqrt x)) 0.0)
(* (pow x -0.5) 0.5)
(/ (+ x (- 1.0 x)) (+ t_0 (sqrt x))))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if ((t_0 - sqrt(x)) <= 0.0) {
tmp = pow(x, -0.5) * 0.5;
} else {
tmp = (x + (1.0 - x)) / (t_0 + sqrt(x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if ((t_0 - sqrt(x)) <= 0.0d0) then
tmp = (x ** (-0.5d0)) * 0.5d0
else
tmp = (x + (1.0d0 - x)) / (t_0 + sqrt(x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if ((t_0 - Math.sqrt(x)) <= 0.0) {
tmp = Math.pow(x, -0.5) * 0.5;
} else {
tmp = (x + (1.0 - x)) / (t_0 + Math.sqrt(x));
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if (t_0 - math.sqrt(x)) <= 0.0: tmp = math.pow(x, -0.5) * 0.5 else: tmp = (x + (1.0 - x)) / (t_0 + math.sqrt(x)) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(t_0 - sqrt(x)) <= 0.0) tmp = Float64((x ^ -0.5) * 0.5); else tmp = Float64(Float64(x + Float64(1.0 - x)) / Float64(t_0 + sqrt(x))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if ((t_0 - sqrt(x)) <= 0.0) tmp = (x ^ -0.5) * 0.5; else tmp = (x + (1.0 - x)) / (t_0 + sqrt(x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Power[x, -0.5], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;t\_0 - \sqrt{x} \leq 0:\\
\;\;\;\;{x}^{-0.5} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \left(1 - x\right)}{t\_0 + \sqrt{x}}\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) < 0.0Initial program 3.9%
Taylor expanded in x around inf
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6499.8%
Simplified99.8%
*-commutativeN/A
*-lowering-*.f64N/A
inv-powN/A
sqrt-pow1N/A
metadata-evalN/A
pow-lowering-pow.f64100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) Initial program 78.4%
flip--N/A
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
pow1/2N/A
pow-lowering-pow.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6478.3%
Applied egg-rr78.3%
unpow1/2N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f6478.3%
Applied egg-rr78.3%
remove-double-divN/A
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
+-commutativeN/A
rem-square-sqrtN/A
associate--l+N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f6499.5%
Applied egg-rr99.5%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= x 60000000.0) (- (sqrt (+ x 1.0)) (sqrt x)) (* (pow x -0.5) 0.5)))
double code(double x) {
double tmp;
if (x <= 60000000.0) {
tmp = sqrt((x + 1.0)) - sqrt(x);
} else {
tmp = pow(x, -0.5) * 0.5;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 60000000.0d0) then
tmp = sqrt((x + 1.0d0)) - sqrt(x)
else
tmp = (x ** (-0.5d0)) * 0.5d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 60000000.0) {
tmp = Math.sqrt((x + 1.0)) - Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) * 0.5;
}
return tmp;
}
def code(x): tmp = 0 if x <= 60000000.0: tmp = math.sqrt((x + 1.0)) - math.sqrt(x) else: tmp = math.pow(x, -0.5) * 0.5 return tmp
function code(x) tmp = 0.0 if (x <= 60000000.0) tmp = Float64(sqrt(Float64(x + 1.0)) - sqrt(x)); else tmp = Float64((x ^ -0.5) * 0.5); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 60000000.0) tmp = sqrt((x + 1.0)) - sqrt(x); else tmp = (x ^ -0.5) * 0.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 60000000.0], N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 60000000:\\
\;\;\;\;\sqrt{x + 1} - \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot 0.5\\
\end{array}
\end{array}
if x < 6e7Initial program 88.4%
if 6e7 < x Initial program 4.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6499.3%
Simplified99.3%
*-commutativeN/A
*-lowering-*.f64N/A
inv-powN/A
sqrt-pow1N/A
metadata-evalN/A
pow-lowering-pow.f6499.5%
Applied egg-rr99.5%
(FPCore (x) :precision binary64 (- (/ -0.125 (pow x 1.5)) (* -0.5 (pow x -0.5))))
double code(double x) {
return (-0.125 / pow(x, 1.5)) - (-0.5 * pow(x, -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-0.125d0) / (x ** 1.5d0)) - ((-0.5d0) * (x ** (-0.5d0)))
end function
public static double code(double x) {
return (-0.125 / Math.pow(x, 1.5)) - (-0.5 * Math.pow(x, -0.5));
}
def code(x): return (-0.125 / math.pow(x, 1.5)) - (-0.5 * math.pow(x, -0.5))
function code(x) return Float64(Float64(-0.125 / (x ^ 1.5)) - Float64(-0.5 * (x ^ -0.5))) end
function tmp = code(x) tmp = (-0.125 / (x ^ 1.5)) - (-0.5 * (x ^ -0.5)); end
code[x_] := N[(N[(-0.125 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.125}{{x}^{1.5}} - -0.5 \cdot {x}^{-0.5}
\end{array}
Initial program 7.7%
Taylor expanded in x around inf
/-lowering-/.f64N/A
remove-double-negN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6497.8%
Simplified97.8%
div-subN/A
--lowering--.f64N/A
*-commutativeN/A
associate-/l*N/A
sqrt-divN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
rem-square-sqrtN/A
cube-multN/A
/-lowering-/.f64N/A
pow1/2N/A
pow-powN/A
pow-lowering-pow.f64N/A
metadata-evalN/A
*-rgt-identityN/A
times-fracN/A
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (x) :precision binary64 (+ (/ -0.125 (pow x 1.5)) (/ 0.5 (sqrt x))))
double code(double x) {
return (-0.125 / pow(x, 1.5)) + (0.5 / sqrt(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-0.125d0) / (x ** 1.5d0)) + (0.5d0 / sqrt(x))
end function
public static double code(double x) {
return (-0.125 / Math.pow(x, 1.5)) + (0.5 / Math.sqrt(x));
}
def code(x): return (-0.125 / math.pow(x, 1.5)) + (0.5 / math.sqrt(x))
function code(x) return Float64(Float64(-0.125 / (x ^ 1.5)) + Float64(0.5 / sqrt(x))) end
function tmp = code(x) tmp = (-0.125 / (x ^ 1.5)) + (0.5 / sqrt(x)); end
code[x_] := N[(N[(-0.125 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision] + N[(0.5 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.125}{{x}^{1.5}} + \frac{0.5}{\sqrt{x}}
\end{array}
Initial program 7.7%
Taylor expanded in x around inf
/-lowering-/.f64N/A
remove-double-negN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6497.8%
Simplified97.8%
clear-numN/A
associate-/r/N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-lft-neg-inN/A
div-invN/A
div-invN/A
+-lowering-+.f64N/A
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (x) :precision binary64 (* (pow x -0.5) 0.5))
double code(double x) {
return pow(x, -0.5) * 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-0.5d0)) * 0.5d0
end function
public static double code(double x) {
return Math.pow(x, -0.5) * 0.5;
}
def code(x): return math.pow(x, -0.5) * 0.5
function code(x) return Float64((x ^ -0.5) * 0.5) end
function tmp = code(x) tmp = (x ^ -0.5) * 0.5; end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5} \cdot 0.5
\end{array}
Initial program 7.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6497.0%
Simplified97.0%
*-commutativeN/A
*-lowering-*.f64N/A
inv-powN/A
sqrt-pow1N/A
metadata-evalN/A
pow-lowering-pow.f6497.2%
Applied egg-rr97.2%
(FPCore (x) :precision binary64 (/ 0.5 (sqrt x)))
double code(double x) {
return 0.5 / sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 / sqrt(x)
end function
public static double code(double x) {
return 0.5 / Math.sqrt(x);
}
def code(x): return 0.5 / math.sqrt(x)
function code(x) return Float64(0.5 / sqrt(x)) end
function tmp = code(x) tmp = 0.5 / sqrt(x); end
code[x_] := N[(0.5 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{\sqrt{x}}
\end{array}
Initial program 7.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6497.0%
Simplified97.0%
sqrt-divN/A
metadata-evalN/A
un-div-invN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6496.8%
Applied egg-rr96.8%
(FPCore (x) :precision binary64 (- 1.0 (sqrt x)))
double code(double x) {
return 1.0 - sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - sqrt(x)
end function
public static double code(double x) {
return 1.0 - Math.sqrt(x);
}
def code(x): return 1.0 - math.sqrt(x)
function code(x) return Float64(1.0 - sqrt(x)) end
function tmp = code(x) tmp = 1.0 - sqrt(x); end
code[x_] := N[(1.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt{x}
\end{array}
Initial program 7.7%
Taylor expanded in x around 0
--lowering--.f64N/A
sqrt-lowering-sqrt.f641.6%
Simplified1.6%
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))))
double code(double x) {
return 1.0 / (sqrt((x + 1.0)) + sqrt(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))
end function
public static double code(double x) {
return 1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
}
def code(x): return 1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))
function code(x) return Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) end
function tmp = code(x) tmp = 1.0 / (sqrt((x + 1.0)) + sqrt(x)); end
code[x_] := N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x + 1} + \sqrt{x}}
\end{array}
(FPCore (x) :precision binary64 (* 0.5 (pow x -0.5)))
double code(double x) {
return 0.5 * pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 * (x ** (-0.5d0))
end function
public static double code(double x) {
return 0.5 * Math.pow(x, -0.5);
}
def code(x): return 0.5 * math.pow(x, -0.5)
function code(x) return Float64(0.5 * (x ^ -0.5)) end
function tmp = code(x) tmp = 0.5 * (x ^ -0.5); end
code[x_] := N[(0.5 * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot {x}^{-0.5}
\end{array}
herbie shell --seed 2024191
(FPCore (x)
:name "2sqrt (example 3.1)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))
:alt
(! :herbie-platform default (* 1/2 (pow x -1/2)))
(- (sqrt (+ x 1.0)) (sqrt x)))