(FPCore (x eps) :precision binary64 (- x (sqrt (- (* x x) eps))))
(FPCore (x eps) :precision binary64 (/ (- eps) (- (- x) (sqrt (- (* x x) eps)))))
double code(double x, double eps) {
return x - sqrt(((x * x) - eps));
}
double code(double x, double eps) {
return -eps / (-x - sqrt(((x * x) - eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = x - sqrt(((x * x) - eps))
end function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = -eps / (-x - sqrt(((x * x) - eps)))
end function
public static double code(double x, double eps) {
return x - Math.sqrt(((x * x) - eps));
}
public static double code(double x, double eps) {
return -eps / (-x - Math.sqrt(((x * x) - eps)));
}
def code(x, eps): return x - math.sqrt(((x * x) - eps))
def code(x, eps): return -eps / (-x - math.sqrt(((x * x) - eps)))
function code(x, eps) return Float64(x - sqrt(Float64(Float64(x * x) - eps))) end
function code(x, eps) return Float64(Float64(-eps) / Float64(Float64(-x) - sqrt(Float64(Float64(x * x) - eps)))) end
function tmp = code(x, eps) tmp = x - sqrt(((x * x) - eps)); end
function tmp = code(x, eps) tmp = -eps / (-x - sqrt(((x * x) - eps))); end
code[x_, eps_] := N[(x - N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, eps_] := N[((-eps) / N[((-x) - N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x - \sqrt{x \cdot x - \varepsilon}
\frac{-\varepsilon}{\left(-x\right) - \sqrt{x \cdot x - \varepsilon}}




Bits error versus x




Bits error versus eps
Results
| Original | 24.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
Initial program 24.6
Applied egg-rr0.3
Applied egg-rr0.3
Final simplification0.3
herbie shell --seed 2022153
(FPCore (x eps)
:name "ENA, Section 1.4, Exercise 4d"
:precision binary64
:pre (and (and (<= 0.0 x) (<= x 1000000000.0)) (and (<= -1.0 eps) (<= eps 1.0)))
:herbie-target
(/ eps (+ x (sqrt (- (* x x) eps))))
(- x (sqrt (- (* x x) eps))))