Average Error: 15.5 → 0.0
Time: 10.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3416824020916.59033203125 \lor \neg \left(x \le 568.3518365384376238580443896353244781494\right):\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{x \cdot x + 1}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -3416824020916.59033203125 \lor \neg \left(x \le 568.3518365384376238580443896353244781494\right):\\
\;\;\;\;\left(\frac{1}{x} - \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{x \cdot x + 1}\\

\end{array}
double f(double x) {
        double r49730 = x;
        double r49731 = r49730 * r49730;
        double r49732 = 1.0;
        double r49733 = r49731 + r49732;
        double r49734 = r49730 / r49733;
        return r49734;
}

double f(double x) {
        double r49735 = x;
        double r49736 = -3416824020916.5903;
        bool r49737 = r49735 <= r49736;
        double r49738 = 568.3518365384376;
        bool r49739 = r49735 <= r49738;
        double r49740 = !r49739;
        bool r49741 = r49737 || r49740;
        double r49742 = 1.0;
        double r49743 = r49742 / r49735;
        double r49744 = 1.0;
        double r49745 = 3.0;
        double r49746 = pow(r49735, r49745);
        double r49747 = r49744 / r49746;
        double r49748 = r49743 - r49747;
        double r49749 = 5.0;
        double r49750 = pow(r49735, r49749);
        double r49751 = r49744 / r49750;
        double r49752 = r49748 + r49751;
        double r49753 = r49735 * r49735;
        double r49754 = r49753 + r49744;
        double r49755 = r49742 / r49754;
        double r49756 = r49735 * r49755;
        double r49757 = r49741 ? r49752 : r49756;
        return r49757;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -3416824020916.5903 or 568.3518365384376 < x

    1. Initial program 31.4

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv31.5

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
    4. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{{x}^{5}} + \frac{1}{x}\right) - 1 \cdot \frac{1}{{x}^{3}}}\]
    5. Simplified0.0

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

    if -3416824020916.5903 < x < 568.3518365384376

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv0.0

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3416824020916.59033203125 \lor \neg \left(x \le 568.3518365384376238580443896353244781494\right):\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

  (/ x (+ (* x x) 1)))