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

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

\end{array}
double f(double x, double y) {
        double r594436 = 1.0;
        double r594437 = x;
        double r594438 = r594436 - r594437;
        double r594439 = y;
        double r594440 = r594438 * r594439;
        double r594441 = r594439 + r594436;
        double r594442 = r594440 / r594441;
        double r594443 = r594436 - r594442;
        return r594443;
}

double f(double x, double y) {
        double r594444 = y;
        double r594445 = -100161581.36651158;
        bool r594446 = r594444 <= r594445;
        double r594447 = 279165547.0253698;
        bool r594448 = r594444 <= r594447;
        double r594449 = !r594448;
        bool r594450 = r594446 || r594449;
        double r594451 = x;
        double r594452 = 1.0;
        double r594453 = r594452 / r594444;
        double r594454 = r594452 * r594451;
        double r594455 = r594454 / r594444;
        double r594456 = r594453 - r594455;
        double r594457 = r594451 + r594456;
        double r594458 = r594452 - r594451;
        double r594459 = 1.0;
        double r594460 = r594452 + r594444;
        double r594461 = r594459 / r594460;
        double r594462 = r594461 * r594444;
        double r594463 = r594458 * r594462;
        double r594464 = r594452 - r594463;
        double r594465 = r594450 ? r594457 : r594464;
        return r594465;
}

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.9
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 < -100161581.36651158 or 279165547.0253698 < y

    1. Initial program 46.0

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Simplified29.6

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}}\]
    3. Using strategy rm
    4. Applied div-inv29.7

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

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

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

    if -100161581.36651158 < y < 279165547.0253698

    1. Initial program 0.2

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

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

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

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

Reproduce

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