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{\sqrt{1}}{\frac{x}{1}}}{\frac{y \cdot 2}{x - y}}\\ \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{\sqrt{1}}{\frac{x}{1}}}{\frac{y \cdot 2}{x - y}}\\

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

\end{array}
double f(double x, double y) {
        double r572780 = x;
        double r572781 = y;
        double r572782 = r572780 - r572781;
        double r572783 = 2.0;
        double r572784 = r572780 * r572783;
        double r572785 = r572784 * r572781;
        double r572786 = r572782 / r572785;
        return r572786;
}

double f(double x, double y) {
        double r572787 = y;
        double r572788 = -4.037603117656268e-36;
        bool r572789 = r572787 <= r572788;
        double r572790 = 5.806446469040415e+46;
        bool r572791 = r572787 <= r572790;
        double r572792 = !r572791;
        bool r572793 = r572789 || r572792;
        double r572794 = 1.0;
        double r572795 = sqrt(r572794);
        double r572796 = x;
        double r572797 = r572796 / r572794;
        double r572798 = r572795 / r572797;
        double r572799 = 2.0;
        double r572800 = r572787 * r572799;
        double r572801 = r572796 - r572787;
        double r572802 = r572800 / r572801;
        double r572803 = r572798 / r572802;
        double r572804 = r572796 * r572799;
        double r572805 = r572804 / r572801;
        double r572806 = r572794 / r572805;
        double r572807 = r572806 / r572787;
        double r572808 = r572793 ? r572803 : r572807;
        return r572808;
}

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 clear-num16.8

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{x}{1} \cdot \frac{2}{x - y}}}}{y}\]
    9. Applied add-sqr-sqrt16.8

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{x}{1} \cdot \frac{2}{x - y}}}{y}\]
    10. Applied times-frac16.7

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{1}}{\frac{x}{1}}}{\frac{y}{\frac{\sqrt{1}}{\frac{2}{x - y}}}}}\]
    12. Simplified0.2

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

    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{\sqrt{1}}{\frac{x}{1}}}{\frac{y \cdot 2}{x - y}}\\ \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)))