Average Error: 15.6 → 0.3
Time: 2.6s
Precision: 64
\[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.0376031176562681 \cdot 10^{-36} \lor \neg \left(y \le 5.8064464690404152 \cdot 10^{46}\right):\\ \;\;\;\;\frac{\frac{1}{x}}{\frac{y}{\frac{x - y}{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\frac{x \cdot 2}{x - y}}}{y}\\ \end{array}\]
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;y \le -4.0376031176562681 \cdot 10^{-36} \lor \neg \left(y \le 5.8064464690404152 \cdot 10^{46}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{\frac{y}{\frac{x - y}{2}}}\\

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

\end{array}
double f(double x, double y) {
        double r614397 = x;
        double r614398 = y;
        double r614399 = r614397 - r614398;
        double r614400 = 2.0;
        double r614401 = r614397 * r614400;
        double r614402 = r614401 * r614398;
        double r614403 = r614399 / r614402;
        return r614403;
}

double f(double x, double y) {
        double r614404 = y;
        double r614405 = -4.037603117656268e-36;
        bool r614406 = r614404 <= r614405;
        double r614407 = 5.806446469040415e+46;
        bool r614408 = r614404 <= r614407;
        double r614409 = !r614408;
        bool r614410 = r614406 || r614409;
        double r614411 = 1.0;
        double r614412 = x;
        double r614413 = r614411 / r614412;
        double r614414 = r614412 - r614404;
        double r614415 = 2.0;
        double r614416 = r614414 / r614415;
        double r614417 = r614404 / r614416;
        double r614418 = r614413 / r614417;
        double r614419 = r614412 * r614415;
        double r614420 = r614419 / r614414;
        double r614421 = r614411 / r614420;
        double r614422 = r614421 / r614404;
        double r614423 = r614410 ? r614418 : r614422;
        return r614423;
}

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

Derivation

  1. Split input into 2 regimes
  2. if y < -4.037603117656268e-36 or 5.806446469040415e+46 < y

    1. Initial program 16.0

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} \cdot \frac{x - y}{2}}}{y}\]
    7. Applied associate-/l*0.1

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

    if -4.037603117656268e-36 < y < 5.806446469040415e+46

    1. Initial program 15.2

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

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

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

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

Reproduce

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