Average Error: 15.4 → 0.2
Time: 17.0s
Precision: 64
\[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -34049285222232588342224461470667636736 \lor \neg \left(x \le 5.984537492343478795202216441324558590653 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{\frac{x - y}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\ \end{array}\]
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;x \le -34049285222232588342224461470667636736 \lor \neg \left(x \le 5.984537492343478795202216441324558590653 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{\frac{x - y}{x \cdot 2}}{y}\\

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

\end{array}
double f(double x, double y) {
        double r452369 = x;
        double r452370 = y;
        double r452371 = r452369 - r452370;
        double r452372 = 2.0;
        double r452373 = r452369 * r452372;
        double r452374 = r452373 * r452370;
        double r452375 = r452371 / r452374;
        return r452375;
}

double f(double x, double y) {
        double r452376 = x;
        double r452377 = -3.404928522223259e+37;
        bool r452378 = r452376 <= r452377;
        double r452379 = 5.984537492343479e-19;
        bool r452380 = r452376 <= r452379;
        double r452381 = !r452380;
        bool r452382 = r452378 || r452381;
        double r452383 = y;
        double r452384 = r452376 - r452383;
        double r452385 = 2.0;
        double r452386 = r452376 * r452385;
        double r452387 = r452384 / r452386;
        double r452388 = r452387 / r452383;
        double r452389 = 1.0;
        double r452390 = r452389 / r452386;
        double r452391 = r452384 / r452383;
        double r452392 = r452390 * r452391;
        double r452393 = r452382 ? r452388 : r452392;
        return r452393;
}

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.2
\[\frac{0.5}{y} - \frac{0.5}{x}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -3.404928522223259e+37 or 5.984537492343479e-19 < x

    1. Initial program 16.5

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

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

    if -3.404928522223259e+37 < x < 5.984537492343479e-19

    1. Initial program 14.4

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

      \[\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}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -34049285222232588342224461470667636736 \lor \neg \left(x \le 5.984537492343478795202216441324558590653 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{\frac{x - y}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019209 +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)))