Average Error: 15.1 → 0.9
Time: 2.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} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.4108510848905031 \cdot 10^{-307} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 7.98976594251477736 \cdot 10^{-110}\right)\right)\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \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} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.4108510848905031 \cdot 10^{-307} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 7.98976594251477736 \cdot 10^{-110}\right)\right)\right):\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r429171 = x;
        double r429172 = 2.0;
        double r429173 = r429171 * r429172;
        double r429174 = y;
        double r429175 = r429173 * r429174;
        double r429176 = r429171 - r429174;
        double r429177 = r429175 / r429176;
        return r429177;
}

double f(double x, double y) {
        double r429178 = x;
        double r429179 = 2.0;
        double r429180 = r429178 * r429179;
        double r429181 = y;
        double r429182 = r429180 * r429181;
        double r429183 = r429178 - r429181;
        double r429184 = r429182 / r429183;
        double r429185 = -inf.0;
        bool r429186 = r429184 <= r429185;
        double r429187 = -1.410851084890503e-307;
        bool r429188 = r429184 <= r429187;
        double r429189 = -0.0;
        bool r429190 = r429184 <= r429189;
        double r429191 = 7.989765942514777e-110;
        bool r429192 = r429184 <= r429191;
        double r429193 = !r429192;
        bool r429194 = r429190 || r429193;
        double r429195 = !r429194;
        bool r429196 = r429188 || r429195;
        double r429197 = !r429196;
        bool r429198 = r429186 || r429197;
        double r429199 = r429181 / r429183;
        double r429200 = r429180 * r429199;
        double r429201 = r429198 ? r429200 : r429184;
        return r429201;
}

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.1
Target0.4
Herbie0.9
\[\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 (/ (* (* x 2.0) y) (- x y)) < -inf.0 or -1.410851084890503e-307 < (/ (* (* x 2.0) y) (- x y)) < -0.0 or 7.989765942514777e-110 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 35.8

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

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

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

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

    if -inf.0 < (/ (* (* x 2.0) y) (- x y)) < -1.410851084890503e-307 or -0.0 < (/ (* (* x 2.0) y) (- x y)) < 7.989765942514777e-110

    1. Initial program 0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.4108510848905031 \cdot 10^{-307} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 7.98976594251477736 \cdot 10^{-110}\right)\right)\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

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