Average Error: 14.3 → 0.0
Time: 5.7s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.450745238348297 \cdot 10^{+24}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \mathbf{elif}\;x \le 665.7378871081933:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -7.450745238348297 \cdot 10^{+24}:\\
\;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\

\mathbf{elif}\;x \le 665.7378871081933:\\
\;\;\;\;\frac{x}{1 + x \cdot x}\\

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

\end{array}
double f(double x) {
        double r1976423 = x;
        double r1976424 = r1976423 * r1976423;
        double r1976425 = 1.0;
        double r1976426 = r1976424 + r1976425;
        double r1976427 = r1976423 / r1976426;
        return r1976427;
}

double f(double x) {
        double r1976428 = x;
        double r1976429 = -7.450745238348297e+24;
        bool r1976430 = r1976428 <= r1976429;
        double r1976431 = 1.0;
        double r1976432 = r1976431 / r1976428;
        double r1976433 = r1976428 * r1976428;
        double r1976434 = r1976433 * r1976428;
        double r1976435 = r1976431 / r1976434;
        double r1976436 = r1976432 - r1976435;
        double r1976437 = 5.0;
        double r1976438 = pow(r1976428, r1976437);
        double r1976439 = r1976431 / r1976438;
        double r1976440 = r1976436 + r1976439;
        double r1976441 = 665.7378871081933;
        bool r1976442 = r1976428 <= r1976441;
        double r1976443 = r1976431 + r1976433;
        double r1976444 = r1976428 / r1976443;
        double r1976445 = r1976442 ? r1976444 : r1976440;
        double r1976446 = r1976430 ? r1976440 : r1976445;
        return r1976446;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -7.450745238348297e+24 or 665.7378871081933 < x

    1. Initial program 30.7

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around inf 0.0

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

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

    if -7.450745238348297e+24 < x < 665.7378871081933

    1. Initial program 0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.450745238348297 \cdot 10^{+24}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \mathbf{elif}\;x \le 665.7378871081933:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]

Reproduce

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

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

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