
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (+ (sqrt (+ x 1.0)) (sqrt x)))) (if (<= x 1e+129) (/ (pow (fma x x x) -0.5) t_0) (/ (/ 1.0 x) t_0))))
double code(double x) {
double t_0 = sqrt((x + 1.0)) + sqrt(x);
double tmp;
if (x <= 1e+129) {
tmp = pow(fma(x, x, x), -0.5) / t_0;
} else {
tmp = (1.0 / x) / t_0;
}
return tmp;
}
function code(x) t_0 = Float64(sqrt(Float64(x + 1.0)) + sqrt(x)) tmp = 0.0 if (x <= 1e+129) tmp = Float64((fma(x, x, x) ^ -0.5) / t_0); else tmp = Float64(Float64(1.0 / x) / t_0); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1e+129], N[(N[Power[N[(x * x + x), $MachinePrecision], -0.5], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1} + \sqrt{x}\\
\mathbf{if}\;x \leq 10^{+129}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, x, x\right)\right)}^{-0.5}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 0.0)
(/ (/ 1.0 x) (+ t_0 (sqrt x)))
(- (pow x -0.5) (pow (+ x 1.0) -0.5)))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = (1.0 / x) / (t_0 + sqrt(x));
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
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 (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 0.0d0) then
tmp = (1.0d0 / x) / (t_0 + sqrt(x))
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = (1.0 / x) / (t_0 + Math.sqrt(x));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0: tmp = (1.0 / x) / (t_0 + math.sqrt(x)) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 0.0) tmp = Float64(Float64(1.0 / x) / Float64(t_0 + sqrt(x))); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) tmp = (1.0 / x) / (t_0 + sqrt(x)); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (/ (* (pow x -0.5) (pow (+ x 1.0) -0.5)) (+ (sqrt (+ x 1.0)) (sqrt x))))
double code(double x) {
return (pow(x, -0.5) * pow((x + 1.0), -0.5)) / (sqrt((x + 1.0)) + sqrt(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x ** (-0.5d0)) * ((x + 1.0d0) ** (-0.5d0))) / (sqrt((x + 1.0d0)) + sqrt(x))
end function
public static double code(double x) {
return (Math.pow(x, -0.5) * Math.pow((x + 1.0), -0.5)) / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
}
def code(x): return (math.pow(x, -0.5) * math.pow((x + 1.0), -0.5)) / (math.sqrt((x + 1.0)) + math.sqrt(x))
function code(x) return Float64(Float64((x ^ -0.5) * (Float64(x + 1.0) ^ -0.5)) / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) end
function tmp = code(x) tmp = ((x ^ -0.5) * ((x + 1.0) ^ -0.5)) / (sqrt((x + 1.0)) + sqrt(x)); end
code[x_] := N[(N[(N[Power[x, -0.5], $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{x}^{-0.5} \cdot {\left(x + 1\right)}^{-0.5}}{\sqrt{x + 1} + \sqrt{x}}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 5900.0) (- (pow x -0.5) (pow (+ x 1.0) -0.5)) (/ (/ 1.0 (+ x (+ 0.5 (/ -0.125 x)))) (+ (sqrt (+ x 1.0)) (sqrt x)))))
double code(double x) {
double tmp;
if (x <= 5900.0) {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
} else {
tmp = (1.0 / (x + (0.5 + (-0.125 / x)))) / (sqrt((x + 1.0)) + sqrt(x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 5900.0d0) then
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
else
tmp = (1.0d0 / (x + (0.5d0 + ((-0.125d0) / x)))) / (sqrt((x + 1.0d0)) + sqrt(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 5900.0) {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
} else {
tmp = (1.0 / (x + (0.5 + (-0.125 / x)))) / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5900.0: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) else: tmp = (1.0 / (x + (0.5 + (-0.125 / x)))) / (math.sqrt((x + 1.0)) + math.sqrt(x)) return tmp
function code(x) tmp = 0.0 if (x <= 5900.0) tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); else tmp = Float64(Float64(1.0 / Float64(x + Float64(0.5 + Float64(-0.125 / x)))) / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5900.0) tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); else tmp = (1.0 / (x + (0.5 + (-0.125 / x)))) / (sqrt((x + 1.0)) + sqrt(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5900.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5900:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x + \left(0.5 + \frac{-0.125}{x}\right)}}{\sqrt{x + 1} + \sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(if (<= x 1.0)
(+ (+ (pow x -0.5) (* x 0.5)) -1.0)
(if (<= x 5.5e+102)
(* 0.5 (sqrt (/ 1.0 (pow x 3.0))))
(/ 1.0 (* (+ (/ -0.125 x) (+ x 0.5)) (+ 1.0 (sqrt x)))))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else if (x <= 5.5e+102) {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
} else {
tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + sqrt(x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else if (x <= 5.5d+102) then
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
else
tmp = 1.0d0 / ((((-0.125d0) / x) + (x + 0.5d0)) * (1.0d0 + sqrt(x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else if (x <= 5.5e+102) {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
} else {
tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + Math.sqrt(x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 elif x <= 5.5e+102: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) else: tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + math.sqrt(x))) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); elseif (x <= 5.5e+102) tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); else tmp = Float64(1.0 / Float64(Float64(Float64(-0.125 / x) + Float64(x + 0.5)) * Float64(1.0 + sqrt(x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; elseif (x <= 5.5e+102) tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); else tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + sqrt(x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 5.5e+102], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(-0.125 / x), $MachinePrecision] + N[(x + 0.5), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\frac{-0.125}{x} + \left(x + 0.5\right)\right) \cdot \left(1 + \sqrt{x}\right)}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(if (<= x 105000000.0)
(- (pow x -0.5) (pow (+ x 1.0) -0.5))
(if (<= x 5.5e+102)
(* 0.5 (sqrt (/ 1.0 (pow x 3.0))))
(/ 1.0 (* (+ (/ -0.125 x) (+ x 0.5)) (+ 1.0 (sqrt x)))))))
double code(double x) {
double tmp;
if (x <= 105000000.0) {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
} else if (x <= 5.5e+102) {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
} else {
tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + sqrt(x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 105000000.0d0) then
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
else if (x <= 5.5d+102) then
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
else
tmp = 1.0d0 / ((((-0.125d0) / x) + (x + 0.5d0)) * (1.0d0 + sqrt(x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 105000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
} else if (x <= 5.5e+102) {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
} else {
tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + Math.sqrt(x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 105000000.0: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) elif x <= 5.5e+102: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) else: tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + math.sqrt(x))) return tmp
function code(x) tmp = 0.0 if (x <= 105000000.0) tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); elseif (x <= 5.5e+102) tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); else tmp = Float64(1.0 / Float64(Float64(Float64(-0.125 / x) + Float64(x + 0.5)) * Float64(1.0 + sqrt(x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 105000000.0) tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); elseif (x <= 5.5e+102) tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); else tmp = 1.0 / (((-0.125 / x) + (x + 0.5)) * (1.0 + sqrt(x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 105000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+102], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(-0.125 / x), $MachinePrecision] + N[(x + 0.5), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 105000000:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\frac{-0.125}{x} + \left(x + 0.5\right)\right) \cdot \left(1 + \sqrt{x}\right)}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.41) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (/ 1.0 (+ x 0.5)) (+ 1.0 (sqrt x)))))
double code(double x) {
double tmp;
if (x <= 0.41) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 / (x + 0.5)) / (1.0 + sqrt(x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.41d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (1.0d0 / (x + 0.5d0)) / (1.0d0 + sqrt(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.41) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 / (x + 0.5)) / (1.0 + Math.sqrt(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.41: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (1.0 / (x + 0.5)) / (1.0 + math.sqrt(x)) return tmp
function code(x) tmp = 0.0 if (x <= 0.41) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(1.0 / Float64(x + 0.5)) / Float64(1.0 + sqrt(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.41) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (1.0 / (x + 0.5)) / (1.0 + sqrt(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.41], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.41:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x + 0.5}}{1 + \sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (/ 1.0 x) (+ 1.0 (sqrt x)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 / x) / (1.0 + sqrt(x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (1.0d0 / x) / (1.0d0 + sqrt(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 / x) / (1.0 + Math.sqrt(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (1.0 / x) / (1.0 + math.sqrt(x)) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(1.0 / x) / Float64(1.0 + sqrt(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (1.0 / x) / (1.0 + sqrt(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{1 + \sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.62) (+ (pow x -0.5) -1.0) (/ (/ 1.0 x) (+ 1.0 (sqrt x)))))
double code(double x) {
double tmp;
if (x <= 0.62) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = (1.0 / x) / (1.0 + sqrt(x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.62d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (1.0d0 / x) / (1.0d0 + sqrt(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.62) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = (1.0 / x) / (1.0 + Math.sqrt(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.62: tmp = math.pow(x, -0.5) + -1.0 else: tmp = (1.0 / x) / (1.0 + math.sqrt(x)) return tmp
function code(x) tmp = 0.0 if (x <= 0.62) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(Float64(1.0 / x) / Float64(1.0 + sqrt(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.62) tmp = (x ^ -0.5) + -1.0; else tmp = (1.0 / x) / (1.0 + sqrt(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.62], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.62:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{1 + \sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.72) (+ (pow x -0.5) -1.0) (/ 1.0 (+ x (+ 0.5 (/ -0.125 x))))))
double code(double x) {
double tmp;
if (x <= 0.72) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / (x + (0.5 + (-0.125 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.72d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / (x + (0.5d0 + ((-0.125d0) / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.72) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / (x + (0.5 + (-0.125 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.72: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 1.0 / (x + (0.5 + (-0.125 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.72) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(1.0 / Float64(x + Float64(0.5 + Float64(-0.125 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.72) tmp = (x ^ -0.5) + -1.0; else tmp = 1.0 / (x + (0.5 + (-0.125 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.72], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / N[(x + N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.72:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + \left(0.5 + \frac{-0.125}{x}\right)}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
(FPCore (x) :precision binary64 (/ 1.0 (+ x (+ 0.5 (/ -0.125 x)))))
double code(double x) {
return 1.0 / (x + (0.5 + (-0.125 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x + (0.5d0 + ((-0.125d0) / x)))
end function
public static double code(double x) {
return 1.0 / (x + (0.5 + (-0.125 / x)));
}
def code(x): return 1.0 / (x + (0.5 + (-0.125 / x)))
function code(x) return Float64(1.0 / Float64(x + Float64(0.5 + Float64(-0.125 / x)))) end
function tmp = code(x) tmp = 1.0 / (x + (0.5 + (-0.125 / x))); end
code[x_] := N[(1.0 / N[(x + N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + \left(0.5 + \frac{-0.125}{x}\right)}
\end{array}
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
(FPCore (x) :precision binary64 (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0))))))
double code(double x) {
return 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (((x + 1.0d0) * sqrt(x)) + (x * sqrt((x + 1.0d0))))
end function
public static double code(double x) {
return 1.0 / (((x + 1.0) * Math.sqrt(x)) + (x * Math.sqrt((x + 1.0))));
}
def code(x): return 1.0 / (((x + 1.0) * math.sqrt(x)) + (x * math.sqrt((x + 1.0))))
function code(x) return Float64(1.0 / Float64(Float64(Float64(x + 1.0) * sqrt(x)) + Float64(x * sqrt(Float64(x + 1.0))))) end
function tmp = code(x) tmp = 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0)))); end
code[x_] := N[(1.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}
herbie shell --seed 2024010
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))