
(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 14 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 (/ 1.0 (sqrt (+ 1.0 x)))))
(if (<= (- (/ 1.0 (sqrt x)) t_0) 2e-9)
(/
(+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (pow x 2.0))))
(sqrt x))
(- (pow x -0.5) t_0))))
double code(double x) {
double t_0 = 1.0 / sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) - t_0) <= 2e-9) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / pow(x, 2.0)))) / sqrt(x);
} else {
tmp = pow(x, -0.5) - t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) - t_0) <= 2d-9) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) + ((-0.375d0) / (x ** 2.0d0)))) / sqrt(x)
else
tmp = (x ** (-0.5d0)) - t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 / Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) - t_0) <= 2e-9) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) + (-0.375 / Math.pow(x, 2.0)))) / Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) - t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 / math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) - t_0) <= 2e-9: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) + (-0.375 / math.pow(x, 2.0)))) / math.sqrt(x) else: tmp = math.pow(x, -0.5) - t_0 return tmp
function code(x) t_0 = Float64(1.0 / sqrt(Float64(1.0 + x))) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_0) <= 2e-9) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / (x ^ 2.0)))) / sqrt(x)); else tmp = Float64((x ^ -0.5) - t_0); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) - t_0) <= 2e-9) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) + (-0.375 / (x ^ 2.0)))) / sqrt(x); else tmp = (x ^ -0.5) - t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], 2e-9], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{1 + x}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t_0 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{{x}^{2}}\right)}{\sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - t_0\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))) (t_1 (/ 1.0 t_0)))
(if (<= (- (/ 1.0 (sqrt x)) t_1) 2e-9)
(* (/ 1.0 (+ (sqrt x) t_0)) (/ 1.0 (+ x (+ 0.5 (/ -0.125 x)))))
(- (pow x -0.5) t_1))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double t_1 = 1.0 / t_0;
double tmp;
if (((1.0 / sqrt(x)) - t_1) <= 2e-9) {
tmp = (1.0 / (sqrt(x) + t_0)) * (1.0 / (x + (0.5 + (-0.125 / x))));
} else {
tmp = pow(x, -0.5) - t_1;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
t_1 = 1.0d0 / t_0
if (((1.0d0 / sqrt(x)) - t_1) <= 2d-9) then
tmp = (1.0d0 / (sqrt(x) + t_0)) * (1.0d0 / (x + (0.5d0 + ((-0.125d0) / x))))
else
tmp = (x ** (-0.5d0)) - t_1
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double t_1 = 1.0 / t_0;
double tmp;
if (((1.0 / Math.sqrt(x)) - t_1) <= 2e-9) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) * (1.0 / (x + (0.5 + (-0.125 / x))));
} else {
tmp = Math.pow(x, -0.5) - t_1;
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) t_1 = 1.0 / t_0 tmp = 0 if ((1.0 / math.sqrt(x)) - t_1) <= 2e-9: tmp = (1.0 / (math.sqrt(x) + t_0)) * (1.0 / (x + (0.5 + (-0.125 / x)))) else: tmp = math.pow(x, -0.5) - t_1 return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) t_1 = Float64(1.0 / t_0) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_1) <= 2e-9) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) * Float64(1.0 / Float64(x + Float64(0.5 + Float64(-0.125 / x))))); else tmp = Float64((x ^ -0.5) - t_1); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); t_1 = 1.0 / t_0; tmp = 0.0; if (((1.0 / sqrt(x)) - t_1) <= 2e-9) tmp = (1.0 / (sqrt(x) + t_0)) * (1.0 / (x + (0.5 + (-0.125 / x)))); else tmp = (x ^ -0.5) - t_1; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], 2e-9], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
t_1 := \frac{1}{t_0}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t_1 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\sqrt{x} + t_0} \cdot \frac{1}{x + \left(0.5 + \frac{-0.125}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - t_1\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))) (t_1 (/ 1.0 t_0)))
(if (<= (- (/ 1.0 (sqrt x)) t_1) 2e-9)
(* (/ 1.0 (+ (sqrt x) t_0)) (/ 1.0 (+ x 0.5)))
(- (pow x -0.5) t_1))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double t_1 = 1.0 / t_0;
double tmp;
if (((1.0 / sqrt(x)) - t_1) <= 2e-9) {
tmp = (1.0 / (sqrt(x) + t_0)) * (1.0 / (x + 0.5));
} else {
tmp = pow(x, -0.5) - t_1;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
t_1 = 1.0d0 / t_0
if (((1.0d0 / sqrt(x)) - t_1) <= 2d-9) then
tmp = (1.0d0 / (sqrt(x) + t_0)) * (1.0d0 / (x + 0.5d0))
else
tmp = (x ** (-0.5d0)) - t_1
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double t_1 = 1.0 / t_0;
double tmp;
if (((1.0 / Math.sqrt(x)) - t_1) <= 2e-9) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) * (1.0 / (x + 0.5));
} else {
tmp = Math.pow(x, -0.5) - t_1;
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) t_1 = 1.0 / t_0 tmp = 0 if ((1.0 / math.sqrt(x)) - t_1) <= 2e-9: tmp = (1.0 / (math.sqrt(x) + t_0)) * (1.0 / (x + 0.5)) else: tmp = math.pow(x, -0.5) - t_1 return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) t_1 = Float64(1.0 / t_0) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_1) <= 2e-9) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) * Float64(1.0 / Float64(x + 0.5))); else tmp = Float64((x ^ -0.5) - t_1); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); t_1 = 1.0 / t_0; tmp = 0.0; if (((1.0 / sqrt(x)) - t_1) <= 2e-9) tmp = (1.0 / (sqrt(x) + t_0)) * (1.0 / (x + 0.5)); else tmp = (x ^ -0.5) - t_1; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], 2e-9], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
t_1 := \frac{1}{t_0}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t_1 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\sqrt{x} + t_0} \cdot \frac{1}{x + 0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - t_1\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt (+ 1.0 x)))))
(if (<= (- (/ 1.0 (sqrt x)) t_0) 1.5e-9)
(/ (- (/ 0.5 x) (/ 0.375 (pow x 2.0))) (sqrt x))
(- (pow x -0.5) t_0))))
double code(double x) {
double t_0 = 1.0 / sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) - t_0) <= 1.5e-9) {
tmp = ((0.5 / x) - (0.375 / pow(x, 2.0))) / sqrt(x);
} else {
tmp = pow(x, -0.5) - t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) - t_0) <= 1.5d-9) then
tmp = ((0.5d0 / x) - (0.375d0 / (x ** 2.0d0))) / sqrt(x)
else
tmp = (x ** (-0.5d0)) - t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 / Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) - t_0) <= 1.5e-9) {
tmp = ((0.5 / x) - (0.375 / Math.pow(x, 2.0))) / Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) - t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 / math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) - t_0) <= 1.5e-9: tmp = ((0.5 / x) - (0.375 / math.pow(x, 2.0))) / math.sqrt(x) else: tmp = math.pow(x, -0.5) - t_0 return tmp
function code(x) t_0 = Float64(1.0 / sqrt(Float64(1.0 + x))) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_0) <= 1.5e-9) tmp = Float64(Float64(Float64(0.5 / x) - Float64(0.375 / (x ^ 2.0))) / sqrt(x)); else tmp = Float64((x ^ -0.5) - t_0); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) - t_0) <= 1.5e-9) tmp = ((0.5 / x) - (0.375 / (x ^ 2.0))) / sqrt(x); else tmp = (x ^ -0.5) - t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], 1.5e-9], N[(N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{1 + x}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t_0 \leq 1.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{{x}^{2}}}{\sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - t_0\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt (+ 1.0 x)))))
(if (<= (- (/ 1.0 (sqrt x)) t_0) 5e-14)
(/ (/ 0.5 x) (sqrt x))
(- (pow x -0.5) t_0))))
double code(double x) {
double t_0 = 1.0 / sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) - t_0) <= 5e-14) {
tmp = (0.5 / x) / sqrt(x);
} else {
tmp = pow(x, -0.5) - t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) - t_0) <= 5d-14) then
tmp = (0.5d0 / x) / sqrt(x)
else
tmp = (x ** (-0.5d0)) - t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 / Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) - t_0) <= 5e-14) {
tmp = (0.5 / x) / Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) - t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 / math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) - t_0) <= 5e-14: tmp = (0.5 / x) / math.sqrt(x) else: tmp = math.pow(x, -0.5) - t_0 return tmp
function code(x) t_0 = Float64(1.0 / sqrt(Float64(1.0 + x))) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_0) <= 5e-14) tmp = Float64(Float64(0.5 / x) / sqrt(x)); else tmp = Float64((x ^ -0.5) - t_0); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) - t_0) <= 5e-14) tmp = (0.5 / x) / sqrt(x); else tmp = (x ^ -0.5) - t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], 5e-14], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{1 + x}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t_0 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - t_0\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (/ (/ 1.0 (hypot x (sqrt x))) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / hypot(x, sqrt(x))) / (sqrt(x) + sqrt((1.0 + x)));
}
public static double code(double x) {
return (1.0 / Math.hypot(x, Math.sqrt(x))) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x): return (1.0 / math.hypot(x, math.sqrt(x))) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x) return Float64(Float64(1.0 / hypot(x, sqrt(x))) / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) end
function tmp = code(x) tmp = (1.0 / hypot(x, sqrt(x))) / (sqrt(x) + sqrt((1.0 + x))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 122000000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 122000000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else {
tmp = (0.5 / x) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 122000000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else
tmp = (0.5d0 / x) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 122000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else {
tmp = (0.5 / x) / Math.sqrt(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 122000000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) else: tmp = (0.5 / x) / math.sqrt(x) return tmp
function code(x) tmp = 0.0 if (x <= 122000000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); else tmp = Float64(Float64(0.5 / x) / sqrt(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 122000000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = (0.5 / x) / sqrt(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 122000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 122000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 1.7) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = (0.5 / x) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.7d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = (0.5d0 / x) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = (0.5 / x) / Math.sqrt(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = (0.5 / x) / math.sqrt(x) return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(Float64(0.5 / x) / sqrt(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = (0.5 / x) / sqrt(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 1.0) (- (/ 1.0 (sqrt x)) (+ 1.0 (* x -0.5))) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (1.0 / sqrt(x)) - (1.0 + (x * -0.5));
} else {
tmp = (0.5 / x) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (1.0d0 / sqrt(x)) - (1.0d0 + (x * (-0.5d0)))
else
tmp = (0.5d0 / x) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (1.0 / Math.sqrt(x)) - (1.0 + (x * -0.5));
} else {
tmp = (0.5 / x) / Math.sqrt(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (1.0 / math.sqrt(x)) - (1.0 + (x * -0.5)) else: tmp = (0.5 / x) / math.sqrt(x) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 + Float64(x * -0.5))); else tmp = Float64(Float64(0.5 / x) / sqrt(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = (1.0 / sqrt(x)) - (1.0 + (x * -0.5)); else tmp = (0.5 / x) / sqrt(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{1}{\sqrt{x}} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) / Math.sqrt(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = math.pow(x, -0.5) + -1.0 else: tmp = (0.5 / x) / math.sqrt(x) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(Float64(0.5 / x) / sqrt(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = (x ^ -0.5) + -1.0; else tmp = (0.5 / x) / sqrt(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.6) (+ (pow x -0.5) -1.0) (/ 1.0 (+ x 0.5))))
double code(double x) {
double tmp;
if (x <= 0.6) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / (x + 0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.6d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / (x + 0.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.6) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / (x + 0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.6: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 1.0 / (x + 0.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.6) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(1.0 / Float64(x + 0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.6) tmp = (x ^ -0.5) + -1.0; else tmp = 1.0 / (x + 0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.6], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.6:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + 0.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (/ 1.0 (+ x 0.5)))
double code(double x) {
return 1.0 / (x + 0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x + 0.5d0)
end function
public static double code(double x) {
return 1.0 / (x + 0.5);
}
def code(x): return 1.0 / (x + 0.5)
function code(x) return Float64(1.0 / Float64(x + 0.5)) end
function tmp = code(x) tmp = 1.0 / (x + 0.5); end
code[x_] := N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 0.5}
\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 2.0)
double code(double x) {
return 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0
end function
public static double code(double x) {
return 2.0;
}
def code(x): return 2.0
function code(x) return 2.0 end
function tmp = code(x) tmp = 2.0; end
code[x_] := 2.0
\begin{array}{l}
\\
2
\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 2024006
(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)))))