(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x) :precision binary64 (/ (- (pow x -0.5)) (* (/ (+ (pow x -0.5) (pow (+ x 1.0) -0.5)) (pow x -0.5)) (- -1.0 x))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
return -pow(x, -0.5) / (((pow(x, -0.5) + pow((x + 1.0), -0.5)) / pow(x, -0.5)) * (-1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = -(x ** (-0.5d0)) / ((((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0))) / (x ** (-0.5d0))) * ((-1.0d0) - x))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
public static double code(double x) {
return -Math.pow(x, -0.5) / (((Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5)) / Math.pow(x, -0.5)) * (-1.0 - x));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x): return -math.pow(x, -0.5) / (((math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)) / math.pow(x, -0.5)) * (-1.0 - x))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function code(x) return Float64(Float64(-(x ^ -0.5)) / Float64(Float64(Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5)) / (x ^ -0.5)) * Float64(-1.0 - x))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
function tmp = code(x) tmp = -(x ^ -0.5) / ((((x ^ -0.5) + ((x + 1.0) ^ -0.5)) / (x ^ -0.5)) * (-1.0 - x)); 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]
code[x_] := N[((-N[Power[x, -0.5], $MachinePrecision]) / N[(N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{-{x}^{-0.5}}{\frac{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}{{x}^{-0.5}} \cdot \left(-1 - x\right)}




Bits error versus x
Results
| Original | 20.1 |
|---|---|
| Target | 0.6 |
| Herbie | 0.1 |
Initial program 20.1
Applied egg-rr20.2
Applied egg-rr5.1
Applied egg-rr0.1
Applied egg-rr0.1
Final simplification0.1
herbie shell --seed 2022150
(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)))))