Average Error: 22.3 → 0.2
Time: 19.4s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4201198044259844344621563904 \lor \neg \left(y \le 528433753610563.25\right):\\ \;\;\;\;\left(x + \frac{1}{y}\right) - 1 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{\left(1 - x\right) \cdot {y}^{3}}{{y}^{3} + {1}^{3}}\right) - \left(\left(1 - x\right) \cdot \frac{y}{{y}^{3} + {1}^{3}}\right) \cdot \left(1 \cdot 1 - y \cdot 1\right)\\ \end{array}\]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \le -4201198044259844344621563904 \lor \neg \left(y \le 528433753610563.25\right):\\
\;\;\;\;\left(x + \frac{1}{y}\right) - 1 \cdot \frac{x}{y}\\

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

\end{array}
double f(double x, double y) {
        double r561979 = 1.0;
        double r561980 = x;
        double r561981 = r561979 - r561980;
        double r561982 = y;
        double r561983 = r561981 * r561982;
        double r561984 = r561982 + r561979;
        double r561985 = r561983 / r561984;
        double r561986 = r561979 - r561985;
        return r561986;
}

double f(double x, double y) {
        double r561987 = y;
        double r561988 = -4.2011980442598443e+27;
        bool r561989 = r561987 <= r561988;
        double r561990 = 528433753610563.25;
        bool r561991 = r561987 <= r561990;
        double r561992 = !r561991;
        bool r561993 = r561989 || r561992;
        double r561994 = x;
        double r561995 = 1.0;
        double r561996 = r561995 / r561987;
        double r561997 = r561994 + r561996;
        double r561998 = r561994 / r561987;
        double r561999 = r561995 * r561998;
        double r562000 = r561997 - r561999;
        double r562001 = r561995 - r561994;
        double r562002 = 3.0;
        double r562003 = pow(r561987, r562002);
        double r562004 = r562001 * r562003;
        double r562005 = pow(r561995, r562002);
        double r562006 = r562003 + r562005;
        double r562007 = r562004 / r562006;
        double r562008 = r561995 - r562007;
        double r562009 = r561987 / r562006;
        double r562010 = r562001 * r562009;
        double r562011 = r561995 * r561995;
        double r562012 = r561987 * r561995;
        double r562013 = r562011 - r562012;
        double r562014 = r562010 * r562013;
        double r562015 = r562008 - r562014;
        double r562016 = r561993 ? r562000 : r562015;
        return r562016;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original22.3
Target0.2
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.848278829724677052581682801246643066:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891002655029296875:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -4.2011980442598443e+27 or 528433753610563.25 < y

    1. Initial program 46.8

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity46.8

      \[\leadsto 1 - \frac{\left(1 - x\right) \cdot y}{\color{blue}{1 \cdot \left(y + 1\right)}}\]
    4. Applied times-frac29.8

      \[\leadsto 1 - \color{blue}{\frac{1 - x}{1} \cdot \frac{y}{y + 1}}\]
    5. Simplified29.8

      \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \cdot \frac{y}{y + 1}\]
    6. Using strategy rm
    7. Applied flip3-+53.6

      \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{\frac{{y}^{3} + {1}^{3}}{y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)}}}\]
    8. Applied associate-/r/53.6

      \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(\frac{y}{{y}^{3} + {1}^{3}} \cdot \left(y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)\right)\right)}\]
    9. Applied associate-*r*53.6

      \[\leadsto 1 - \color{blue}{\left(\left(1 - x\right) \cdot \frac{y}{{y}^{3} + {1}^{3}}\right) \cdot \left(y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)\right)}\]
    10. Taylor expanded around inf 0.0

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

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

    if -4.2011980442598443e+27 < y < 528433753610563.25

    1. Initial program 1.1

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.1

      \[\leadsto 1 - \frac{\left(1 - x\right) \cdot y}{\color{blue}{1 \cdot \left(y + 1\right)}}\]
    4. Applied times-frac1.0

      \[\leadsto 1 - \color{blue}{\frac{1 - x}{1} \cdot \frac{y}{y + 1}}\]
    5. Simplified1.0

      \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \cdot \frac{y}{y + 1}\]
    6. Using strategy rm
    7. Applied flip3-+1.1

      \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{\frac{{y}^{3} + {1}^{3}}{y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)}}}\]
    8. Applied associate-/r/1.1

      \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(\frac{y}{{y}^{3} + {1}^{3}} \cdot \left(y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)\right)\right)}\]
    9. Applied associate-*r*1.1

      \[\leadsto 1 - \color{blue}{\left(\left(1 - x\right) \cdot \frac{y}{{y}^{3} + {1}^{3}}\right) \cdot \left(y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)\right)}\]
    10. Using strategy rm
    11. Applied distribute-lft-in1.1

      \[\leadsto 1 - \color{blue}{\left(\left(\left(1 - x\right) \cdot \frac{y}{{y}^{3} + {1}^{3}}\right) \cdot \left(y \cdot y\right) + \left(\left(1 - x\right) \cdot \frac{y}{{y}^{3} + {1}^{3}}\right) \cdot \left(1 \cdot 1 - y \cdot 1\right)\right)}\]
    12. Applied associate--r+0.5

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

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

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

Reproduce

herbie shell --seed 2019303 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (if (< y -3693.84827882972468) (- (/ 1 y) (- (/ x y) x)) (if (< y 6799310503.41891003) (- 1 (/ (* (- 1 x) y) (+ y 1))) (- (/ 1 y) (- (/ x y) x))))

  (- 1 (/ (* (- 1 x) y) (+ y 1))))