Average Error: 14.6 → 0.8
Time: 18.1s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -57238629659.91823577880859375:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.021719397133276368228592954796657675009 \cdot 10^{-140}:\\ \;\;\;\;\frac{2 \cdot x}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -57238629659.91823577880859375:\\
\;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\

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

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

\end{array}
double f(double x, double y) {
        double r25076831 = x;
        double r25076832 = 2.0;
        double r25076833 = r25076831 * r25076832;
        double r25076834 = y;
        double r25076835 = r25076833 * r25076834;
        double r25076836 = r25076831 - r25076834;
        double r25076837 = r25076835 / r25076836;
        return r25076837;
}

double f(double x, double y) {
        double r25076838 = x;
        double r25076839 = -57238629659.918236;
        bool r25076840 = r25076838 <= r25076839;
        double r25076841 = 2.0;
        double r25076842 = r25076841 * r25076838;
        double r25076843 = y;
        double r25076844 = r25076838 - r25076843;
        double r25076845 = r25076842 / r25076844;
        double r25076846 = r25076845 * r25076843;
        double r25076847 = 1.0217193971332764e-140;
        bool r25076848 = r25076838 <= r25076847;
        double r25076849 = r25076844 / r25076843;
        double r25076850 = r25076842 / r25076849;
        double r25076851 = r25076848 ? r25076850 : r25076846;
        double r25076852 = r25076840 ? r25076846 : r25076851;
        return r25076852;
}

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.4
Herbie0.8
\[\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 < -57238629659.918236 or 1.0217193971332764e-140 < x

    1. Initial program 14.0

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

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

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

    if -57238629659.918236 < x < 1.0217193971332764e-140

    1. Initial program 15.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -57238629659.91823577880859375:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.021719397133276368228592954796657675009 \cdot 10^{-140}:\\ \;\;\;\;\frac{2 \cdot x}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \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)))