Average Error: 15.2 → 0.4
Time: 15.5s
Precision: 64
\[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.392096079342848193007314734731115011171 \cdot 10^{-86} \lor \neg \left(y \le 5.173054498508759236112133194996942845024 \cdot 10^{-30}\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.392096079342848193007314734731115011171 \cdot 10^{-86} \lor \neg \left(y \le 5.173054498508759236112133194996942845024 \cdot 10^{-30}\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 r320679 = x;
        double r320680 = y;
        double r320681 = r320679 + r320680;
        double r320682 = 2.0;
        double r320683 = r320679 * r320682;
        double r320684 = r320683 * r320680;
        double r320685 = r320681 / r320684;
        return r320685;
}

double f(double x, double y) {
        double r320686 = y;
        double r320687 = -1.3920960793428482e-86;
        bool r320688 = r320686 <= r320687;
        double r320689 = 5.173054498508759e-30;
        bool r320690 = r320686 <= r320689;
        double r320691 = !r320690;
        bool r320692 = r320688 || r320691;
        double r320693 = 1.0;
        double r320694 = x;
        double r320695 = 2.0;
        double r320696 = r320694 * r320695;
        double r320697 = r320693 / r320696;
        double r320698 = r320694 + r320686;
        double r320699 = r320698 / r320686;
        double r320700 = r320697 * r320699;
        double r320701 = r320698 / r320696;
        double r320702 = r320701 / r320686;
        double r320703 = r320692 ? r320700 : r320702;
        return r320703;
}

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

Derivation

  1. Split input into 2 regimes
  2. if y < -1.3920960793428482e-86 or 5.173054498508759e-30 < 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.3920960793428482e-86 < y < 5.173054498508759e-30

    1. Initial program 17.8

      \[\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.392096079342848193007314734731115011171 \cdot 10^{-86} \lor \neg \left(y \le 5.173054498508759236112133194996942845024 \cdot 10^{-30}\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 2019306 +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)))