Average Error: 15.4 → 0.1
Time: 16.7s
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{\frac{x - y}{2}}{x}}{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{\frac{x - y}{2}}{x}}{y}\\

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

\end{array}
double f(double x, double y) {
        double r411822 = x;
        double r411823 = y;
        double r411824 = r411822 - r411823;
        double r411825 = 2.0;
        double r411826 = r411822 * r411825;
        double r411827 = r411826 * r411823;
        double r411828 = r411824 / r411827;
        return r411828;
}

double f(double x, double y) {
        double r411829 = x;
        double r411830 = -3.404928522223259e+37;
        bool r411831 = r411829 <= r411830;
        double r411832 = 5.984537492343479e-19;
        bool r411833 = r411829 <= r411832;
        double r411834 = !r411833;
        bool r411835 = r411831 || r411834;
        double r411836 = y;
        double r411837 = r411829 - r411836;
        double r411838 = 2.0;
        double r411839 = r411837 / r411838;
        double r411840 = r411839 / r411829;
        double r411841 = r411840 / r411836;
        double r411842 = 1.0;
        double r411843 = r411829 * r411838;
        double r411844 = r411842 / r411843;
        double r411845 = r411837 / r411836;
        double r411846 = r411844 * r411845;
        double r411847 = r411835 ? r411841 : r411846;
        return r411847;
}

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.1
\[\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 *-un-lft-identity16.5

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}}\]
    5. Using strategy rm
    6. Applied associate-*r/0.2

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{x - y}{2}}{x}}}{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.1

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

Reproduce

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