Average Error: 14.6 → 0.6
Time: 33.8s
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 -62785949538196690289038937030656:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -5.803368299499310115651714592899503248245 \cdot 10^{-307}:\\ \;\;\;\;\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:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 9.896071544107303447480442631568164014492 \cdot 10^{-42}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \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 -62785949538196690289038937030656:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -5.803368299499310115651714592899503248245 \cdot 10^{-307}:\\
\;\;\;\;\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:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

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

\end{array}
double f(double x, double y) {
        double r367048 = x;
        double r367049 = 2.0;
        double r367050 = r367048 * r367049;
        double r367051 = y;
        double r367052 = r367050 * r367051;
        double r367053 = r367048 - r367051;
        double r367054 = r367052 / r367053;
        return r367054;
}

double f(double x, double y) {
        double r367055 = x;
        double r367056 = 2.0;
        double r367057 = r367055 * r367056;
        double r367058 = y;
        double r367059 = r367057 * r367058;
        double r367060 = r367055 - r367058;
        double r367061 = r367059 / r367060;
        double r367062 = -6.278594953819669e+31;
        bool r367063 = r367061 <= r367062;
        double r367064 = r367055 / r367058;
        double r367065 = 1.0;
        double r367066 = r367064 - r367065;
        double r367067 = r367057 / r367066;
        double r367068 = -5.80336829949931e-307;
        bool r367069 = r367061 <= r367068;
        double r367070 = 0.0;
        bool r367071 = r367061 <= r367070;
        double r367072 = r367058 / r367060;
        double r367073 = r367057 * r367072;
        double r367074 = 9.896071544107303e-42;
        bool r367075 = r367061 <= r367074;
        double r367076 = r367075 ? r367061 : r367067;
        double r367077 = r367071 ? r367073 : r367076;
        double r367078 = r367069 ? r367061 : r367077;
        double r367079 = r367063 ? r367067 : r367078;
        return r367079;
}

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.6
Target0.3
Herbie0.6
\[\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)) < -6.278594953819669e+31 or 9.896071544107303e-42 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 29.9

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

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

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

    if -6.278594953819669e+31 < (/ (* (* x 2.0) y) (- x y)) < -5.80336829949931e-307 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 9.896071544107303e-42

    1. Initial program 5.4

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

    if -5.80336829949931e-307 < (/ (* (* x 2.0) y) (- x y)) < 0.0

    1. Initial program 58.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -62785949538196690289038937030656:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -5.803368299499310115651714592899503248245 \cdot 10^{-307}:\\ \;\;\;\;\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:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 9.896071544107303447480442631568164014492 \cdot 10^{-42}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -1.7210442634149447e81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))