Average Error: 14.8 → 0.2
Time: 2.1s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -826361.63285378064 \lor \neg \left(y \le 6.83900105870824044 \cdot 10^{-58}\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 -826361.63285378064 \lor \neg \left(y \le 6.83900105870824044 \cdot 10^{-58}\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 r689942 = x;
        double r689943 = 2.0;
        double r689944 = r689942 * r689943;
        double r689945 = y;
        double r689946 = r689944 * r689945;
        double r689947 = r689942 - r689945;
        double r689948 = r689946 / r689947;
        return r689948;
}

double f(double x, double y) {
        double r689949 = y;
        double r689950 = -826361.6328537806;
        bool r689951 = r689949 <= r689950;
        double r689952 = 6.83900105870824e-58;
        bool r689953 = r689949 <= r689952;
        double r689954 = !r689953;
        bool r689955 = r689951 || r689954;
        double r689956 = x;
        double r689957 = 2.0;
        double r689958 = r689956 * r689957;
        double r689959 = r689956 - r689949;
        double r689960 = r689959 / r689949;
        double r689961 = r689958 / r689960;
        double r689962 = r689956 / r689959;
        double r689963 = r689949 * r689957;
        double r689964 = r689962 * r689963;
        double r689965 = r689955 ? r689961 : r689964;
        return r689965;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.8
Target0.3
Herbie0.2
\[\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 < -826361.6328537806 or 6.83900105870824e-58 < y

    1. Initial program 14.9

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

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

    if -826361.6328537806 < y < 6.83900105870824e-58

    1. Initial program 14.7

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

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

      \[\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.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -826361.63285378064 \lor \neg \left(y \le 6.83900105870824044 \cdot 10^{-58}\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 2020035 
(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)))