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




Bits error versus x
Results
| Original | 15.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 15.0
Simplified15.0
Applied egg-rr15.1
Taylor expanded in x around 0 0.1
Final simplification0.1
herbie shell --seed 2022160
(FPCore (x)
:name "x / (x^2 + 1)"
:precision binary64
:herbie-target
(/ 1.0 (+ x (/ 1.0 x)))
(/ x (+ (* x x) 1.0)))