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

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

\end{array}
double f(double x) {
        double r50170 = x;
        double r50171 = r50170 * r50170;
        double r50172 = 1.0;
        double r50173 = r50171 + r50172;
        double r50174 = r50170 / r50173;
        return r50174;
}

double f(double x) {
        double r50175 = x;
        double r50176 = -4056411831943571.5;
        bool r50177 = r50175 <= r50176;
        double r50178 = 412.72204873712656;
        bool r50179 = r50175 <= r50178;
        double r50180 = !r50179;
        bool r50181 = r50177 || r50180;
        double r50182 = 1.0;
        double r50183 = r50182 / r50175;
        double r50184 = 1.0;
        double r50185 = 3.0;
        double r50186 = pow(r50175, r50185);
        double r50187 = r50184 / r50186;
        double r50188 = r50183 - r50187;
        double r50189 = 5.0;
        double r50190 = pow(r50175, r50189);
        double r50191 = r50184 / r50190;
        double r50192 = r50188 + r50191;
        double r50193 = r50175 * r50186;
        double r50194 = r50184 * r50184;
        double r50195 = r50193 - r50194;
        double r50196 = r50175 / r50195;
        double r50197 = r50175 * r50175;
        double r50198 = r50197 - r50184;
        double r50199 = r50196 * r50198;
        double r50200 = r50181 ? r50192 : r50199;
        return r50200;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -4056411831943571.5 or 412.72204873712656 < x

    1. Initial program 31.1

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

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

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

      \[\leadsto \color{blue}{\frac{x}{x \cdot {x}^{3} - 1 \cdot 1}} \cdot \left(x \cdot x - 1\right)\]
    6. 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}}}\]
    7. Simplified0.0

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

    if -4056411831943571.5 < x < 412.72204873712656

    1. Initial program 0.0

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

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

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

      \[\leadsto \color{blue}{\frac{x}{x \cdot {x}^{3} - 1 \cdot 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 -4056411831943571.5 \lor \neg \left(x \le 412.7220487371265562615008093416690826416\right):\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot {x}^{3} - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)\\ \end{array}\]

Reproduce

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

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

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