Average Error: 7.7 → 1.0
Time: 7.5s
Precision: 64
\[x \ge -0.5 \land x \le 0.5\]
\[\frac{a + b}{1 - a \cdot b}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a + b}{1 - a \cdot b} \le -7.233755570401035316922079348244947479559 \cdot 10^{-207}:\\ \;\;\;\;\frac{1}{\frac{1 - a \cdot b}{a + b}}\\ \mathbf{elif}\;\frac{a + b}{1 - a \cdot b} \le 0.0:\\ \;\;\;\;\frac{-1}{b} - \left(\frac{1}{a} + \frac{1}{{a}^{2} \cdot b}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a + b}{1 - a \cdot b}\\ \end{array}\]
\frac{a + b}{1 - a \cdot b}
\begin{array}{l}
\mathbf{if}\;\frac{a + b}{1 - a \cdot b} \le -7.233755570401035316922079348244947479559 \cdot 10^{-207}:\\
\;\;\;\;\frac{1}{\frac{1 - a \cdot b}{a + b}}\\

\mathbf{elif}\;\frac{a + b}{1 - a \cdot b} \le 0.0:\\
\;\;\;\;\frac{-1}{b} - \left(\frac{1}{a} + \frac{1}{{a}^{2} \cdot b}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{a + b}{1 - a \cdot b}\\

\end{array}
double f(double a, double b, double __attribute__((unused)) x) {
        double r2312508 = a;
        double r2312509 = b;
        double r2312510 = r2312508 + r2312509;
        double r2312511 = 1.0;
        double r2312512 = r2312508 * r2312509;
        double r2312513 = r2312511 - r2312512;
        double r2312514 = r2312510 / r2312513;
        return r2312514;
}

double f(double a, double b, double __attribute__((unused)) x) {
        double r2312515 = a;
        double r2312516 = b;
        double r2312517 = r2312515 + r2312516;
        double r2312518 = 1.0;
        double r2312519 = r2312515 * r2312516;
        double r2312520 = r2312518 - r2312519;
        double r2312521 = r2312517 / r2312520;
        double r2312522 = -7.233755570401035e-207;
        bool r2312523 = r2312521 <= r2312522;
        double r2312524 = 1.0;
        double r2312525 = r2312520 / r2312517;
        double r2312526 = r2312524 / r2312525;
        double r2312527 = 0.0;
        bool r2312528 = r2312521 <= r2312527;
        double r2312529 = -1.0;
        double r2312530 = r2312529 / r2312516;
        double r2312531 = r2312524 / r2312515;
        double r2312532 = 2.0;
        double r2312533 = pow(r2312515, r2312532);
        double r2312534 = r2312533 * r2312516;
        double r2312535 = r2312518 / r2312534;
        double r2312536 = r2312531 + r2312535;
        double r2312537 = r2312530 - r2312536;
        double r2312538 = r2312528 ? r2312537 : r2312521;
        double r2312539 = r2312523 ? r2312526 : r2312538;
        return r2312539;
}

Error

Bits error versus a

Bits error versus b

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (/ (+ a b) (- 1.0 (* a b))) < -7.233755570401035e-207

    1. Initial program 0.1

      \[\frac{a + b}{1 - a \cdot b}\]
    2. Using strategy rm
    3. Applied clear-num0.2

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - a \cdot b}{a + b}}}\]

    if -7.233755570401035e-207 < (/ (+ a b) (- 1.0 (* a b))) < 0.0

    1. Initial program 49.9

      \[\frac{a + b}{1 - a \cdot b}\]
    2. Taylor expanded around inf 11.6

      \[\leadsto \color{blue}{-\left(\frac{1}{b} + \left(1 \cdot \frac{1}{{a}^{2} \cdot b} + \frac{1}{a}\right)\right)}\]
    3. Simplified11.6

      \[\leadsto \color{blue}{\frac{-1}{b} - \left(\frac{1}{a} + \frac{1}{{a}^{2} \cdot b}\right)}\]

    if 0.0 < (/ (+ a b) (- 1.0 (* a b)))

    1. Initial program 7.7

      \[\frac{a + b}{1 - a \cdot b}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a + b}{1 - a \cdot b} \le -7.233755570401035316922079348244947479559 \cdot 10^{-207}:\\ \;\;\;\;\frac{1}{\frac{1 - a \cdot b}{a + b}}\\ \mathbf{elif}\;\frac{a + b}{1 - a \cdot b} \le 0.0:\\ \;\;\;\;\frac{-1}{b} - \left(\frac{1}{a} + \frac{1}{{a}^{2} \cdot b}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a + b}{1 - a \cdot b}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (a b x)
  :name "(a+b)/(1-a*b)"
  :precision binary64
  :pre (and (>= x (- 0.5)) (<= x 0.5))
  (/ (+ a b) (- 1 (* a b))))