Average Error: 14.9 → 0.1
Time: 31.5s
Precision: 64
\[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -28977.22179038679678342305123805999755859:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2}\\ \mathbf{elif}\;y \le 3.496989925683049938768280575041583491689 \cdot 10^{-34}:\\ \;\;\;\;\frac{\frac{y + x}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2}\\ \end{array}\]
\frac{x + y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;y \le -28977.22179038679678342305123805999755859:\\
\;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2}\\

\mathbf{elif}\;y \le 3.496989925683049938768280575041583491689 \cdot 10^{-34}:\\
\;\;\;\;\frac{\frac{y + x}{x \cdot 2}}{y}\\

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

\end{array}
double f(double x, double y) {
        double r22789764 = x;
        double r22789765 = y;
        double r22789766 = r22789764 + r22789765;
        double r22789767 = 2.0;
        double r22789768 = r22789764 * r22789767;
        double r22789769 = r22789768 * r22789765;
        double r22789770 = r22789766 / r22789769;
        return r22789770;
}

double f(double x, double y) {
        double r22789771 = y;
        double r22789772 = -28977.221790386797;
        bool r22789773 = r22789771 <= r22789772;
        double r22789774 = x;
        double r22789775 = r22789771 + r22789774;
        double r22789776 = r22789775 / r22789771;
        double r22789777 = 1.0;
        double r22789778 = 2.0;
        double r22789779 = r22789774 * r22789778;
        double r22789780 = r22789777 / r22789779;
        double r22789781 = r22789776 * r22789780;
        double r22789782 = 3.49698992568305e-34;
        bool r22789783 = r22789771 <= r22789782;
        double r22789784 = r22789775 / r22789779;
        double r22789785 = r22789784 / r22789771;
        double r22789786 = r22789783 ? r22789785 : r22789781;
        double r22789787 = r22789773 ? r22789781 : r22789786;
        return r22789787;
}

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

Derivation

  1. Split input into 2 regimes
  2. if y < -28977.221790386797 or 3.49698992568305e-34 < y

    1. Initial program 14.3

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

      \[\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}}\]

    if -28977.221790386797 < y < 3.49698992568305e-34

    1. Initial program 15.6

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -28977.22179038679678342305123805999755859:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2}\\ \mathbf{elif}\;y \le 3.496989925683049938768280575041583491689 \cdot 10^{-34}:\\ \;\;\;\;\frac{\frac{y + x}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, C"

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

  (/ (+ x y) (* (* x 2.0) y)))