Average Error: 21.9 → 0.3
Time: 3.7s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -7583054551493676 \lor \neg \left(y \le 227113532.892336339\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{y} - \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 -7583054551493676 \lor \neg \left(y \le 227113532.892336339\right):\\
\;\;\;\;1 \cdot \left(\frac{1}{y} - \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 r631786 = 1.0;
        double r631787 = x;
        double r631788 = r631786 - r631787;
        double r631789 = y;
        double r631790 = r631788 * r631789;
        double r631791 = r631789 + r631786;
        double r631792 = r631790 / r631791;
        double r631793 = r631786 - r631792;
        return r631793;
}

double f(double x, double y) {
        double r631794 = y;
        double r631795 = -7583054551493676.0;
        bool r631796 = r631794 <= r631795;
        double r631797 = 227113532.89233634;
        bool r631798 = r631794 <= r631797;
        double r631799 = !r631798;
        bool r631800 = r631796 || r631799;
        double r631801 = 1.0;
        double r631802 = 1.0;
        double r631803 = r631802 / r631794;
        double r631804 = x;
        double r631805 = r631804 / r631794;
        double r631806 = r631803 - r631805;
        double r631807 = r631801 * r631806;
        double r631808 = r631807 + r631804;
        double r631809 = r631801 - r631804;
        double r631810 = r631809 * r631794;
        double r631811 = r631794 + r631801;
        double r631812 = r631802 / r631811;
        double r631813 = r631810 * r631812;
        double r631814 = r631801 - r631813;
        double r631815 = r631800 ? r631808 : r631814;
        return r631815;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original21.9
Target0.3
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.84827882972468:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891003:\\ \;\;\;\;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 < -7583054551493676.0 or 227113532.89233634 < y

    1. Initial program 45.6

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

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

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

    if -7583054551493676.0 < y < 227113532.89233634

    1. Initial program 0.4

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

      \[\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.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -7583054551493676 \lor \neg \left(y \le 227113532.892336339\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{y} - \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 2020064 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
  :precision binary64

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

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