Average Error: 14.7 → 0.1
Time: 3.6min
Precision: binary64
Cost: 448
\[\frac{x}{x \cdot x + 1}\]
\[\frac{1}{x - \frac{-1}{x}}\]
\frac{x}{x \cdot x + 1}
\frac{1}{x - \frac{-1}{x}}
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
(FPCore (x) :precision binary64 (/ 1.0 (- x (/ -1.0 x))))
double code(double x) {
	return x / ((x * x) + 1.0);
}
double code(double x) {
	return 1.0 / (x - (-1.0 / 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 -1.01136998843019 \lor \neg \left(x \leq 0.9962994643615916\right):\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 2
Error31.3
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_213514.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_212414.7

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

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

    \[\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 add-sqr-sqrt_binary64_21460.1

    \[\leadsto \frac{-\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{-1}{x} - x}\]
  12. Applied distribute-rgt-neg-in_binary64_20820.1

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

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

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

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

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

Reproduce

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

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

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