Average Error: 15.3 → 1.7
Time: 7.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -69604390459434.2578125 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -6.059189969388941925252077985376441306569 \cdot 10^{-279} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 2.712693619237536218171867186771954088351 \cdot 10^{-123}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -69604390459434.2578125 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -6.059189969388941925252077985376441306569 \cdot 10^{-279} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 2.712693619237536218171867186771954088351 \cdot 10^{-123}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\

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

\end{array}
double f(double x, double y) {
        double r579925 = x;
        double r579926 = 2.0;
        double r579927 = r579925 * r579926;
        double r579928 = y;
        double r579929 = r579927 * r579928;
        double r579930 = r579925 - r579928;
        double r579931 = r579929 / r579930;
        return r579931;
}

double f(double x, double y) {
        double r579932 = x;
        double r579933 = 2.0;
        double r579934 = r579932 * r579933;
        double r579935 = y;
        double r579936 = r579934 * r579935;
        double r579937 = r579932 - r579935;
        double r579938 = r579936 / r579937;
        double r579939 = -69604390459434.26;
        bool r579940 = r579938 <= r579939;
        double r579941 = -6.059189969388942e-279;
        bool r579942 = r579938 <= r579941;
        double r579943 = 0.0;
        bool r579944 = r579938 <= r579943;
        double r579945 = !r579944;
        double r579946 = 2.7126936192375362e-123;
        bool r579947 = r579938 <= r579946;
        bool r579948 = r579945 && r579947;
        bool r579949 = r579942 || r579948;
        double r579950 = !r579949;
        bool r579951 = r579940 || r579950;
        double r579952 = r579932 / r579935;
        double r579953 = 1.0;
        double r579954 = r579952 - r579953;
        double r579955 = r579934 / r579954;
        double r579956 = r579951 ? r579955 : r579938;
        return r579956;
}

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.3
Target0.3
Herbie1.7
\[\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 (/ (* (* x 2.0) y) (- x y)) < -69604390459434.26 or -6.059189969388942e-279 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 2.7126936192375362e-123 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 25.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Simplified3.0

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

    if -69604390459434.26 < (/ (* (* x 2.0) y) (- x y)) < -6.059189969388942e-279 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 2.7126936192375362e-123

    1. Initial program 7.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -69604390459434.2578125 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -6.059189969388941925252077985376441306569 \cdot 10^{-279} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 2.712693619237536218171867186771954088351 \cdot 10^{-123}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

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