Average Error: 14.9 → 0.4
Time: 5.7s
Precision: 64
\[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.475760874344247412285955891776113381999 \cdot 10^{-22} \lor \neg \left(y \le 8.032379764470728586268388231044118745118 \cdot 10^{-73}\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 -1.475760874344247412285955891776113381999 \cdot 10^{-22} \lor \neg \left(y \le 8.032379764470728586268388231044118745118 \cdot 10^{-73}\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 r314883 = x;
        double r314884 = y;
        double r314885 = r314883 + r314884;
        double r314886 = 2.0;
        double r314887 = r314883 * r314886;
        double r314888 = r314887 * r314884;
        double r314889 = r314885 / r314888;
        return r314889;
}

double f(double x, double y) {
        double r314890 = y;
        double r314891 = -1.4757608743442474e-22;
        bool r314892 = r314890 <= r314891;
        double r314893 = 8.032379764470729e-73;
        bool r314894 = r314890 <= r314893;
        double r314895 = !r314894;
        bool r314896 = r314892 || r314895;
        double r314897 = 1.0;
        double r314898 = x;
        double r314899 = 2.0;
        double r314900 = r314898 * r314899;
        double r314901 = r314897 / r314900;
        double r314902 = r314898 + r314890;
        double r314903 = r314902 / r314890;
        double r314904 = r314901 * r314903;
        double r314905 = r314902 / r314900;
        double r314906 = r314905 / r314890;
        double r314907 = r314896 ? r314904 : r314906;
        return r314907;
}

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

Derivation

  1. Split input into 2 regimes
  2. if y < -1.4757608743442474e-22 or 8.032379764470729e-73 < y

    1. Initial program 13.5

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

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

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

    if -1.4757608743442474e-22 < y < 8.032379764470729e-73

    1. Initial program 17.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.475760874344247412285955891776113381999 \cdot 10^{-22} \lor \neg \left(y \le 8.032379764470728586268388231044118745118 \cdot 10^{-73}\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 2019212 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, C"
  :precision binary64

  :herbie-target
  (+ (/ 0.5 x) (/ 0.5 y))

  (/ (+ x y) (* (* x 2) y)))