Average Error: 15.3 → 0.3
Time: 3.0s
Precision: 64
\[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.13970281624645849 \cdot 10^{-71} \lor \neg \left(x \le 5.70707891780906418 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{\frac{x + y}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{\frac{y}{\frac{x + y}{2}}}\\ \end{array}\]
\frac{x + y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;x \le -1.13970281624645849 \cdot 10^{-71} \lor \neg \left(x \le 5.70707891780906418 \cdot 10^{-21}\right):\\
\;\;\;\;\frac{\frac{x + y}{x \cdot 2}}{y}\\

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

\end{array}
double f(double x, double y) {
        double r465251 = x;
        double r465252 = y;
        double r465253 = r465251 + r465252;
        double r465254 = 2.0;
        double r465255 = r465251 * r465254;
        double r465256 = r465255 * r465252;
        double r465257 = r465253 / r465256;
        return r465257;
}

double f(double x, double y) {
        double r465258 = x;
        double r465259 = -1.1397028162464585e-71;
        bool r465260 = r465258 <= r465259;
        double r465261 = 5.707078917809064e-21;
        bool r465262 = r465258 <= r465261;
        double r465263 = !r465262;
        bool r465264 = r465260 || r465263;
        double r465265 = y;
        double r465266 = r465258 + r465265;
        double r465267 = 2.0;
        double r465268 = r465258 * r465267;
        double r465269 = r465266 / r465268;
        double r465270 = r465269 / r465265;
        double r465271 = 1.0;
        double r465272 = r465271 / r465258;
        double r465273 = r465266 / r465267;
        double r465274 = r465265 / r465273;
        double r465275 = r465272 / r465274;
        double r465276 = r465264 ? r465270 : r465275;
        return r465276;
}

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.1397028162464585e-71 or 5.707078917809064e-21 < x

    1. Initial program 14.2

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

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

    if -1.1397028162464585e-71 < x < 5.707078917809064e-21

    1. Initial program 16.8

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

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

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

      \[\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}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.13970281624645849 \cdot 10^{-71} \lor \neg \left(x \le 5.70707891780906418 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{\frac{x + y}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{\frac{y}{\frac{x + y}{2}}}\\ \end{array}\]

Reproduce

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