Average Error: 15.0 → 0.0
Time: 15.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1753.7015445183354:\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)\\ \mathbf{elif}\;x \le 1007.4541128350563:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -1753.7015445183354:\\
\;\;\;\;\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)\\

\mathbf{elif}\;x \le 1007.4541128350563:\\
\;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)\\

\end{array}
double f(double x) {
        double r1995284 = x;
        double r1995285 = r1995284 * r1995284;
        double r1995286 = 1.0;
        double r1995287 = r1995285 + r1995286;
        double r1995288 = r1995284 / r1995287;
        return r1995288;
}

double f(double x) {
        double r1995289 = x;
        double r1995290 = -1753.7015445183354;
        bool r1995291 = r1995289 <= r1995290;
        double r1995292 = 1.0;
        double r1995293 = r1995292 / r1995289;
        double r1995294 = r1995289 * r1995289;
        double r1995295 = r1995294 * r1995289;
        double r1995296 = r1995292 / r1995295;
        double r1995297 = r1995294 * r1995294;
        double r1995298 = r1995292 / r1995297;
        double r1995299 = r1995298 / r1995289;
        double r1995300 = r1995296 - r1995299;
        double r1995301 = r1995293 - r1995300;
        double r1995302 = 1007.4541128350563;
        bool r1995303 = r1995289 <= r1995302;
        double r1995304 = r1995294 - r1995292;
        double r1995305 = -1.0;
        double r1995306 = r1995305 + r1995297;
        double r1995307 = r1995289 / r1995306;
        double r1995308 = r1995304 * r1995307;
        double r1995309 = r1995303 ? r1995308 : r1995301;
        double r1995310 = r1995291 ? r1995301 : r1995309;
        return r1995310;
}

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.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1753.7015445183354 or 1007.4541128350563 < x

    1. Initial program 30.4

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)}\]

    if -1753.7015445183354 < x < 1007.4541128350563

    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}}\]
    4. Using strategy rm
    5. Applied flip-+0.0

      \[\leadsto x \cdot \frac{1}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    6. Applied associate-/r/0.0

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)\right)}\]
    7. Applied associate-*r*0.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1753.7015445183354:\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)\\ \mathbf{elif}\;x \le 1007.4541128350563:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{\left(x \cdot x\right) \cdot x} - \frac{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x}\right)\\ \end{array}\]

Reproduce

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

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

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