Average Error: 14.3 → 0.1
Time: 12.3s
Precision: 64
\[\frac{x + y}{\left(x \cdot 2.0\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -28977.221790386797:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2.0}\\ \mathbf{elif}\;y \le 3.49698992568305 \cdot 10^{-34}:\\ \;\;\;\;\frac{\frac{y + x}{x \cdot 2.0}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2.0}\\ \end{array}\]
\frac{x + y}{\left(x \cdot 2.0\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;y \le -28977.221790386797:\\
\;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2.0}\\

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

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

\end{array}
double f(double x, double y) {
        double r22581498 = x;
        double r22581499 = y;
        double r22581500 = r22581498 + r22581499;
        double r22581501 = 2.0;
        double r22581502 = r22581498 * r22581501;
        double r22581503 = r22581502 * r22581499;
        double r22581504 = r22581500 / r22581503;
        return r22581504;
}

double f(double x, double y) {
        double r22581505 = y;
        double r22581506 = -28977.221790386797;
        bool r22581507 = r22581505 <= r22581506;
        double r22581508 = x;
        double r22581509 = r22581505 + r22581508;
        double r22581510 = r22581509 / r22581505;
        double r22581511 = 1.0;
        double r22581512 = 2.0;
        double r22581513 = r22581508 * r22581512;
        double r22581514 = r22581511 / r22581513;
        double r22581515 = r22581510 * r22581514;
        double r22581516 = 3.49698992568305e-34;
        bool r22581517 = r22581505 <= r22581516;
        double r22581518 = r22581509 / r22581513;
        double r22581519 = r22581518 / r22581505;
        double r22581520 = r22581517 ? r22581519 : r22581515;
        double r22581521 = r22581507 ? r22581515 : r22581520;
        return r22581521;
}

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.3
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.0\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.0\right) \cdot y}\]
    4. Applied times-frac0.2

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

    if -28977.221790386797 < y < 3.49698992568305e-34

    1. Initial program 14.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -28977.221790386797:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2.0}\\ \mathbf{elif}\;y \le 3.49698992568305 \cdot 10^{-34}:\\ \;\;\;\;\frac{\frac{y + x}{x \cdot 2.0}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{y} \cdot \frac{1}{x \cdot 2.0}\\ \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)))