Average Error: 15.4 → 0.0
Time: 1.4s
Precision: 64
\[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
\[0.5 \cdot \left(\frac{1}{y} - \frac{1}{x}\right)\]
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
0.5 \cdot \left(\frac{1}{y} - \frac{1}{x}\right)
double f(double x, double y) {
        double r517001 = x;
        double r517002 = y;
        double r517003 = r517001 - r517002;
        double r517004 = 2.0;
        double r517005 = r517001 * r517004;
        double r517006 = r517005 * r517002;
        double r517007 = r517003 / r517006;
        return r517007;
}

double f(double x, double y) {
        double r517008 = 0.5;
        double r517009 = 1.0;
        double r517010 = y;
        double r517011 = r517009 / r517010;
        double r517012 = x;
        double r517013 = r517009 / r517012;
        double r517014 = r517011 - r517013;
        double r517015 = r517008 * r517014;
        return r517015;
}

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

Derivation

  1. Initial program 15.4

    \[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
  2. Taylor expanded around 0 0.0

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

    \[\leadsto \color{blue}{0.5 \cdot \left(\frac{1}{y} - \frac{1}{x}\right)}\]
  4. Final simplification0.0

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

Reproduce

herbie shell --seed 2020065 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, B"
  :precision binary64

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

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