Average Error: 14.9 → 7.0
Time: 6.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[x \cdot \left(2 \cdot \frac{y}{x - y}\right)\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
x \cdot \left(2 \cdot \frac{y}{x - y}\right)
double f(double x, double y) {
        double r455650 = x;
        double r455651 = 2.0;
        double r455652 = r455650 * r455651;
        double r455653 = y;
        double r455654 = r455652 * r455653;
        double r455655 = r455650 - r455653;
        double r455656 = r455654 / r455655;
        return r455656;
}

double f(double x, double y) {
        double r455657 = x;
        double r455658 = 2.0;
        double r455659 = y;
        double r455660 = r455657 - r455659;
        double r455661 = r455659 / r455660;
        double r455662 = r455658 * r455661;
        double r455663 = r455657 * r455662;
        return r455663;
}

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.9
Target0.3
Herbie7.0
\[\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 3 regimes
  2. if y < -1.3041135359922132e-54

    1. Initial program 14.2

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right)} \cdot \frac{y}{x - y}\]
    6. Using strategy rm
    7. Applied associate-*l*0.3

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

    if -1.3041135359922132e-54 < y < 1.6669026246870463e-40

    1. Initial program 15.2

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

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

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

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

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

    if 1.6669026246870463e-40 < y

    1. Initial program 15.2

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.2

      \[\leadsto \frac{x \cdot 2}{\frac{x - y}{\color{blue}{1 \cdot y}}}\]
    6. Applied *-un-lft-identity0.2

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

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

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

      \[\leadsto \frac{x \cdot 2}{1 \cdot \color{blue}{\left(\frac{x}{y} - 1\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.0

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

Reproduce

herbie shell --seed 2019294 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))