Average Error: 15.3 → 8.4
Time: 2.5s
Precision: 64
\[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
\[\frac{\frac{\frac{x + y}{y}}{2}}{x}\]
\frac{x + y}{\left(x \cdot 2\right) \cdot y}
\frac{\frac{\frac{x + y}{y}}{2}}{x}
double f(double x, double y) {
        double r442629 = x;
        double r442630 = y;
        double r442631 = r442629 + r442630;
        double r442632 = 2.0;
        double r442633 = r442629 * r442632;
        double r442634 = r442633 * r442630;
        double r442635 = r442631 / r442634;
        return r442635;
}

double f(double x, double y) {
        double r442636 = x;
        double r442637 = y;
        double r442638 = r442636 + r442637;
        double r442639 = r442638 / r442637;
        double r442640 = 2.0;
        double r442641 = r442639 / r442640;
        double r442642 = r442641 / r442636;
        return r442642;
}

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.3
Target0.0
Herbie8.4
\[\frac{0.5}{x} + \frac{0.5}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -2.1344161616579373e+52 or 1.5003823122464018e-27 < y

    1. Initial program 16.3

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

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

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

    if -2.1344161616579373e+52 < y < 1.5003823122464018e-27

    1. Initial program 14.5

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot 2} \cdot \frac{x + y}{y}}\]
    5. Using strategy rm
    6. Applied div-inv16.0

      \[\leadsto \frac{1}{x \cdot 2} \cdot \color{blue}{\left(\left(x + y\right) \cdot \frac{1}{y}\right)}\]
    7. Applied associate-*r*0.4

      \[\leadsto \color{blue}{\left(\frac{1}{x \cdot 2} \cdot \left(x + y\right)\right) \cdot \frac{1}{y}}\]
    8. Simplified0.3

      \[\leadsto \color{blue}{\frac{x + y}{x \cdot 2}} \cdot \frac{1}{y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.4

    \[\leadsto \frac{\frac{\frac{x + y}{y}}{2}}{x}\]

Reproduce

herbie shell --seed 1978988140 
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, C"
  :precision binary64

  :herbie-target
  (+ (/ 0.5 x) (/ 0.5 y))

  (/ (+ x y) (* (* x 2) y)))