Average Error: 22.0 → 0.2
Time: 12.6s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -207134368.8996343314647674560546875 \lor \neg \left(y \le 124171319.52169995009899139404296875\right):\\ \;\;\;\;\left(\frac{1}{y} - 1 \cdot \frac{x}{y}\right) + x\\ \mathbf{else}:\\ \;\;\;\;1 - \left(\left(1 - x\right) \cdot y\right) \cdot \frac{1}{y + 1}\\ \end{array}\]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \le -207134368.8996343314647674560546875 \lor \neg \left(y \le 124171319.52169995009899139404296875\right):\\
\;\;\;\;\left(\frac{1}{y} - 1 \cdot \frac{x}{y}\right) + x\\

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

\end{array}
double f(double x, double y) {
        double r561662 = 1.0;
        double r561663 = x;
        double r561664 = r561662 - r561663;
        double r561665 = y;
        double r561666 = r561664 * r561665;
        double r561667 = r561665 + r561662;
        double r561668 = r561666 / r561667;
        double r561669 = r561662 - r561668;
        return r561669;
}

double f(double x, double y) {
        double r561670 = y;
        double r561671 = -207134368.89963433;
        bool r561672 = r561670 <= r561671;
        double r561673 = 124171319.52169995;
        bool r561674 = r561670 <= r561673;
        double r561675 = !r561674;
        bool r561676 = r561672 || r561675;
        double r561677 = 1.0;
        double r561678 = r561677 / r561670;
        double r561679 = x;
        double r561680 = r561679 / r561670;
        double r561681 = r561677 * r561680;
        double r561682 = r561678 - r561681;
        double r561683 = r561682 + r561679;
        double r561684 = r561677 - r561679;
        double r561685 = r561684 * r561670;
        double r561686 = 1.0;
        double r561687 = r561670 + r561677;
        double r561688 = r561686 / r561687;
        double r561689 = r561685 * r561688;
        double r561690 = r561677 - r561689;
        double r561691 = r561676 ? r561683 : r561690;
        return r561691;
}

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.0
Target0.3
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 < -207134368.89963433 or 124171319.52169995 < y

    1. Initial program 45.3

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Taylor expanded around inf 0.2

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

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

    if -207134368.89963433 < y < 124171319.52169995

    1. Initial program 0.2

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Using strategy rm
    3. Applied div-inv0.2

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

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

Reproduce

herbie shell --seed 2019212 
(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))))