Average Error: 23.1 → 0.2
Time: 11.3s
Precision: 64
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
\[\begin{array}{l} \mathbf{if}\;y \le -100315004.67027035:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\ \mathbf{elif}\;y \le 159075929.13207832:\\ \;\;\;\;1.0 - \left(1.0 - x\right) \cdot \left(\frac{1}{y + 1.0} \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\ \end{array}\]
1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}
\begin{array}{l}
\mathbf{if}\;y \le -100315004.67027035:\\
\;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\

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

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

\end{array}
double f(double x, double y) {
        double r35602602 = 1.0;
        double r35602603 = x;
        double r35602604 = r35602602 - r35602603;
        double r35602605 = y;
        double r35602606 = r35602604 * r35602605;
        double r35602607 = r35602605 + r35602602;
        double r35602608 = r35602606 / r35602607;
        double r35602609 = r35602602 - r35602608;
        return r35602609;
}

double f(double x, double y) {
        double r35602610 = y;
        double r35602611 = -100315004.67027035;
        bool r35602612 = r35602610 <= r35602611;
        double r35602613 = x;
        double r35602614 = 1.0;
        double r35602615 = r35602614 / r35602610;
        double r35602616 = r35602613 + r35602615;
        double r35602617 = r35602613 / r35602610;
        double r35602618 = r35602617 * r35602614;
        double r35602619 = r35602616 - r35602618;
        double r35602620 = 159075929.13207832;
        bool r35602621 = r35602610 <= r35602620;
        double r35602622 = r35602614 - r35602613;
        double r35602623 = 1.0;
        double r35602624 = r35602610 + r35602614;
        double r35602625 = r35602623 / r35602624;
        double r35602626 = r35602625 * r35602610;
        double r35602627 = r35602622 * r35602626;
        double r35602628 = r35602614 - r35602627;
        double r35602629 = r35602621 ? r35602628 : r35602619;
        double r35602630 = r35602612 ? r35602619 : r35602629;
        return r35602630;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original23.1
Target0.2
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.8482788297247:\\ \;\;\;\;\frac{1.0}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891:\\ \;\;\;\;1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1.0}{y} - \left(\frac{x}{y} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -100315004.67027035 or 159075929.13207832 < y

    1. Initial program 45.7

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

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

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

      \[\leadsto 1.0 - \color{blue}{\left(1.0 - x\right)} \cdot \frac{y}{y + 1.0}\]
    6. Using strategy rm
    7. Applied div-inv30.2

      \[\leadsto 1.0 - \left(1.0 - x\right) \cdot \color{blue}{\left(y \cdot \frac{1}{y + 1.0}\right)}\]
    8. Taylor expanded around inf 0.1

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

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

    if -100315004.67027035 < y < 159075929.13207832

    1. Initial program 0.2

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

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

      \[\leadsto 1.0 - \color{blue}{\frac{1.0 - x}{1} \cdot \frac{y}{y + 1.0}}\]
    5. Simplified0.2

      \[\leadsto 1.0 - \color{blue}{\left(1.0 - x\right)} \cdot \frac{y}{y + 1.0}\]
    6. Using strategy rm
    7. Applied div-inv0.2

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

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

Reproduce

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

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))

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