Average Error: 15.0 → 0.2
Time: 10.1s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -3473982491094751895355392:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;y \le 1.595212172464986205719205231531851770116 \cdot 10^{-42}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -3473982491094751895355392:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\mathbf{elif}\;y \le 1.595212172464986205719205231531851770116 \cdot 10^{-42}:\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\end{array}
double f(double x, double y) {
        double r26394786 = x;
        double r26394787 = 2.0;
        double r26394788 = r26394786 * r26394787;
        double r26394789 = y;
        double r26394790 = r26394788 * r26394789;
        double r26394791 = r26394786 - r26394789;
        double r26394792 = r26394790 / r26394791;
        return r26394792;
}

double f(double x, double y) {
        double r26394793 = y;
        double r26394794 = -3.473982491094752e+24;
        bool r26394795 = r26394793 <= r26394794;
        double r26394796 = x;
        double r26394797 = 2.0;
        double r26394798 = r26394796 * r26394797;
        double r26394799 = r26394796 - r26394793;
        double r26394800 = r26394799 / r26394793;
        double r26394801 = r26394798 / r26394800;
        double r26394802 = 1.5952121724649862e-42;
        bool r26394803 = r26394793 <= r26394802;
        double r26394804 = r26394798 / r26394799;
        double r26394805 = r26394804 * r26394793;
        double r26394806 = r26394803 ? r26394805 : r26394801;
        double r26394807 = r26394795 ? r26394801 : r26394806;
        return r26394807;
}

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.0
Target0.3
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt -1.721044263414944729490876394165887012892 \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 < -3.473982491094752e+24 or 1.5952121724649862e-42 < y

    1. Initial program 15.6

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

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

    if -3.473982491094752e+24 < y < 1.5952121724649862e-42

    1. Initial program 14.4

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3473982491094751895355392:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;y \le 1.595212172464986205719205231531851770116 \cdot 10^{-42}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))