
(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 9 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 (/ (pow (+ x 1.0) -0.5) (* x (+ (sqrt (/ (+ x 1.0) x)) 1.0))))
double code(double x) {
return pow((x + 1.0), -0.5) / (x * (sqrt(((x + 1.0) / x)) + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) / (x * (sqrt(((x + 1.0d0) / x)) + 1.0d0))
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) / (x * (Math.sqrt(((x + 1.0) / x)) + 1.0));
}
def code(x): return math.pow((x + 1.0), -0.5) / (x * (math.sqrt(((x + 1.0) / x)) + 1.0))
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) / Float64(x * Float64(sqrt(Float64(Float64(x + 1.0) / x)) + 1.0))) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) / (x * (sqrt(((x + 1.0) / x)) + 1.0)); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * N[(N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(x + 1\right)}^{-0.5}}{x \cdot \left(\sqrt{\frac{x + 1}{x}} + 1\right)}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
flip-+39.3%
sqrt-undiv39.3%
sqrt-undiv39.3%
add-sqr-sqrt39.5%
metadata-eval39.5%
sqrt-undiv39.5%
Applied egg-rr39.5%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
+-commutative99.6%
div-inv99.6%
sub-neg99.6%
+-commutative99.6%
metadata-eval99.6%
clear-num99.7%
/-rgt-identity99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (* (/ (+ 0.5 (/ (- (/ (+ 0.0625 (/ -0.0390625 x)) x) 0.125) x)) x) (pow (+ x 1.0) -0.5)))
double code(double x) {
return ((0.5 + ((((0.0625 + (-0.0390625 / x)) / x) - 0.125) / x)) / x) * pow((x + 1.0), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((0.5d0 + ((((0.0625d0 + ((-0.0390625d0) / x)) / x) - 0.125d0) / x)) / x) * ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
return ((0.5 + ((((0.0625 + (-0.0390625 / x)) / x) - 0.125) / x)) / x) * Math.pow((x + 1.0), -0.5);
}
def code(x): return ((0.5 + ((((0.0625 + (-0.0390625 / x)) / x) - 0.125) / x)) / x) * math.pow((x + 1.0), -0.5)
function code(x) return Float64(Float64(Float64(0.5 + Float64(Float64(Float64(Float64(0.0625 + Float64(-0.0390625 / x)) / x) - 0.125) / x)) / x) * (Float64(x + 1.0) ^ -0.5)) end
function tmp = code(x) tmp = ((0.5 + ((((0.0625 + (-0.0390625 / x)) / x) - 0.125) / x)) / x) * ((x + 1.0) ^ -0.5); end
code[x_] := N[(N[(N[(0.5 + N[(N[(N[(N[(0.0625 + N[(-0.0390625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.125), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 + \frac{\frac{0.0625 + \frac{-0.0390625}{x}}{x} - 0.125}{x}}{x} \cdot {\left(x + 1\right)}^{-0.5}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
Taylor expanded in x around inf 99.3%
associate--l+99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around -inf 99.3%
mul-1-neg99.3%
unsub-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
sub-neg99.3%
associate-*r/99.3%
metadata-eval99.3%
distribute-neg-frac99.3%
metadata-eval99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ (/ 1.0 x) (+ 2.0 (/ (+ 0.5 (/ -0.125 x)) x)))))
double code(double x) {
return pow((x + 1.0), -0.5) * ((1.0 / x) / (2.0 + ((0.5 + (-0.125 / x)) / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * ((1.0d0 / x) / (2.0d0 + ((0.5d0 + ((-0.125d0) / x)) / x)))
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * ((1.0 / x) / (2.0 + ((0.5 + (-0.125 / x)) / x)));
}
def code(x): return math.pow((x + 1.0), -0.5) * ((1.0 / x) / (2.0 + ((0.5 + (-0.125 / x)) / x)))
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(1.0 / x) / Float64(2.0 + Float64(Float64(0.5 + Float64(-0.125 / x)) / x)))) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * ((1.0 / x) / (2.0 + ((0.5 + (-0.125 / x)) / x))); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(2.0 + N[(N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{\frac{1}{x}}{2 + \frac{0.5 + \frac{-0.125}{x}}{x}}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
flip-+39.3%
sqrt-undiv39.3%
sqrt-undiv39.3%
add-sqr-sqrt39.5%
metadata-eval39.5%
sqrt-undiv39.5%
Applied egg-rr39.5%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around inf 99.2%
associate--l+99.2%
associate-*r/99.2%
metadata-eval99.2%
unpow299.2%
associate-/l/99.2%
div-sub99.2%
sub-neg99.2%
distribute-neg-frac299.2%
neg-mul-199.2%
rem-square-sqrt0.0%
unpow20.0%
*-commutative0.0%
metadata-eval0.0%
associate-*r/0.0%
Simplified99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ (+ 0.5 (/ (+ -0.125 (/ 0.0625 x)) x)) x)))
double code(double x) {
return pow((x + 1.0), -0.5) * ((0.5 + ((-0.125 + (0.0625 / x)) / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * ((0.5d0 + (((-0.125d0) + (0.0625d0 / x)) / x)) / x)
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * ((0.5 + ((-0.125 + (0.0625 / x)) / x)) / x);
}
def code(x): return math.pow((x + 1.0), -0.5) * ((0.5 + ((-0.125 + (0.0625 / x)) / x)) / x)
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(0.5 + Float64(Float64(-0.125 + Float64(0.0625 / x)) / x)) / x)) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * ((0.5 + ((-0.125 + (0.0625 / x)) / x)) / x); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(0.5 + N[(N[(-0.125 + N[(0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{0.5 + \frac{-0.125 + \frac{0.0625}{x}}{x}}{x}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
Taylor expanded in x around inf 99.3%
associate--l+99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 99.2%
sub-neg99.2%
associate-*r/99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (/ (* (pow (+ x 1.0) -0.5) (- 0.5 (/ 0.125 x))) x))
double code(double x) {
return (pow((x + 1.0), -0.5) * (0.5 - (0.125 / x))) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (((x + 1.0d0) ** (-0.5d0)) * (0.5d0 - (0.125d0 / x))) / x
end function
public static double code(double x) {
return (Math.pow((x + 1.0), -0.5) * (0.5 - (0.125 / x))) / x;
}
def code(x): return (math.pow((x + 1.0), -0.5) * (0.5 - (0.125 / x))) / x
function code(x) return Float64(Float64((Float64(x + 1.0) ^ -0.5) * Float64(0.5 - Float64(0.125 / x))) / x) end
function tmp = code(x) tmp = (((x + 1.0) ^ -0.5) * (0.5 - (0.125 / x))) / x; end
code[x_] := N[(N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(x + 1\right)}^{-0.5} \cdot \left(0.5 - \frac{0.125}{x}\right)}{x}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
associate-*l/98.9%
+-commutative98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (* (+ 0.5 (/ -0.125 x)) (/ (pow (+ x 1.0) -0.5) x)))
double code(double x) {
return (0.5 + (-0.125 / x)) * (pow((x + 1.0), -0.5) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 + ((-0.125d0) / x)) * (((x + 1.0d0) ** (-0.5d0)) / x)
end function
public static double code(double x) {
return (0.5 + (-0.125 / x)) * (Math.pow((x + 1.0), -0.5) / x);
}
def code(x): return (0.5 + (-0.125 / x)) * (math.pow((x + 1.0), -0.5) / x)
function code(x) return Float64(Float64(0.5 + Float64(-0.125 / x)) * Float64((Float64(x + 1.0) ^ -0.5) / x)) end
function tmp = code(x) tmp = (0.5 + (-0.125 / x)) * (((x + 1.0) ^ -0.5) / x); end
code[x_] := N[(N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 + \frac{-0.125}{x}\right) \cdot \frac{{\left(x + 1\right)}^{-0.5}}{x}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
clear-num98.8%
inv-pow98.8%
Applied egg-rr98.8%
unpow-198.8%
sub-neg98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
Simplified98.8%
associate-*l/98.9%
*-un-lft-identity98.9%
clear-num97.2%
+-commutative97.2%
Applied egg-rr97.2%
associate-/r/98.8%
associate-/r/98.8%
associate-*l/98.9%
*-lft-identity98.9%
*-commutative98.9%
*-lft-identity98.9%
associate-*l/98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*l/98.9%
*-lft-identity98.9%
+-commutative98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ (- 0.5 (/ 0.125 x)) x)))
double code(double x) {
return pow((x + 1.0), -0.5) * ((0.5 - (0.125 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * ((0.5d0 - (0.125d0 / x)) / x)
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * ((0.5 - (0.125 / x)) / x);
}
def code(x): return math.pow((x + 1.0), -0.5) * ((0.5 - (0.125 / x)) / x)
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(0.5 - Float64(0.125 / x)) / x)) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * ((0.5 - (0.125 / x)) / x); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{0.5 - \frac{0.125}{x}}{x}
\end{array}
Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
associate-*l/39.3%
*-un-lft-identity39.3%
inv-pow39.3%
sqrt-pow239.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.2%
sub-neg39.2%
*-inverses39.2%
metadata-eval39.2%
/-rgt-identity39.2%
Simplified39.2%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (* 0.5 (pow x -1.5)))
double code(double x) {
return 0.5 * pow(x, -1.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 * (x ** (-1.5d0))
end function
public static double code(double x) {
return 0.5 * Math.pow(x, -1.5);
}
def code(x): return 0.5 * math.pow(x, -1.5)
function code(x) return Float64(0.5 * (x ^ -1.5)) end
function tmp = code(x) tmp = 0.5 * (x ^ -1.5); end
code[x_] := N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot {x}^{-1.5}
\end{array}
Initial program 39.3%
add-exp-log7.9%
log-rec7.9%
pow1/27.9%
log-pow7.9%
+-commutative7.9%
log1p-define7.9%
Applied egg-rr7.9%
Taylor expanded in x around inf 7.0%
+-commutative7.0%
distribute-lft-neg-in7.0%
metadata-eval7.0%
*-commutative7.0%
exp-to-pow38.4%
unpow1/238.4%
associate--l+93.7%
Simplified67.6%
+-rgt-identity67.6%
*-commutative67.6%
sqrt-pow197.8%
metadata-eval97.8%
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 39.3%
add-exp-log7.9%
log-rec7.9%
pow1/27.9%
log-pow7.9%
+-commutative7.9%
log1p-define7.9%
Applied egg-rr7.9%
Taylor expanded in x around inf 5.0%
distribute-lft-neg-in5.0%
metadata-eval5.0%
*-commutative5.0%
exp-to-pow36.2%
unpow1/236.2%
+-inverses36.2%
Simplified36.2%
(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}
(FPCore (x) :precision binary64 (- (pow x -0.5) (pow (+ x 1.0) -0.5)))
double code(double x) {
return pow(x, -0.5) - pow((x + 1.0), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
return Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
def code(x): return math.pow(x, -0.5) - math.pow((x + 1.0), -0.5)
function code(x) return Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)) end
function tmp = code(x) tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}
\end{array}
herbie shell --seed 2024180
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
:alt
(! :herbie-platform default (- (pow x -1/2) (pow (+ x 1) -1/2)))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))