Average Error: 15.1 → 0.5
Time: 11.0s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.01776738281857308254796379287654417567 \cdot 10^{-5}:\\ \;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\ \mathbf{elif}\;x \le 3.62378838658747611836253077264636734886 \cdot 10^{-110}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -5.01776738281857308254796379287654417567 \cdot 10^{-5}:\\
\;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\

\mathbf{elif}\;x \le 3.62378838658747611836253077264636734886 \cdot 10^{-110}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r21730167 = x;
        double r21730168 = 2.0;
        double r21730169 = r21730167 * r21730168;
        double r21730170 = y;
        double r21730171 = r21730169 * r21730170;
        double r21730172 = r21730167 - r21730170;
        double r21730173 = r21730171 / r21730172;
        return r21730173;
}

double f(double x, double y) {
        double r21730174 = x;
        double r21730175 = -5.017767382818573e-05;
        bool r21730176 = r21730174 <= r21730175;
        double r21730177 = y;
        double r21730178 = 2.0;
        double r21730179 = r21730177 * r21730178;
        double r21730180 = r21730174 - r21730177;
        double r21730181 = r21730174 / r21730180;
        double r21730182 = r21730179 * r21730181;
        double r21730183 = 3.623788386587476e-110;
        bool r21730184 = r21730174 <= r21730183;
        double r21730185 = r21730174 * r21730178;
        double r21730186 = r21730180 / r21730177;
        double r21730187 = r21730185 / r21730186;
        double r21730188 = r21730184 ? r21730187 : r21730182;
        double r21730189 = r21730176 ? r21730182 : r21730188;
        return r21730189;
}

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.3
Herbie0.5
\[\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 2 regimes
  2. if x < -5.017767382818573e-05 or 3.623788386587476e-110 < x

    1. Initial program 14.4

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

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

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

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

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

    if -5.017767382818573e-05 < x < 3.623788386587476e-110

    1. Initial program 16.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.01776738281857308254796379287654417567 \cdot 10^{-5}:\\ \;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\ \mathbf{elif}\;x \le 3.62378838658747611836253077264636734886 \cdot 10^{-110}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\ \end{array}\]

Reproduce

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