Average Error: 15.5 → 0.4
Time: 1.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.1116518480520122 \cdot 10^{66} \lor \neg \left(y \le 3.6268085031482395 \cdot 10^{-63}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - y} \cdot \left(y \cdot 2\right)\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -1.1116518480520122 \cdot 10^{66} \lor \neg \left(y \le 3.6268085031482395 \cdot 10^{-63}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r533640 = x;
        double r533641 = 2.0;
        double r533642 = r533640 * r533641;
        double r533643 = y;
        double r533644 = r533642 * r533643;
        double r533645 = r533640 - r533643;
        double r533646 = r533644 / r533645;
        return r533646;
}

double f(double x, double y) {
        double r533647 = y;
        double r533648 = -1.1116518480520122e+66;
        bool r533649 = r533647 <= r533648;
        double r533650 = 3.6268085031482395e-63;
        bool r533651 = r533647 <= r533650;
        double r533652 = !r533651;
        bool r533653 = r533649 || r533652;
        double r533654 = x;
        double r533655 = 2.0;
        double r533656 = r533654 * r533655;
        double r533657 = r533654 - r533647;
        double r533658 = r533657 / r533647;
        double r533659 = r533656 / r533658;
        double r533660 = r533654 / r533657;
        double r533661 = r533647 * r533655;
        double r533662 = r533660 * r533661;
        double r533663 = r533653 ? r533659 : r533662;
        return r533663;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.5
Target0.4
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{81}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 83645045635564432:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.1116518480520122e+66 or 3.6268085031482395e-63 < y

    1. Initial program 16.5

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l*0.5

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]

    if -1.1116518480520122e+66 < y < 3.6268085031482395e-63

    1. Initial program 14.4

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l*14.8

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied div-inv14.9

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

      \[\leadsto \color{blue}{\frac{x}{x - y} \cdot \frac{2}{\frac{1}{y}}}\]
    7. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.1116518480520122 \cdot 10^{66} \lor \neg \left(y \le 3.6268085031482395 \cdot 10^{-63}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - y} \cdot \left(y \cdot 2\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020083 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))