Average Error: 21.8 → 0.2
Time: 14.0s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -129982374.7612293064594268798828125 \lor \neg \left(y \le 341613825.027258396148681640625\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 -129982374.7612293064594268798828125 \lor \neg \left(y \le 341613825.027258396148681640625\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 r625429 = 1.0;
        double r625430 = x;
        double r625431 = r625429 - r625430;
        double r625432 = y;
        double r625433 = r625431 * r625432;
        double r625434 = r625432 + r625429;
        double r625435 = r625433 / r625434;
        double r625436 = r625429 - r625435;
        return r625436;
}

double f(double x, double y) {
        double r625437 = y;
        double r625438 = -129982374.7612293;
        bool r625439 = r625437 <= r625438;
        double r625440 = 341613825.0272584;
        bool r625441 = r625437 <= r625440;
        double r625442 = !r625441;
        bool r625443 = r625439 || r625442;
        double r625444 = 1.0;
        double r625445 = 1.0;
        double r625446 = r625445 / r625437;
        double r625447 = x;
        double r625448 = r625447 / r625437;
        double r625449 = r625446 - r625448;
        double r625450 = r625444 * r625449;
        double r625451 = r625450 + r625447;
        double r625452 = r625444 - r625447;
        double r625453 = r625452 * r625437;
        double r625454 = r625437 + r625444;
        double r625455 = r625445 / r625454;
        double r625456 = r625453 * r625455;
        double r625457 = r625444 - r625456;
        double r625458 = r625443 ? r625451 : r625457;
        return r625458;
}

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.8
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 < -129982374.7612293 or 341613825.0272584 < y

    1. Initial program 45.1

      \[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}{1 \cdot \left(\frac{1}{y} - \frac{x}{y}\right) + x}\]

    if -129982374.7612293 < y < 341613825.0272584

    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 -129982374.7612293064594268798828125 \lor \neg \left(y \le 341613825.027258396148681640625\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 2019291 
(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))))