Average Error: 14.9 → 0.2
Time: 13.9s
Precision: 64
\[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -581495020226601048837164420888002560 \lor \neg \left(y \le 4840027656.94566631317138671875\right):\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x - y}{x \cdot 2}}{y}\\ \end{array}\]
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;y \le -581495020226601048837164420888002560 \lor \neg \left(y \le 4840027656.94566631317138671875\right):\\
\;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\

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

\end{array}
double f(double x, double y) {
        double r303078 = x;
        double r303079 = y;
        double r303080 = r303078 - r303079;
        double r303081 = 2.0;
        double r303082 = r303078 * r303081;
        double r303083 = r303082 * r303079;
        double r303084 = r303080 / r303083;
        return r303084;
}

double f(double x, double y) {
        double r303085 = y;
        double r303086 = -5.8149502022660105e+35;
        bool r303087 = r303085 <= r303086;
        double r303088 = 4840027656.945666;
        bool r303089 = r303085 <= r303088;
        double r303090 = !r303089;
        bool r303091 = r303087 || r303090;
        double r303092 = 1.0;
        double r303093 = x;
        double r303094 = 2.0;
        double r303095 = r303093 * r303094;
        double r303096 = r303092 / r303095;
        double r303097 = r303093 - r303085;
        double r303098 = r303097 / r303085;
        double r303099 = r303096 * r303098;
        double r303100 = r303097 / r303095;
        double r303101 = r303100 / r303085;
        double r303102 = r303091 ? r303099 : r303101;
        return r303102;
}

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

Derivation

  1. Split input into 2 regimes
  2. if y < -5.8149502022660105e+35 or 4840027656.945666 < y

    1. Initial program 16.5

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

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

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

    if -5.8149502022660105e+35 < y < 4840027656.945666

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

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

Reproduce

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