Average Error: 15.0 → 0.1
Time: 1.1s
Precision: binary64
\[\frac{x}{x \cdot x + 1} \]
\[{\left(x + \frac{1}{x}\right)}^{-1} \]
(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}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.0
Target0.1
Herbie0.1
\[\frac{1}{x + \frac{1}{x}} \]

Derivation

  1. Initial program 15.0

    \[\frac{x}{x \cdot x + 1} \]
  2. Simplified15.0

    \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(x, x, 1\right)}} \]
  3. Applied egg-rr15.1

    \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(x, x, 1\right)}{x}\right)}^{-1}} \]
  4. Taylor expanded in x around 0 0.1

    \[\leadsto {\color{blue}{\left(\frac{1}{x} + x\right)}}^{-1} \]
  5. Final simplification0.1

    \[\leadsto {\left(x + \frac{1}{x}\right)}^{-1} \]

Reproduce

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)))