Average Error: 14.9 → 0.2
Time: 10.1s
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 828625256103.0855712890625\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 828625256103.0855712890625\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 r338095 = x;
        double r338096 = y;
        double r338097 = r338095 + r338096;
        double r338098 = 2.0;
        double r338099 = r338095 * r338098;
        double r338100 = r338099 * r338096;
        double r338101 = r338097 / r338100;
        return r338101;
}

double f(double x, double y) {
        double r338102 = y;
        double r338103 = -5.8149502022660105e+35;
        bool r338104 = r338102 <= r338103;
        double r338105 = 828625256103.0856;
        bool r338106 = r338102 <= r338105;
        double r338107 = !r338106;
        bool r338108 = r338104 || r338107;
        double r338109 = 1.0;
        double r338110 = x;
        double r338111 = 2.0;
        double r338112 = r338110 * r338111;
        double r338113 = r338109 / r338112;
        double r338114 = r338110 + r338102;
        double r338115 = r338114 / r338102;
        double r338116 = r338113 * r338115;
        double r338117 = r338114 / r338112;
        double r338118 = r338117 / r338102;
        double r338119 = r338108 ? r338116 : r338118;
        return r338119;
}

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

Derivation

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

    1. Initial program 16.6

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

      \[\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 < 828625256103.0856

    1. Initial program 13.4

      \[\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 828625256103.0855712890625\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, C"
  :precision binary64

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

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