Average Error: 14.2 → 0.8
Time: 9.6s
Precision: 64
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -57238629659.918236:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.0217193971332764 \cdot 10^{-140}:\\ \;\;\;\;\frac{2.0 \cdot x}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -57238629659.918236:\\
\;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\

\mathbf{elif}\;x \le 1.0217193971332764 \cdot 10^{-140}:\\
\;\;\;\;\frac{2.0 \cdot x}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r22638193 = x;
        double r22638194 = 2.0;
        double r22638195 = r22638193 * r22638194;
        double r22638196 = y;
        double r22638197 = r22638195 * r22638196;
        double r22638198 = r22638193 - r22638196;
        double r22638199 = r22638197 / r22638198;
        return r22638199;
}

double f(double x, double y) {
        double r22638200 = x;
        double r22638201 = -57238629659.918236;
        bool r22638202 = r22638200 <= r22638201;
        double r22638203 = 2.0;
        double r22638204 = r22638203 * r22638200;
        double r22638205 = y;
        double r22638206 = r22638200 - r22638205;
        double r22638207 = r22638204 / r22638206;
        double r22638208 = r22638207 * r22638205;
        double r22638209 = 1.0217193971332764e-140;
        bool r22638210 = r22638200 <= r22638209;
        double r22638211 = r22638206 / r22638205;
        double r22638212 = r22638204 / r22638211;
        double r22638213 = r22638210 ? r22638212 : r22638208;
        double r22638214 = r22638202 ? r22638208 : r22638213;
        return r22638214;
}

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.2
Target0.4
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 8.364504563556443 \cdot 10^{+16}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -57238629659.918236 or 1.0217193971332764e-140 < x

    1. Initial program 13.3

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

      \[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/1.2

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

    if -57238629659.918236 < x < 1.0217193971332764e-140

    1. Initial program 15.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -57238629659.918236:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.0217193971332764 \cdot 10^{-140}:\\ \;\;\;\;\frac{2.0 \cdot x}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]

Reproduce

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