Average Error: 14.9 → 1.1
Time: 32.7s
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 -2.148830163480626119193023708058808164846 \cdot 10^{-23}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -8.174877329539413749230582362665895049321 \cdot 10^{-304}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.016863972527170217327846549438020488946 \cdot 10^{-127}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \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 -2.148830163480626119193023708058808164846 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -8.174877329539413749230582362665895049321 \cdot 10^{-304}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

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

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.016863972527170217327846549438020488946 \cdot 10^{-127}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r27275481 = x;
        double r27275482 = 2.0;
        double r27275483 = r27275481 * r27275482;
        double r27275484 = y;
        double r27275485 = r27275483 * r27275484;
        double r27275486 = r27275481 - r27275484;
        double r27275487 = r27275485 / r27275486;
        return r27275487;
}

double f(double x, double y) {
        double r27275488 = x;
        double r27275489 = 2.0;
        double r27275490 = r27275488 * r27275489;
        double r27275491 = y;
        double r27275492 = r27275490 * r27275491;
        double r27275493 = r27275488 - r27275491;
        double r27275494 = r27275492 / r27275493;
        double r27275495 = -2.148830163480626e-23;
        bool r27275496 = r27275494 <= r27275495;
        double r27275497 = r27275491 / r27275493;
        double r27275498 = r27275489 * r27275497;
        double r27275499 = r27275488 * r27275498;
        double r27275500 = -8.174877329539414e-304;
        bool r27275501 = r27275494 <= r27275500;
        double r27275502 = 0.0;
        bool r27275503 = r27275494 <= r27275502;
        double r27275504 = r27275493 / r27275491;
        double r27275505 = r27275490 / r27275504;
        double r27275506 = 3.0168639725271702e-127;
        bool r27275507 = r27275494 <= r27275506;
        double r27275508 = r27275507 ? r27275494 : r27275499;
        double r27275509 = r27275503 ? r27275505 : r27275508;
        double r27275510 = r27275501 ? r27275494 : r27275509;
        double r27275511 = r27275496 ? r27275499 : r27275510;
        return r27275511;
}

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.9
Target0.4
Herbie1.1
\[\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 3 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -2.148830163480626e-23 or 3.0168639725271702e-127 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 20.7

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity20.7

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right)} \cdot \frac{y}{x - y}\]
    6. Using strategy rm
    7. Applied associate-*l*1.5

      \[\leadsto \color{blue}{x \cdot \left(2 \cdot \frac{y}{x - y}\right)}\]

    if -2.148830163480626e-23 < (/ (* (* x 2.0) y) (- x y)) < -8.174877329539414e-304 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 3.0168639725271702e-127

    1. Initial program 0.8

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]

    if -8.174877329539414e-304 < (/ (* (* x 2.0) y) (- x y)) < 0.0

    1. Initial program 56.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.148830163480626119193023708058808164846 \cdot 10^{-23}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -8.174877329539413749230582362665895049321 \cdot 10^{-304}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.016863972527170217327846549438020488946 \cdot 10^{-127}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \end{array}\]

Reproduce

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