Average Error: 15.3 → 0.3
Time: 1.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.93403941868859091 \cdot 10^{-36} \lor \neg \left(y \le 1.19064852231214522 \cdot 10^{-72}\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.93403941868859091 \cdot 10^{-36} \lor \neg \left(y \le 1.19064852231214522 \cdot 10^{-72}\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 r626673 = x;
        double r626674 = 2.0;
        double r626675 = r626673 * r626674;
        double r626676 = y;
        double r626677 = r626675 * r626676;
        double r626678 = r626673 - r626676;
        double r626679 = r626677 / r626678;
        return r626679;
}

double f(double x, double y) {
        double r626680 = y;
        double r626681 = -1.934039418688591e-36;
        bool r626682 = r626680 <= r626681;
        double r626683 = 1.1906485223121452e-72;
        bool r626684 = r626680 <= r626683;
        double r626685 = !r626684;
        bool r626686 = r626682 || r626685;
        double r626687 = x;
        double r626688 = 2.0;
        double r626689 = r626687 * r626688;
        double r626690 = r626687 - r626680;
        double r626691 = r626690 / r626680;
        double r626692 = r626689 / r626691;
        double r626693 = r626687 / r626690;
        double r626694 = r626680 * r626688;
        double r626695 = r626693 * r626694;
        double r626696 = r626686 ? r626692 : r626695;
        return r626696;
}

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
Herbie0.3
\[\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.934039418688591e-36 or 1.1906485223121452e-72 < y

    1. Initial program 14.4

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

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

    if -1.934039418688591e-36 < y < 1.1906485223121452e-72

    1. Initial program 16.6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.93403941868859091 \cdot 10^{-36} \lor \neg \left(y \le 1.19064852231214522 \cdot 10^{-72}\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 2020060 
(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)))