Average Error: 15.0 → 0.2
Time: 10.6s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\frac{1}{\frac{0.5}{y} - \frac{0.5}{x}}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\frac{1}{\frac{0.5}{y} - \frac{0.5}{x}}
double f(double x, double y) {
        double r365722 = x;
        double r365723 = 2.0;
        double r365724 = r365722 * r365723;
        double r365725 = y;
        double r365726 = r365724 * r365725;
        double r365727 = r365722 - r365725;
        double r365728 = r365726 / r365727;
        return r365728;
}

double f(double x, double y) {
        double r365729 = 1.0;
        double r365730 = 0.5;
        double r365731 = y;
        double r365732 = r365730 / r365731;
        double r365733 = x;
        double r365734 = r365730 / r365733;
        double r365735 = r365732 - r365734;
        double r365736 = r365729 / r365735;
        return r365736;
}

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.0
Target0.3
Herbie0.2
\[\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. Initial program 15.0

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

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

    \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{x}{y} - 1}}\]
  5. Using strategy rm
  6. Applied clear-num7.7

    \[\leadsto \color{blue}{\frac{1}{\frac{\frac{x}{y} - 1}{x \cdot 2}}}\]
  7. Taylor expanded around 0 0.2

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

    \[\leadsto \frac{1}{\color{blue}{\frac{0.5}{y} - \frac{0.5}{x}}}\]
  9. Final simplification0.2

    \[\leadsto \frac{1}{\frac{0.5}{y} - \frac{0.5}{x}}\]

Reproduce

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