Average Error: 14.7 → 0.1
Time: 2.0min
Precision: binary64
Cost: 448
\[\frac{x}{x \cdot x + 1}\]
\[\frac{-1}{\frac{-1}{x} - x}\]
\frac{x}{x \cdot x + 1}
\frac{-1}{\frac{-1}{x} - x}
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
(FPCore (x) :precision binary64 (/ -1.0 (- (/ -1.0 x) x)))
double code(double x) {
	return x / ((x * x) + 1.0);
}
double code(double x) {
	return -1.0 / ((-1.0 / x) - x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.7
Target0.1
Herbie0.1
\[\frac{1}{x + \frac{1}{x}}\]

Alternatives

Alternative 1
Error0.6
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -0.9963031824001185 \lor \neg \left(x \leq 1.0239732575115408\right):\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 2
Error31.0
Cost64
\[x\]

Error

Time

Derivation

  1. Initial program 14.7

    \[\frac{x}{x \cdot x + 1}\]
  2. Using strategy rm
  3. Applied frac-2neg_binary64_145314.7

    \[\leadsto \color{blue}{\frac{-x}{-\left(x \cdot x + 1\right)}}\]
  4. Simplified14.7

    \[\leadsto \frac{-x}{\color{blue}{-1 - x \cdot x}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity_binary64_144214.7

    \[\leadsto \frac{-\color{blue}{1 \cdot x}}{-1 - x \cdot x}\]
  7. Applied distribute-lft-neg-in_binary64_139914.7

    \[\leadsto \frac{\color{blue}{\left(-1\right) \cdot x}}{-1 - x \cdot x}\]
  8. Applied associate-/l*_binary64_138714.8

    \[\leadsto \color{blue}{\frac{-1}{\frac{-1 - x \cdot x}{x}}}\]
  9. Simplified0.1

    \[\leadsto \frac{-1}{\color{blue}{\frac{-1}{x} - x}}\]
  10. Using strategy rm
  11. Applied distribute-frac-neg_binary64_14050.1

    \[\leadsto \color{blue}{-\frac{1}{\frac{-1}{x} - x}}\]
  12. Simplified0.1

    \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{x} - x}}\]
  13. Final simplification0.1

    \[\leadsto \frac{-1}{\frac{-1}{x} - x}\]

Reproduce

herbie shell --seed 2021045 
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ x (/ 1.0 x)))

  (/ x (+ (* x x) 1.0)))