Average Error: 7.7 → 2.8
Time: 6.8s
Precision: 64
\[b \lt a\]
\[\frac{a + b}{1 - a \cdot b}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.103965574456185187720871491165962419889 \cdot 10^{191} \lor \neg \left(b \le 4.354857369571379975401692621934704586388 \cdot 10^{-39}\right):\\ \;\;\;\;\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - a \cdot b} \cdot \left(a + b\right)\\ \end{array}\]
\frac{a + b}{1 - a \cdot b}
\begin{array}{l}
\mathbf{if}\;b \le -1.103965574456185187720871491165962419889 \cdot 10^{191} \lor \neg \left(b \le 4.354857369571379975401692621934704586388 \cdot 10^{-39}\right):\\
\;\;\;\;\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{1 - a \cdot b} \cdot \left(a + b\right)\\

\end{array}
double f(double a, double b) {
        double r2323082 = a;
        double r2323083 = b;
        double r2323084 = r2323082 + r2323083;
        double r2323085 = 1.0;
        double r2323086 = r2323082 * r2323083;
        double r2323087 = r2323085 - r2323086;
        double r2323088 = r2323084 / r2323087;
        return r2323088;
}

double f(double a, double b) {
        double r2323089 = b;
        double r2323090 = -1.1039655744561852e+191;
        bool r2323091 = r2323089 <= r2323090;
        double r2323092 = 4.35485736957138e-39;
        bool r2323093 = r2323089 <= r2323092;
        double r2323094 = !r2323093;
        bool r2323095 = r2323091 || r2323094;
        double r2323096 = -1.0;
        double r2323097 = r2323096 / r2323089;
        double r2323098 = 1.0;
        double r2323099 = a;
        double r2323100 = r2323099 * r2323089;
        double r2323101 = r2323100 * r2323099;
        double r2323102 = r2323098 / r2323101;
        double r2323103 = 1.0;
        double r2323104 = r2323103 / r2323099;
        double r2323105 = r2323102 + r2323104;
        double r2323106 = r2323097 - r2323105;
        double r2323107 = r2323098 - r2323100;
        double r2323108 = r2323103 / r2323107;
        double r2323109 = r2323099 + r2323089;
        double r2323110 = r2323108 * r2323109;
        double r2323111 = r2323095 ? r2323106 : r2323110;
        return r2323111;
}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < -1.1039655744561852e+191 or 4.35485736957138e-39 < b

    1. Initial program 23.7

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - a \cdot b}{a + b}}}\]
    4. Taylor expanded around inf 11.0

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

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

    if -1.1039655744561852e+191 < b < 4.35485736957138e-39

    1. Initial program 2.3

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - a \cdot b}{a + b}}}\]
    4. Using strategy rm
    5. Applied div-inv2.4

      \[\leadsto \frac{1}{\color{blue}{\left(1 - a \cdot b\right) \cdot \frac{1}{a + b}}}\]
    6. Applied add-cube-cbrt2.4

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(1 - a \cdot b\right) \cdot \frac{1}{a + b}}\]
    7. Applied times-frac2.4

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1 - a \cdot b} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a + b}}}\]
    8. Simplified2.4

      \[\leadsto \color{blue}{\frac{1}{1 - a \cdot b}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a + b}}\]
    9. Simplified2.3

      \[\leadsto \frac{1}{1 - a \cdot b} \cdot \color{blue}{\left(a + b\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.103965574456185187720871491165962419889 \cdot 10^{191} \lor \neg \left(b \le 4.354857369571379975401692621934704586388 \cdot 10^{-39}\right):\\ \;\;\;\;\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - a \cdot b} \cdot \left(a + b\right)\\ \end{array}\]

Reproduce

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